<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rachit Ahuja on Medium]]></title>
        <description><![CDATA[Stories by Rachit Ahuja on Medium]]></description>
        <link>https://medium.com/@rachit_231095?source=rss-38de9229b8c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dppAXKyHu7w-hubejiRIYA.jpeg</url>
            <title>Stories by Rachit Ahuja on Medium</title>
            <link>https://medium.com/@rachit_231095?source=rss-38de9229b8c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:51:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rachit_231095/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Multi-Agent Systems with Claude: A Series Part 2 — The Five Patterns]]></title>
            <link>https://medium.com/@rachit_231095/multi-agent-systems-with-claude-a-series-part-2-the-five-patterns-74b8e0d380f0?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/74b8e0d380f0</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 18:56:08 GMT</pubDate>
            <atom:updated>2026-06-23T18:56:08.684Z</atom:updated>
            <content:encoded><![CDATA[<p>Last time, I drew a line between an agent and a multi-agent system: one LLM driving its own loop versus an orchestrator handing pieces of a problem off to isolated workers and synthesising what comes back. What I didn’t do is tell you how to get from one to the other, or how many ways there are to do it.</p><p>Anthropic has documented five of them in <em>Building Effective Agents</em>, and the framing that matters comes before any of the five individually:</p><blockquote><em>“Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.”</em></blockquote><p>That distinction splits the five patterns cleanly in half. Prompt Chaining, Routing, and Parallelisation are workflows: the control flow is fixed in code before the task ever runs, and the LLM is filling in content within a path you already drew. Orchestrator-Workers and Evaluator-Optimizer are different in kind, not just degree. An LLM call’s job becomes deciding what other LLM calls need to happen, at runtime, based on what it finds. That’s the first point in the list where “workflow” stops being an adequate word for what’s running.</p><p>One piece of Anthropic’s own guidance is worth keeping in view as you read: these are not prescriptive boxes to pick one from. They’re meant to be combined and customized, and added “only when it demonstrably improves outcomes” — because every step up this list trades latency and cost for task performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_3pNPddxKavcF2BIwg_sXw.png" /><figcaption>Multi-agent Architectural Patterns</figcaption></figure><h3><strong>Pattern 1: Prompt Chaining</strong></h3><p>The simplest shape on the list is a linear pipeline. User input goes to LLM call 1, the output passes through a programmatic gate, then to LLM call 2, and onward until the final output. Each call’s full output becomes the next call’s input. The gate is regular code — a validation function, a regex, a schema check — not another LLM call. It sits between steps and can halt the chain or kick it back if an intermediate result fails.</p><p>State is fully shared and fully serial: every downstream step sees everything upstream produced. There’s no isolation, which is exactly what separates this from the multi-agent patterns later in the list, where subagents deliberately don’t see each other’s context.</p><p>Anthropic’s worked example is writing an outline of a document, checking that the outline meets certain criteria, then writing the document based on the outline. The gate after step one is what prevents a structurally broken outline from silently becoming a structurally broken document. Their other example — generating marketing copy, then translating it — shows the same shape in a different domain. Translation quality depends entirely on the English draft it receives, so combining both into one call risks the model degrading on either sub-task.</p><p><strong>Reach for it</strong> when the task decomposes cleanly into a fixed, known sequence of subtasks, and you’re willing to trade latency for accuracy by making each individual call an easier problem.</p><p><strong>Skip it </strong>when the steps aren’t actually fixed. If you don’t know ahead of time how many steps there will be, or what step three should do until you’ve seen step two’s output, you’ve outgrown a chain. You need something deciding that at runtime instead.</p><p><strong>Failure mode:</strong> a chain always executes every step, in the same order, for every input. There’s no branching, only validation gates that can stop the chain, not redirect it. Force a chain onto a task that actually needs branching logic, and you end up with gates doing the work routing should be doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDeSaImOqSWrIhmQgg3gCg.png" /></figure><h3><strong>Pattern 2: Routing</strong></h3><p>Routing adds the first decision point. User input goes to a router — an LLM call or a classifier — that branches to one of several specialised downstream handlers. The router’s only job is classification. It doesn’t do the work itself; it decides which path does. Unlike a chain, only one branch executes per input. The others are never invoked.</p><p>The classifier doesn’t have to be an LLM. Anthropic’s framing is that it can be “a more traditional classification model/algorithm” — routing doesn’t require an LLM doing the routing, just something accurate at categorising.</p><p><strong>Two worked examples from the source</strong>: customer service requests split into general questions, refund requests, and technical support, each routed to a different downstream process with its own prompt and tools. And model routing for cost — sending easy or common questions to a smaller, cheaper model like Claude Haiku 4.5, and hard or unusual questions to a more capable model like Claude Sonnet 4.5.</p><p>Assembled, a customer-support platform, runs both variants of this at once. It analyses the skills a support case requires and routes it to the optimal handler — an AI agent or a human with specific expertise — while also routing by model tier: Claude 3.5 Sonnet for complex reasoning and Claude 3 Haiku for high-speed operations, the same cost-routing shape Anthropic describes generically above, now with a named deployment behind it. The reported results, for specific accounts rather than as a platform-wide average: more than 50% of support tickets automated, one customer’s routing accuracy improved from<strong> 62% to 90%</strong> across hundreds of categories, and Thrasio reported nearly<strong> $2M in cost savings</strong> with <strong>full resolution time down 50%</strong>.</p><p><strong>Reach for it </strong>when the task has distinct categories that are genuinely better handled by separate, specialized prompts or models, and accurate classification is achievable.</p><p><strong>Skip it </strong>when categories overlap heavily or classification accuracy is poor. Misrouted requests hit the wrong specialized handler with no recovery path — routing has no equivalent of the chain’s programmatic gate to catch a bad classification before it propagates.</p><p><strong>How it differs from chaining</strong>: chaining is “do step one, then step two, always.” Routing is “do exactly one of these N things, decided by what came in.” It’s not chaining with an if-statement bolted on. It’s a structurally different shape — one decision point, mutually exclusive paths, no shared sequential state between branches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-oqT0Agxkjf-lO_OyaDriQ.png" /></figure><h3><strong>Pattern 3: Parallelization</strong></h3><p>Parallelization fans out instead of branching. Input goes to simultaneous, independent LLM calls, which feed into programmatic aggregation, which produces the output. There are two distinct sub-patterns under this shape.</p><p>Sectioning breaks one task into independent subtasks, runs them concurrently, and combines the results — but the subtasks are predefined. You decided what they were in code before execution started. Voting runs the same task multiple times with different prompts or framings, then aggregates the outputs — majority vote, a threshold — to get a higher-confidence answer than any single attempt would give you.</p><p>In both variants, the parallel calls don’t communicate with each other during execution. They run in isolation and only get combined afterward, by code, not by another LLM call deciding how to combine them. That last detail is what separates this from Orchestrator-Workers, where synthesis is itself an LLM step.</p><p><strong>Worked examples from the source</strong>: sectioning shows up as guardrails, where one model instance processes user queries while another screens them for inappropriate content — “this tends to perform better than having the same LLM call handle both.” Voting shows up in code review, where several different prompts review and flag the same code for vulnerabilities, with results aggregated; and in content moderation, where multiple prompts evaluate different aspects or apply different vote thresholds to balance false positives against false negatives.</p><p><strong>Grafana’s incident-response assistant is a clean sectioning example</strong>. During an investigation it runs three fixed, named agents in parallel — a metrics agent, a logging agent, a tracing agent — each checking a different observability pillar, described directly as “multiple investigation branches running in parallel (not sequential).” The three roles are predefined, not decided at runtime by a coordinator weighing what it’s found so far, which is what would make this Orchestrator-Workers instead. It’s the same Grafana case study behind the 3.5x-faster, 8-minute root-cause finding from Part 1 — this is the architectural detail underneath that result, not a new case.</p><p><strong>Reach for it </strong>when subtasks can be cleanly divided in advance and parallelized for speed, or the task benefits from multiple independent perspectives raising confidence on a single judgment. Anthropic’s general note here is broader than this pattern alone: “for complex tasks with multiple considerations, LLMs generally perform better when each consideration is handled by a separate LLM call.”</p><p><strong>Skip it</strong> when the subtasks aren’t actually independent. If subtask B needs subtask A’s output, that’s not a parallelization problem — it’s a chaining problem. Voting specifically requires tuning a vote threshold; get it wrong and you trade false positives for false negatives or vice versa.</p><p>The comparison most likely to trip you up is Parallelization versus Orchestrator-Workers, because the two look identical on surface. Anthropic states the difference directly: “Whereas it’s topographically similar [to parallelization], the key difference from parallelization is its flexibility — subtasks aren’t pre-defined, but determined by the orchestrator based on the specific input.” In Parallelization, you — the developer, in code — decide what the parallel subtasks are before the task ever runs. In Orchestrator-Workers, the orchestrator LLM decides what the subtasks are, at runtime, based on what it finds. Same fan-out, fan-in shape on a diagram. Structurally different control flow underneath.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mcfPPKAGlNRCfOGaFlvtOw.png" /></figure><h3><strong>The line that actually matters</strong></h3><p>Here’s where the five patterns stop being a uniform list. The first three — chaining, routing, parallelization — are workflows in Anthropic’s own taxonomy. None of them require true multi-agent machinery. You could build all three with a single agent and well-placed code, and in a lot of cases, that’s exactly what you should do.</p><p>The last two are where the architecture earns the name. Orchestrator-Workers is the pattern Anthropic explicitly calls out as the structure underneath its own production multi-agent research system — the one from Part 1 that beat a single agent by 90.2% on Anthropic’s internal evaluation. Evaluator-Optimizer is the other genuinely adaptive pattern, though it solves a different problem: depth instead of breadth.</p><h3><strong>Pattern 4: Orchestrator-Workers</strong></h3><p>This is the pattern worth the most architectural detail, because it’s where control genuinely moves into the model’s hands. User input goes to an orchestrator LLM, which dynamically generates task assignments for N worker LLMs. Workers execute in parallel. The orchestrator synthesizes their results into an output — or loops back to spawn more workers if the synthesis reveals gaps.</p><p>The state handling is the key shift from Parallelization: each worker operates in its own isolated context window and does not see what its siblings are doing. The orchestrator is the only place state gets aggregated. From <em>How we built our multi-agent research system</em>: the lead agent “develops a strategy, and spawns subagents to explore different aspects simultaneously,” then “synthesizes these results and decides whether more research is needed — if so, it can create additional subagents or refine its strategy.” That last clause is what makes it a loop and not a single fan-out-fan-in pass. The orchestrator can re-delegate based on what comes back — something none of the first three patterns do.</p><p>Anthropic’s worked examples from <em>Building Effective Agents</em> are coding products that make complex changes to multiple files, and search tasks that gather and analyze information from multiple sources. Both share a property: you genuinely cannot enumerate the subtasks ahead of time. The right files to touch, or the right sources to search, depend on what the orchestrator discovers as it goes.</p><p>The research system gives a more concrete version of the same idea. Effort scales with the orchestrator’s own assessment of the query, per Anthropic’s heuristics: simple fact-finding requires just one agent with three to ten tool calls, direct comparisons might need two to four subagents with ten to fifteen calls each, and complex research might use more than ten subagents with clearly divided responsibilities. For a typical query, the lead agent spins up three to five subagents in parallel. Anthropic’s documentation also describes each subagent receiving a four-part delegation contract before it starts — a clear objective, a specified output format, guidance on which tools and sources to use, and explicit task boundaries defining when it’s done. Miss any of the four, and the subagent drifts.</p><p>Two production examples outside Anthropic’s own research system show the same shape. Netflix’s platform team built an agent on Claude’s Multiagent Orchestration feature to process build logs from hundreds of builds across different sources. As Anthropic describes it: “Multiagent orchestration lets the agent analyze batches in parallel and surface only the patterns worth acting on” — a lead agent decomposing a noisy, high-volume task and delegating to specialists running in parallel on a shared filesystem, then synthesizing down to what recurs across many builds rather than what’s noise in any one of them.</p><p>Thomson Reuters’ Deep Research system, behind Westlaw and CoCounsel, is explicit about rejecting the alternative: “Instead of one monolithic agent, we orchestrate specialized components, each tuned for a particular document type” — case law, statutes, secondary sources. The system layers multi-step planning, parallel execution, and dynamic tool selection on top, with a strategy that adapts as findings come in. That’s the architecture behind CoCounsel’s headline numbers from <a href="https://medium.com/@rachit_231095/multi-agent-systems-with-claude-a-series-4f3e7edd3bf7">Part 1</a>: tasks cut from 8–9 hours to 1–2 hours for some users, with roughly 76% completion on unconstrained end-to-end workflows.</p><p><strong>Reach for it </strong>when you cannot predict the subtasks needed ahead of time — the decomposition itself depends on what the system learns mid-task.</p><p>Skip it when you can enumerate the subtasks in advance. If you already know what the parallel pieces are, you don’t need an LLM deciding that for you — use Parallelization instead and save the coordination overhead.</p><p>Failure modes, specific to this pattern: Anthropic’s own engineering write-up is unusually candid about what went wrong in early versions. Agents were “spawning 50 subagents for simple queries” — the orchestrator over-decomposing trivial tasks because nothing constrained its effort-scaling judgment. There was direct work duplication too: “one subagent explored the 2021 automotive chip crisis while 2 others duplicated work investigating current 2025 supply chains” — sibling workers with no visibility into each other’s task scope, redoing the same research from different angles. And there’s a structural bottleneck Anthropic names directly: execution is currently synchronous. The lead agent can’t steer subagents mid-task, subagents can’t coordinate with each other, and the entire system can be blocked while waiting for a single subagent to finish searching. That’s the cost of the isolation that makes the pattern work — clean, uncontaminated worker contexts, in exchange for giving up the ability to course-correct a worker once it’s running.</p><p><strong>How it differs from its neighbors</strong>: versus Parallelization, decomposition is dynamic rather than predefined (the comparison above). Versus Evaluator-Optimizer, the next pattern, Orchestrator-Workers fans out to multiple distinct workers doing different things in service of one larger task. Evaluator-Optimizer is a tight two-role loop — one generator, one evaluator — iterating on a single piece of output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jI5MxsqYcvaeqfXMpYXs0A.png" /></figure><h3><strong>Pattern 5: Evaluator-Optimizer</strong></h3><p>This one is a loop, not a pipeline. Input goes to a generator LLM, which produces output. An evaluator LLM assesses that output against criteria and gives feedback. If the output isn’t satisfactory, it loops back to the generator with that feedback, and the cycle continues until criteria are met. Two distinct LLM roles, each call seeing the prior round’s output plus the evaluator’s critique — context accumulates round over round here, rather than getting isolated the way it does in Orchestrator-Workers.</p><p>Anthropic’s worked examples: literary translation, where there are nuances a translator LLM might not capture initially, but an evaluator LLM can provide useful critiques on. And complex search tasks that require multiple rounds of searching and analysis to gather comprehensive information, where the evaluator decides whether further searches are warranted.</p><p>That second example overlaps with research use cases also covered under Orchestrator-Workers, and the distinguishing factor is the shape of the loop. Evaluator-Optimizer is appropriate when refinement is about the quality of a single artifact improving over rounds — not about coverage across independent subtasks.</p><p>Wisedocs, a medical-document review company, makes a better example than translation because the loop is concrete and the result is measured. They built a document quality check agent on Claude’s Outcomes feature, which grades each review against their internal guidelines and sends it back for revision if it falls short. Wisedocs now runs reviews 50% faster while staying aligned with their standards. Outcomes is this pattern as a platform primitive: a developer writes a rubric, a grader agent in its own isolated context window rereads the artifact against it after every revision, and either marks it satisfied or returns a specific list of gaps — looping until the bar is met or a maximum iteration count is hit.</p><p>Reach for it when two conditions both hold, per Anthropic’s own framing: “first, that LLM responses can be demonstrably improved when a human articulates their feedback; and second, that the LLM can provide such feedback” — meaning an LLM evaluator can actually approximate that human critique. Clear evaluation criteria need to exist, and iterative refinement needs to provide measurable value.</p><p>Skip it when there’s no clear way to evaluate “better” — no rubric, no criteria a model or human could articulate. The loop has nothing to converge against.</p><p>One failure mode deserves to be called out on its own, because it’s unique to this pattern: without an explicit stopping condition — a max round count, or a hard quality bar — Evaluator-Optimizer has a built-in infinite-loop failure mode. The evaluator can keep finding something to critique indefinitely. Every other pattern on the list terminates on its own; this is the one that doesn’t unless you make it.</p><p>How it differs from Orchestrator-Workers: both are runtime-adaptive, and neither has fixed, predefined subtasks. But Orchestrator-Workers fans out across breadth, with multiple workers covering different ground in parallel. Evaluator-Optimizer iterates in depth: one thread of work, refined repeatedly, never parallelized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdKEPTVq22ZqVe7lCH9SHw.png" /></figure><h3><strong>What Anthropic’s research system actually runs</strong></h3><p>It isn’t a textbook single-pattern implementation. Anthropic’s production Research feature is Orchestrator-Workers combined with an extra verification stage. A lead agent (Claude Opus 4) plus three to five parallel subagents (Claude Sonnet 4) form the orchestrator-workers core. On top of that, a separate Citation Agent post-processes findings to verify and format citations independently, after synthesis — avoiding what you might call a game of telephone, where source attribution degrades through re-summarization chains.</p><p>Structurally, the Citation Agent is closer to an Evaluator-Optimizer pass bolted onto the end of an Orchestrator-Workers pipeline than it is a sixth distinct pattern. It generates nothing new. It checks the lead agent’s synthesized output against the original sources and corrects it. This is the concrete version of the combine-and-customize advice from the top of the piece — the base patterns as building blocks, not mutually exclusive choices.</p><h3><strong>Which one you actually need</strong></h3><p>Lay the five out in order and a shape emerges. Chaining, Routing, and Parallelization share one thing: you, the developer, decided the control flow in code before the task ran. The LLM fills in content within a path you already drew, and you can build all three with a single agent. Orchestrator-Workers and Evaluator-Optimizer are different because the decomposition — what subtask comes next, or whether this round’s output is good enough — gets made by a model at runtime, not by you in advance.</p><p>So the decision comes down to two questions. Reach for Orchestrator-Workers when you cannot enumerate the subtasks ahead of time and the work genuinely benefits from breadth: multiple workers covering different ground simultaneously. Reach for Evaluator-Optimizer when the work is depth, not breadth — one artifact, refined against explicit criteria, round over round.</p><p>The failure modes across all five point the same direction. Force a fixed pipeline onto a task that needs branching, and your gates start doing routing’s job badly. Misclassify in a router with no recovery path, and the wrong specialized handler runs with nothing to catch it. Run parallel calls on subtasks that secretly depend on each other, and you get garbage synthesized confidently. Let an orchestrator decompose without effort-scaling discipline, and it spawns 50 subagents for a question that needed one. Let an evaluator loop run without a stopping condition, and it critiques forever.</p><p>None of these patterns is the “advanced” one you graduate into. They’re five different shapes for five different control-flow problems, and the right move is matching the shape to the constraint you actually have — not reaching for the one that sounds the most like a real multi-agent system.</p><p>Five patterns down. What’s still missing is what it actually looks like to build one — not the diagram, the code. Part 3 is next: a hands-on walkthrough with the Managed Agents API, building the coordinator-worker pattern from scratch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74b8e0d380f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-Agent Systems with Claude: A Series]]></title>
            <link>https://medium.com/@rachit_231095/multi-agent-systems-with-claude-a-series-4f3e7edd3bf7?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f3e7edd3bf7</guid>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 12:41:14 GMT</pubDate>
            <atom:updated>2026-06-23T19:29:58.316Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part 1 — What They Are and Why They Exist</h3><p>Here’s something Anthropic buried in an engineering <a href="https://www.anthropic.com/engineering/building-effective-agents">post</a> that I think should have been the headline: their own engineers spent months building elaborate multi-agent architectures — real ones, production-grade — only to find that better prompting on a single agent would have gotten them there.</p><p>I keep coming back to that admission because it cuts against the grain of how this technology gets talked about. Multi-agent systems are not a level-up. They’re not what you reach for once your single agent starts feeling “too basic.” They’re a specific solution to a specific class of problems — and when you apply them to the wrong problem, you’re paying somewhere around 15x in tokens for something a well-written system prompt could have handled.</p><p>That said: when they <em>do</em> apply, the gains are real. <a href="https://www.anthropic.com/engineering/multi-agent-research-system">Anthropic’s internal Research feature</a> — Claude Opus 4 as an orchestrator running a team of Sonnet 4 subagents — outperformed a single Opus 4 agent by 90.2% on their benchmarks and cut research time by up to 90%. That’s not a rounding error. That’s the kind of number that makes you want to understand exactly what made that problem the right one.</p><p>That question — what makes a problem the right one — is what this series is about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAxfiSuPP8BhJ1OvOrAAJA.jpeg" /><figcaption>90.2% better. 90% faster. But only when the problem actually calls for it</figcaption></figure><h3>What we’re actually talking about</h3><p>Before patterns and architectural diagrams, it’s worth being precise about what an “agent” actually is, because the word is doing a lot of heavy lifting right now.</p><p>The foundational piece is what Anthropic calls the <a href="https://www.anthropic.com/engineering/multi-agent-research-system"><strong>augmented LLM</strong></a>: a language model with retrieval, tools, and memory attached. Not a chatbot. Something that can actually do things. An agent is a system where this LLM drives its own loop — gather context, take an action, check the output, iterate. That loop is the important part. It’s what separates an agent from a pipeline where your code is doing the driving and the model is just one step in the chain.</p><p>A <strong>multi-agent system</strong> adds a layer on top: a central orchestrator receives a high-level goal, figures out how to decompose it, hands pieces off to specialized workers, and synthesizes what comes back. Each worker runs in its own isolated context window. They don’t share state. Everything flows through the orchestrator.</p><p>The isolation is actually the point. Workers stay focused. They don’t inherit each other’s accumulated noise. The orchestrator gets clean summaries rather than raw transcripts. This is what enables the scale — you can have five agents exploring five directions simultaneously, each with a clean slate, each returning a tight summary to a coordinator that never had to watch any of the mess.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rd5Rpeq1XPkegdIDNnWFng.jpeg" /></figure><h3>Why single agents hit walls</h3><p>Most developers run into one of three things before they start thinking seriously about multi-agent systems.</p><p><strong>Context.</strong> Claude has a 200,000-token context window, which sounds large until you’re doing multi-hour research or analyzing a large codebase and you watch the tool outputs pile up. The obvious problem is that context fills up eventually. The subtler problem is that performance starts degrading well before that — effective working context is closer to 60,000–80,000 tokens before things start to slip. A focused agent with a clean context window is more reliable than one wading through 150K tokens of accumulated history.</p><p><strong>Parallelization.</strong> Some tasks have genuinely independent subtasks that could be explored simultaneously. A single agent runs them one after another. You can get some of this with parallel tool calls within a single agent — Anthropic’s data shows it cut research time by up to 90% for complex queries — but you’re still bounded by one thread. Multiple subagents each exploring a different direction reduces total time from the sum of all subtasks to the max of any one subtask.</p><p><strong>Specialization.</strong> A general-purpose agent with 50 tools performs worse than one with 10 well-matched tools. Large tool sets create selection confusion. Three signals this is happening to you: you’re above 20 tools in a single agent, your tools span completely different domains, or adding new tools makes existing tasks worse.</p><p>Those are the three genuine constraints. Notice the corollary: if your task doesn’t hit any of them, you’re adding complexity and paying the 15x token cost for nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3SzAmC0OOACRoT1pheymrQ.png" /></figure><h3>The cost reality (keep this number in your head)</h3><ul><li>Chat: <strong>1x</strong> tokens</li><li>Single agent with tools: <strong>~4x</strong> tokens</li><li>Multi-agent system: <strong>~15x</strong> tokens</li></ul><p>That <a href="https://www.anthropic.com/engineering/multi-agent-research-system">15x is not a marginal overhead</a>. It’s the normal operating cost of the architecture. Whether it earns its keep depends entirely on whether your problem actually needs what multi-agent systems provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xc9RN-0lus3EVuPja95iaw.png" /></figure><h3>Who’s actually building this</h3><p>A few companies that have talked publicly about what they built — and what they ran into.</p><p><strong>Grafana Labs — parallel agents for observability.</strong> Grafana built a Claude-powered multi-agent assistant that fans out to specialized subagents — a metrics agent, a logging agent, a tracing agent — running in parallel to investigate production incidents. The results are concrete: in <a href="https://grafana.com/blog/a-tale-of-two-incident-responses-how-our-ai-assist-helped-us-find-the-cause-3-5x-faster/">one published case study</a>, the assistant identified the root cause of a database failure in eight minutes, about 20 minutes ahead of the on-call team, 3.5x faster overall. The gains came directly from parallelization — the three signal types being examined were genuinely independent, so splitting them across agents rather than running them sequentially actually made sense.</p><p><strong>Intercom — not one agent, but a pipeline of 15–20 of them.</strong> <a href="https://claude.com/customers/intercom">Intercom’s Fin AI agent</a>, powered by Claude, looks like a single assistant from the outside. Under the hood it’s a pipeline of 15–20 subcomponents, each paired with a model tuned for a specific task — answer generation, answer verification, policy compliance. The resolution rate is around 51% out of the box across thousands of customers, with some deployments reportedly reaching 70–80%. Extending Fin to new channels like email required rebuilding parts of that pipeline from scratch, since email has different requirements than chat — a reminder that each component adds surface area for things to break.</p><p><strong>Thomson Reuters — agentic legal AI, but audit-ready by design.</strong> <a href="https://www.thomsonreuters.com/en-us/posts/innovation/rebuilding-for-the-agent-era-the-next-generation-of-cocounsel-legal/">CoCounsel</a>, Thomson Reuters’s AI for legal, tax, and accounting work, uses multi-step agentic workflows that reportedly cut tasks from eight-to-nine hours down to one-to-two hours for some users. On their own evaluations, CoCounsel completes roughly 76% of unconstrained end-to-end workflows. What’s notable about their approach is the deliberate investment in traceability and audit trails — because in legal and compliance work, a hallucination buried in an agent pipeline isn’t just an inconvenience. The governance overhead is part of the system, not a footnote.</p><p><strong>Tines — where the hard part was trust, not tech.</strong> <a href="https://claude.com/customers/tines">Tines</a> builds security and IT automation, and added autonomous AI agents to its platform in mid-2025. Their honest finding: the biggest barrier wasn’t model capability, it was that security teams needed to know exactly what an agent would do before it did it. “It usually gets it right” doesn’t cut it when the action involves firewall rules or a live incident. Their response was a tiered model — deterministic logic where you need predictability, AI copilot patterns where humans confirm before acting, full autonomy only where it’s genuinely safe to grant. Customer numbers include one SOC running an estimated 95-employee-equivalent workload through automation, and SAP reporting 3–6x speed improvements on specific workflows.</p><h3>What’s coming in this series</h3><p>This is the first post in a series that’s going to work through multi-agent systems the way I’d want them explained to me — practically, honestly, without overselling the architecture.</p><p>Here’s the arc:</p><p><a href="https://medium.com/@rachit_231095/multi-agent-systems-with-claude-a-series-part-2-the-five-patterns-74b8e0d380f0"><strong>Part 2 — The Five Patterns</strong></a><strong>:</strong> Anthropic has documented five workflow patterns for multi-agent systems. The first three don’t require true multi-agent machinery. The last two are where the real orchestrator/worker architecture lives. We’ll go through all five, when to reach for each, and what the failure modes look like.</p><p><strong>Part 3 — Building One:</strong> A hands-on walkthrough with the Managed Agents API (currently in beta). We’ll build the coordinator/worker pattern from scratch — create specialist agents, wire up the orchestrator, run a real task.</p><p><strong>Part 4 — What Goes Wrong:</strong> Hallucinations that compound across agent handoffs. Context bloat accumulating at the orchestrator level. Subagents that drift because the delegation contract was vague. Costs that run away before you notice. This post is the one I wish I had before building my first multi-agent system.</p><p><strong>Part 5 — When Not To Use Multi-Agent:</strong> A decision framework. Start with the simplest possible thing. Measure where it breaks. Only reach for multi-agent when you can point at a specific constraint a single agent genuinely cannot overcome. This post is the one that saves you from the trap Anthropic’s own engineers fell into.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5akeW7kmCbss_FB2bqH5w.png" /></figure><p>Multi-agent systems with Claude are a real capability with real results — when the problem fits. The goal of this series is to give you a clear enough picture of how they work, what they cost, and where they break that you can make that call confidently, in either direction.</p><p><a href="https://medium.com/@rachit_231095/multi-agent-systems-with-claude-a-series-part-2-the-five-patterns-74b8e0d380f0">Part 2 is next: five patterns</a>, and the question of which one you actually need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f3e7edd3bf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End-to-End MLOps Pipelines for Sentiment Analysis on Azure using Terraform, Kubeflow v2, MlFlow and…]]></title>
            <link>https://medium.com/datareply/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c0d18e3d286</guid>
            <category><![CDATA[seldon-core]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[machinelerning]]></category>
            <category><![CDATA[kubeflow]]></category>
            <category><![CDATA[kubeflow-pipelines]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 12:49:26 GMT</pubDate>
            <atom:updated>2023-08-25T13:00:40.718Z</atom:updated>
            <content:encoded><![CDATA[<h3>End-to-End MLOps Pipelines for Sentiment Analysis on Azure using Terraform, Kubeflow v2, MlFlow and Seldon: Part5</h3><p><strong>Part 1: </strong><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1"><strong>Introduction and Architecture planning</strong></a></p><p><strong>Part 2: </strong><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f"><strong>Developing workflows for infrastructure deployment via CI-CD</strong></a></p><p><strong>Part 3: </strong><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258"><strong>Setup MLflow on AKS</strong></a></p><p><strong>Part 4: </strong><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11"><strong>Setup Kubeflow and Seldon on AKS</strong></a></p><p><strong>Part 5: </strong><a href="https://medium.com/@rachit_231095/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286"><strong>End-to-End training pipeline and Inference Deployment using Seldon</strong></a></p><p>In this final installment (Part 5), we embark on the execution of an End-to-End Training Pipeline for a Sentiment Analysis Model. This encompassing pipeline encompasses various stages, commencing from establishing an MLFlow experiment for meticulous training run tracking, data retrieval, preprocessing, training diverse models, and ultimately registering the best model based on accuracy metrics. To facilitate a straightforward implementation, we’ll employ port-forwarding to route our Kubeflow pipeline to a local port and trigger the training pipeline via API calls. In real-world scenarios, these training runs are typically scheduled as recurring Jobs. The entire repository containing the pipeline and source code can be accessed here: <a href="https://github.com/rahuja23/Blogpost_kubeflow_pipeline">here</a>. This repository houses three subdirectories: one containing source code for each step, another containing the pipeline code leveraging base images to initiate the training pipeline and the last sub-directory containing the Inference code along with the dependent files.</p><p>The following KubeFlow script is responsible for triggering the training pipeline. It can be integrated into CI/CD workflows or manually invoked:</p><pre>import kfp<br>import kfp.dsl as dsl<br>from kfp.v2.dsl import (<br>    component,<br>    Input,<br>    Output,<br>    Dataset,<br>    Artifact,<br>    InputPath,<br>    OutputPath,<br>)<br>from kfp import compiler<br>import subprocess<br>from kfp.aws import use_aws_secret<br>from typing import NamedTuple<br><br>@component(base_image=&quot;racahu23/blog_mlflow:1&quot;, packages_to_install=[&#39;mlflow&#39;])<br>def mlflow_setup_experiment(tracking_uri:str)-&gt;NamedTuple(&#39;Outputs&#39;,[(&quot;exp_id&quot;, str), (&quot;run_id&quot;, str)]):<br>    import main<br>    op = main.main(tracking_uri)<br>    return op<br>@component(base_image=&quot;racahu23/preprocess:blog&quot;,  packages_to_install=[&#39;mlflow&#39;, &#39;boto3&#39;])<br>def twitter_download_preprocess(information: Output[Artifact],  experiment_id: str, run_id: str, tracking_uri: str):<br>    from main import twitter_sample_download_and_preprocess<br>    args={<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;: information.path<br>    }<br>    twitter_sample_download_and_preprocess(args)<br><br>@component(base_image=&quot;racahu23/numpy:blog_final&quot;,  packages_to_install=[&#39;mlflow&#39;, &#39;boto3&#39;])<br>def numpy_process(information: Input[Artifact], information_output: Output[Artifact],  experiment_id: str, run_id: str,<br>                  tracking_uri: str):<br>    from main import numpy_process<br>    args = {<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;: information.path,<br>        &quot;output_dir&quot;: information_output.path<br>           }<br>    op = numpy_process(args)<br>    return op<br>@component(base_image=&quot;racahu23/scikit:3&quot;, packages_to_install=[&#39;boto3&#39;])<br>def sklearn_logistic(information_input: Input[Artifact], experiment_id: str,<br>                     tracking_uri: str, run_id: str,  sklearn_output: Output[Artifact]):<br>    from main import sklearn_logistic<br>    args = {<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;:  information_input.path,<br>        &quot;output_dir&quot;: sklearn_output.path,<br>        &quot;run_id&quot;: run_id<br>    }<br>    op = sklearn_logistic(args)<br>@component(base_image=&quot;racahu23/logistic:2&quot;,   packages_to_install=[&#39;mlflow&#39;, &#39;boto3&#39;])<br>def logistic_op(sklearn_input:Input[Artifact], logistic_output: Output[Artifact],  experiment_id: str, run_id: str,<br>                tracking_uri: str):<br>    from main import logistic<br>    args = {<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;: sklearn_input.path,<br>        &quot;output_dir&quot;: logistic_output.path<br>    }<br>    op = logistic(args)<br>@component(base_image=&quot;racahu23/torch:1&quot;,  packages_to_install=[&#39;mlflow&#39;, &#39;boto3&#39;])<br>def torch_op(logistic_input:Input[Artifact], torch_output: Output[Artifact],<br>             experiment_id: str, run_id: str, tracking_uri: str<br>             ):<br>    from main import torch_process_logistic<br>    args = {<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;: logistic_input.path,<br>        &quot;output_dir&quot;: torch_output.path<br>    }<br>    op = torch_process_logistic(args)<br><br>@component(base_image=&quot;racahu23/svm:1&quot;,  packages_to_install=[&#39;mlflow&#39;, &#39;boto3&#39;])<br>def svm_op(svm_input: Input[Artifact], svm_output: Output[Artifact],<br>           experiment_id: str, run_id: str, tracking_uri: str<br>           ):<br>    from main import svm_process<br>    args = {<br>        &quot;experiment_id&quot;: experiment_id,<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>        &quot;log_folder&quot;: svm_input.path,<br>        &quot;output_dir&quot;: svm_output.path<br>    }<br>    op = svm_process(args)<br><br>@component(base_image=&quot;racahu23/register:4&quot;,  packages_to_install=[&#39;mlflow&#39;, &#39;python-dotenv&#39;])<br>def register_op( run_id: str, tracking_uri: str):<br>    from main import register_model<br>    args = {<br>        &quot;run_id&quot;: run_id,<br>        &quot;tracking_uri&quot;: tracking_uri,<br>    }<br>    op = register_model(args)<br><br>if __name__ ==&quot;__main__&quot;:<br>    @dsl.pipeline(<br>        name=&#39;Twitter nltk pipeline&#39;,<br>        description=&#39;Writing code by the other way.&#39;<br>    )<br>    def pipeline(mlflow_uri: str):<br>        pvc_name = &quot;twitter-5000&quot;<br>        &quot;&quot;&quot;<br>        vop = dsl.VolumeOp(<br>            name=pvc_name,<br>            resource_name=&quot;twitter-5000&quot;,<br>            size=&quot;1Gi&quot;,<br>            modes=dsl.VOLUME_MODE_RWM<br>        )<br>        &quot;&quot;&quot;<br>        op_mlflow = mlflow_setup_experiment(tracking_uri=mlflow_uri)<br>        download_task= twitter_download_preprocess(experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], run_id=op_mlflow.outputs[&quot;run_id&quot;], tracking_uri=mlflow_uri)<br>        numpy_task = numpy_process(information=download_task.outputs[&#39;information&#39;], experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], run_id=op_mlflow.outputs[&quot;run_id&quot;]<br>                                   , tracking_uri=mlflow_uri).after(<br>            download_task)<br><br><br>        sklearn_task= sklearn_logistic(information_input=numpy_task.outputs[&quot;information_output&quot;], experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], tracking_uri=mlflow_uri, run_id=op_mlflow.outputs[&quot;run_id&quot;]).after(numpy_task)<br><br><br>        logistic_task= logistic_op(sklearn_input=numpy_task.outputs[&quot;information_output&quot;], experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], run_id=op_mlflow.outputs[&quot;run_id&quot;]<br>                                   , tracking_uri=mlflow_uri).after(sklearn_task)<br><br><br>        torch_task = torch_op(logistic_input=numpy_task.outputs[&quot;information_output&quot;], experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], run_id=op_mlflow.outputs[&quot;run_id&quot;]<br>                                   , tracking_uri=mlflow_uri ).after(logistic_task)<br><br>        svm_task = svm_op(svm_input=numpy_task.outputs[&quot;information_output&quot;], experiment_id=op_mlflow.outputs[&quot;exp_id&quot;], run_id=op_mlflow.outputs[&quot;run_id&quot;]<br>                                   , tracking_uri=mlflow_uri).after(torch_task)<br>        register_task = register_op(tracking_uri=mlflow_uri, run_id=op_mlflow.outputs[&quot;run_id&quot;]).after(svm_task)<br>if __name__ == &quot;__main__&quot;:<br>  client = kfp.Client(namespace=&quot;rahuja23&quot;, host=&quot;http://localhost:8080&quot;)<br>  client.create_run_from_pipeline_func(pipeline,<br>                                         arguments={&quot;mlflow_uri&quot;: &quot;http://mlflow.use-case.svc.cluster.local:5000&quot;},<br>                                         mode=kfp.dsl.PipelineExecutionMode.V2_COMPATIBLE,<br>                                         enable_caching=False)</pre><p>The script efficiently triggers the training pipeline, orchestrating each stage along the way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LzlAgCmZwYQ7J9OmeboRCw.png" /><figcaption>End-to-End Kubeflow Pipeline</figcaption></figure><p>Following this comprehensive pipeline execution, the logged artifacts contribute to registering the optimal model within MLFlow, grounded in individual experiment outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7OeiRosBVsHUvcjX-WQaJQ.png" /><figcaption>Mlflow Server with logged Experiment Data</figcaption></figure><p>The focal point now shifts towards the deployment of our prime registered ML model utilising Seldon.</p><h3><strong>Model Deployment using Seldon</strong></h3><p>In this segment, we delve into the deployment of the premier model as a Kubernetes deployment with the aid of Seldon. Seldon offers an open-source platform, “Seldon Core,” designed to assist data scientists and engineers in deploying and overseeing machine learning models on Kubernetes clusters.</p><p>The Inference folder’s structure is outlined below:</p><pre>Inference<br>|-- Dockerfile<br>|-- Inference.py<br>|-- depl.yaml<br>|-- requirements.txt<br>`-- sklearn_folder<br>    |-- Sentiment-LR.pickle<br>    `-- vectoriser-ngram-(1,2).pickle<br><br></pre><p>To carry out the model deployment, the ensuing steps are imperative:</p><ul><li><strong>Create a Custom Wrapper</strong>: Formulate the custom wrapper code incorporating the intended functionality. This may encompass preprocessing logic, post-processing logic, or any other tailored behavior. The wrapper can be scripted using your preferred programming language.</li></ul><pre>%%Inference.py<br><br>import re<br>import string<br>from nltk.corpus import stopwords<br>from nltk.stem import PorterStemmer<br>from nltk.tokenize import TweetTokenizer<br>from nltk.stem import WordNetLemmatizer<br>import pickle<br>import os<br>import logging<br>log = logging.getLogger()<br>class Inference(object):<br>    def __init__(self):<br>        self.model_loaded = False<br>        self.tokenizer = TweetTokenizer(preserve_case=False, strip_handles=True, reduce_len=True)<br>        self.stopwords_en = stopwords.words(&#39;english&#39;)<br>        self.punctuation_en = string.punctuation<br>        self.stemmer = PorterStemmer()<br>        self.sklearn_folder= &quot;sklearn_folder&quot;<br>        self.emojis = {&#39;:)&#39;: &#39;smile&#39;, &#39;:-)&#39;: &#39;smile&#39;, &#39;;d&#39;: &#39;wink&#39;, &#39;:-E&#39;: &#39;vampire&#39;, &#39;:(&#39;: &#39;sad&#39;,<br>                  &#39;:-(&#39;: &#39;sad&#39;, &#39;:-&lt;&#39;: &#39;sad&#39;, &#39;:P&#39;: &#39;raspberry&#39;, &#39;:O&#39;: &#39;surprised&#39;,<br>                  &#39;:-@&#39;: &#39;shocked&#39;, &#39;:@&#39;: &#39;shocked&#39;, &#39;:-$&#39;: &#39;confused&#39;, &#39;:\\&#39;: &#39;annoyed&#39;,<br>                  &#39;:#&#39;: &#39;mute&#39;, &#39;:X&#39;: &#39;mute&#39;, &#39;:^)&#39;: &#39;smile&#39;, &#39;:-&amp;&#39;: &#39;confused&#39;, &#39;$_$&#39;: &#39;greedy&#39;,<br>                  &#39;@@&#39;: &#39;eyeroll&#39;, &#39;:-!&#39;: &#39;confused&#39;, &#39;:-D&#39;: &#39;smile&#39;, &#39;:-0&#39;: &#39;yell&#39;, &#39;O.o&#39;: &#39;confused&#39;,<br>                  &#39;&lt;(-_-)&gt;&#39;: &#39;robot&#39;, &#39;d[-_-]b&#39;: &#39;dj&#39;, &quot;:&#39;-)&quot;: &#39;sadsmile&#39;, &#39;;)&#39;: &#39;wink&#39;,<br>                  &#39;;-)&#39;: &#39;wink&#39;, &#39;O:-)&#39;: &#39;angel&#39;, &#39;O*-)&#39;: &#39;angel&#39;, &#39;(:-D&#39;: &#39;gossip&#39;, &#39;=^.^=&#39;: &#39;cat&#39;}<br><br>        ## Defining set containing all stopwords in english.<br>        self.stopwordlist = [&#39;a&#39;, &#39;about&#39;, &#39;above&#39;, &#39;after&#39;, &#39;again&#39;, &#39;ain&#39;, &#39;all&#39;, &#39;am&#39;, &#39;an&#39;,<br>                        &#39;and&#39;, &#39;any&#39;, &#39;are&#39;, &#39;as&#39;, &#39;at&#39;, &#39;be&#39;, &#39;because&#39;, &#39;been&#39;, &#39;before&#39;,<br>                        &#39;being&#39;, &#39;below&#39;, &#39;between&#39;, &#39;both&#39;, &#39;by&#39;, &#39;can&#39;, &#39;d&#39;, &#39;did&#39;, &#39;do&#39;,<br>                        &#39;does&#39;, &#39;doing&#39;, &#39;down&#39;, &#39;during&#39;, &#39;each&#39;, &#39;few&#39;, &#39;for&#39;, &#39;from&#39;,<br>                        &#39;further&#39;, &#39;had&#39;, &#39;has&#39;, &#39;have&#39;, &#39;having&#39;, &#39;he&#39;, &#39;her&#39;, &#39;here&#39;,<br>                        &#39;hers&#39;, &#39;herself&#39;, &#39;him&#39;, &#39;himself&#39;, &#39;his&#39;, &#39;how&#39;, &#39;i&#39;, &#39;if&#39;, &#39;in&#39;,<br>                        &#39;into&#39;, &#39;is&#39;, &#39;it&#39;, &#39;its&#39;, &#39;itself&#39;, &#39;just&#39;, &#39;ll&#39;, &#39;m&#39;, &#39;ma&#39;,<br>                        &#39;me&#39;, &#39;more&#39;, &#39;most&#39;, &#39;my&#39;, &#39;myself&#39;, &#39;now&#39;, &#39;o&#39;, &#39;of&#39;, &#39;on&#39;, &#39;once&#39;,<br>                        &#39;only&#39;, &#39;or&#39;, &#39;other&#39;, &#39;our&#39;, &#39;ours&#39;, &#39;ourselves&#39;, &#39;out&#39;, &#39;own&#39;, &#39;re&#39;,<br>                        &#39;s&#39;, &#39;same&#39;, &#39;she&#39;, &quot;shes&quot;, &#39;should&#39;, &quot;shouldve&quot;, &#39;so&#39;, &#39;some&#39;, &#39;such&#39;,<br>                        &#39;t&#39;, &#39;than&#39;, &#39;that&#39;, &quot;thatll&quot;, &#39;the&#39;, &#39;their&#39;, &#39;theirs&#39;, &#39;them&#39;,<br>                        &#39;themselves&#39;, &#39;then&#39;, &#39;there&#39;, &#39;these&#39;, &#39;they&#39;, &#39;this&#39;, &#39;those&#39;,<br>                        &#39;through&#39;, &#39;to&#39;, &#39;too&#39;, &#39;under&#39;, &#39;until&#39;, &#39;up&#39;, &#39;ve&#39;, &#39;very&#39;, &#39;was&#39;,<br>                        &#39;we&#39;, &#39;were&#39;, &#39;what&#39;, &#39;when&#39;, &#39;where&#39;, &#39;which&#39;, &#39;while&#39;, &#39;who&#39;, &#39;whom&#39;,<br>                        &#39;why&#39;, &#39;will&#39;, &#39;with&#39;, &#39;won&#39;, &#39;y&#39;, &#39;you&#39;, &quot;youd&quot;, &quot;youll&quot;, &quot;youre&quot;,<br>                        &quot;youve&quot;, &#39;your&#39;, &#39;yours&#39;, &#39;yourself&#39;, &#39;yourselves&#39;]<br><br>    def preprocess(self, textdata):<br>        processedText = []<br><br>        # Create Lemmatizer and Stemmer.<br>        wordLemm = WordNetLemmatizer()<br><br>        # Defining regex patterns.<br>        urlPattern = r&quot;((http://)[^ ]*|(https://)[^ ]*|( www\.)[^ ]*)&quot;<br>        userPattern = &#39;@[^\s]+&#39;<br>        alphaPattern = &quot;[^a-zA-Z0-9]&quot;<br>        sequencePattern = r&quot;(.)\1\1+&quot;<br>        seqReplacePattern = r&quot;\1\1&quot;<br><br>        for tweet in textdata:<br>            tweet = tweet.lower()<br><br>            # Replace all URls with &#39;URL&#39;<br>            tweet = re.sub(urlPattern, &#39; URL&#39;, tweet)<br>            # Replace all emojis.<br>            for emoji in self.emojis.keys():<br>                tweet = tweet.replace(emoji, &quot;EMOJI&quot; + self.emojis[emoji])<br>                # Replace @USERNAME to &#39;USER&#39;.<br>            tweet = re.sub(userPattern, &#39; USER&#39;, tweet)<br>            # Replace all non alphabets.<br>            tweet = re.sub(alphaPattern, &quot; &quot;, tweet)<br>            # Replace 3 or more consecutive letters by 2 letter.<br>            tweet = re.sub(sequencePattern, seqReplacePattern, tweet)<br>            tweetwords = &#39;&#39;<br>            for word in tweet.split():<br>                # Checking if the word is a stopword.<br>                # if word not in stopwordlist:<br>                if len(word) &gt; 1:<br>                    # Lemmatizing the word.<br>                    word = wordLemm.lemmatize(word)<br>                    tweetwords += (word + &#39; &#39;)<br><br>            processedText.append(tweetwords)<br>        return processedText<br><br>    def load_models(self):<br>        &#39;&#39;&#39;<br>        Replace &#39;..path/&#39; by the path of the saved models.<br>        &#39;&#39;&#39;<br>        # Load the vectoriser.<br>        file = open(os.path.join(self.sklearn_folder,&#39;vectoriser-ngram-(1,2).pickle&#39;), &#39;rb&#39;)<br>        vectoriser = pickle.load(file)<br>        file.close()<br>        # Load the LR Model.<br>        file = open(os.path.join(self.sklearn_folder,&#39;Sentiment-LR.pickle&#39;), &#39;rb&#39;)<br>        LRmodel = pickle.load(file)<br>        file.close()<br>        return vectoriser, LRmodel<br><br>    def predict(self,  X, features_names=None):<br>        if self.model_loaded== False:<br>            print(&quot;LOADING MODEL&quot;)<br>            self.vectorizer, self.model = self.load_models()<br>            self.model_loaded=True<br>        # Predict the sentiment<br>        log.info(&quot;X:&quot;, X)<br>        textdata = self.vectorizer.transform(self.preprocess(X))<br>        log.info(&quot;Transformed Data&quot;)<br>        sentiment = self.model.predict(textdata)<br>        # Make a list of text with sentiment.<br>        log.info(&quot;Got Predictions&quot;)<br>        data = {}<br>        emotion_dict= {0: &quot;Sad&quot;, 1: &quot;Happy&quot;}<br>        for text, pred in zip(X, sentiment):<br>            data[text]= emotion_dict[pred]<br>        log.info(&quot;Sending Predictions back!!&quot;)<br>        return data<br><br></pre><ul><li><strong>Containerize the Wrapper</strong>: Bundle the custom wrapper code into a Docker container. The Dockerfile specifies the base image, installs necessary dependencies, and transfers your wrapper code into the container.<br>In our case the Dockerfile looked like this:</li></ul><pre>FROM python:3.8-slim<br>WORKDIR /app<br>COPY . .<br>RUN pip install -r requirements.txt<br>RUN [ &quot;python3&quot;, &quot;-c&quot;, &quot;import nltk; nltk.download(&#39;stopwords&#39;, download_dir=&#39;/usr/local/nltk_data&#39;)&quot;]<br>RUN [ &quot;python3&quot;, &quot;-c&quot;, &quot;import nltk; nltk.download(&#39;wordnet&#39;, download_dir=&#39;/usr/local/nltk_data&#39;)&quot;]<br>ENV MODEL_NAME=Inference<br>ENV API_TYPE=REST<br>ENV SERVICE_TYPE=MODEL<br>ENV PERSISTENCE=0<br>EXPOSE 5000<br>EXPOSE 9000<br>RUN chown -R 8888 /app<br>CMD exec seldon-core-microservice $MODEL_NAME  --service-type $SERVICE_TYPE</pre><ul><li><strong>Build and Push Docker Image</strong>: Construct the Docker image using the Dockerfile, followed by pushing it to a container registry. Replace “your-image-tag” with a fitting tag for the image.<br>In our case since I am working on Mac M1 which uses an arm-based processor and the kubernetes node are having amd-64 type of processor so I supplied an additional flag “- -platform” while creating the docker image.</li></ul><pre>docker build -t racahu23/b_inference:final --platform linux/amd64 .<br>docker push racahu23/b_inference:final</pre><ul><li><strong>Create Seldon Deployment Configuration</strong>: Compose a Seldon deployment configuration YAML file, referencing the custom wrapper image. This configuration also designates the model you intend to wrap, accompanied by other essential settings.<br>In our case the deployment yaml looked like:</li></ul><pre>apiVersion: machinelearning.seldon.io/v1<br>kind: SeldonDeployment<br>metadata:<br>  name: blogpost-model<br>  namespace: seldon<br>spec:<br>  predictors:<br>  - componentSpecs:<br>    - spec:<br>        containers:<br>        - name: transformer<br>          image: racahu23/b_inference:final<br>    graph:<br>      name: transformer<br>      type: MODEL<br>      endpoint:<br>        service_port: 5000<br>    name: model<br>    replicas: 1</pre><ul><li><strong>Apply the Configuration</strong>: Apply the Seldon deployment configuration to your Kubernetes cluster using kubectl apply.</li></ul><pre>kubectl apply -f deployment.yaml</pre><p>This would create a Seldon deployment in our “seldon” namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNbvRv5OW19C53NudRA-7w.png" /><figcaption>All resources in seldon namespace</figcaption></figure><ul><li><strong>Accessing API Docs for Deployed Model</strong>: Upon reaching the “ready” state of the Seldon Deployment, the model’s API documentation can be accessed via a specific URL format, providing valuable insights into the model’s capabilities.<br>Once the Seldon Deployment is in “ready” state the api documentation related to the deployed model can be found on following url:<br>http://&lt;ingress_url&gt;/seldon/&lt;namespace&gt;/&lt;model-name&gt;/api/v1.0/doc/<br>In our case the api documentation was available at following url: <a href="http://20.73.143.214/seldon/seldon/blogpost-model/api/v1.0/doc/">http://20.73.143.214/seldon/seldon/blogpost-model/api/v1.0/doc/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZ_auC85FZ9hcp_1Znf40w.png" /><figcaption>API docs for Seldon Model</figcaption></figure><ul><li><strong>Model Testing</strong>: To finalize the process, assess the deployed model’s performance by submitting data for prediction using Python’s requests module. The results will validate the model&#39;s efficacy.<br>The test script in this case would look like:</li></ul><pre>import numpy as np<br>import json<br>import requests<br><br><br>from seldon_core.seldon_client import SeldonClient<br><br>headers = {&quot;Content-Type&quot;: &quot;application/json&quot;}<br><br>text = [&quot;I hate twitter&quot;,<br>        &quot;May the Force be with you.&quot;,<br>        &quot;Mr. Stark, I don&#39;t feel so good&quot;,<br>        ]<br><br>data = json.dumps({&quot;data&quot;: { &quot;ndarray&quot;: text}})<br>response= requests.post(&#39;http://20.73.143.214:80/seldon/seldon/blogpost-model/api/v1.0/predictions&#39;, data= data, headers=headers)<br>print(response.json()[&#39;jsonData&#39;])</pre><p>Once this script is ran the results should look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ls0tPNHd6t56ZZ-LBK6Hkw.png" /><figcaption>Prediction results from Seldon Model</figcaption></figure><p>By implementing these stages, we successfully establish an integrated MLOps pipeline for Sentiment Analysis on Azure, employing Terraform, Kubeflow v2, MLFlow, and Seldon. This implementation underscores the synergy between diverse technologies and methodologies, facilitating robust and efficient machine learning operations. Should you require further clarification or seek collaboration opportunities, please don’t hesitate to reach out. Until then, let’s continue our journey of exploration and knowledge sharing in the realm of emerging technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c0d18e3d286" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286">End-to-End MLOps Pipelines for Sentiment Analysis on Azure using Terraform, Kubeflow v2, MlFlow and…</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…]]></title>
            <link>https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f14ae5267d11</guid>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 14:11:39 GMT</pubDate>
            <atom:updated>2023-09-01T06:21:40.500Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2, Mlflow, and Seldon: Part 4</h3><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1"><strong>Part 1: Introduction and Architecture planning</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f"><strong>Part 2: Developing workflows for infrastructure deployment via CI-CD</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258"><strong>Part 3: Setting up MLflow on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11"><strong>Part 4: Setting up Kubeflow and Seldon on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286"><strong>Part 5: End-to-End Training Pipeline and Inference Deployment using Seldon.</strong></a></p><p>In Part 4 of our series, our objective is to install Kubeflow and Seldon resources within the AKS cluster that was provisioned in Part 2. To achieve this, we will leverage kustomize, a Kubernetes native configuration management tool, to seamlessly install Kubeflow onto our AKS cluster.</p><h4><strong>Kubeflow Installation</strong></h4><p>Kubeflow is an open-source platform for machine learning (ML) workflow orchestration on Kubernetes. It provides a range of tools for data scientists and ML engineers to manage, deploy, and monitor ML workflows in a scalable and efficient manner. In this blog post, we will walk through the steps to install Kubeflow on Azure Kubernetes Service (AKS).</p><p>Prerequisites:</p><ul><li>Kubernetes Cluster (Created in Part 2)</li><li>Kustomize (5.0.0)</li><li>kubectl</li></ul><p>To initiate the installation of Kubeflow, the first step is to clone the repository at <a href="https://github.com/kubeflow/manifests">https://github.com/kubeflow/manifests</a>. This repository contains Kubeflow manifest files that adhere to the best practices for installing Kubeflow on various Kubernetes engines, not limited to AKS. Once the repository is cloned, we can proceed with the installation of Multi-User Kubeflow Pipelines.</p><p>Kubeflow pipelines offer multi-user isolation as part of their multi-tenancy capabilities. Resources within Kubeflow Pipelines are isolated using Kubernetes namespaces, which are managed by Kubeflow’s profile resource. This ensures that each user operates within their designated namespace, preventing unauthorised access to resources. The Kubeflow Pipelines API server enforces permissions, rejecting requests to namespaces for which the current user lacks appropriate authorization.</p><p>Experiments are associated directly with namespaces, while runs and iterations are organised within the parent experiment’s namespace. Additionally, the execution of pipelines occurs within a user namespace, providing the user with the advantages of Kubernetes namespace isolation. This allows for customised configurations, such as assigning different secrets to various services within different namespaces.</p><p>Once the repository is cloned, we can follow the subsequent steps outlined below to install Kubeflow within our AKS cluster:</p><p><strong>Step 1 :</strong> Get Kubeconfig of the AKS cluster: In order to get kubeconfig of the cluster we will run the following command:</p><p><strong>Step 1 :</strong> Get Kubeconfig of the AKS cluster: In order to get kubeconfig of the cluster we will run the following command:</p><pre>az aks get-credentials --resource-group blogpost-terraform --name terraform-aks</pre><p><strong>Step 2:</strong> Clone the git repository where kustomization manifests are kept:</p><pre>git clone https://github.com/kubeflow/manifests</pre><p><strong>Step 3:</strong> Install certification manager (cert-manager). Cert-manager is utilized by numerous components of Kubeflow to furnish certificates for admission webhooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RYS9k2LdS8pJ966yUyxUEQ.png" /><figcaption>Kustomize command to install Certificate Manager</figcaption></figure><p><strong>Step 4:</strong> Install <a href="https://istio.io/">Istio Services</a>. Several Kubeflow components leverage Istio to ensure the security of their traffic, enforce network authorization, and implement routing policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28Vq2vMs5nIDLqOg3d8DIQ.png" /><figcaption>Installation of Istio Services</figcaption></figure><p><strong>Step 5:</strong> Install OpenID Connect Identity (OIDC). For this implementation we will install an OIDC client called <a href="https://dexidp.io/">Dex</a>. Dex is an OIDC that supports multiple authentication backends. In its default setup, it comes with a static user account having the email “<a href="/service/mailto:user@example.com">user@example.com</a>,” and a default password “12341234”. However, for any Kubeflow deployment meant for production purposes, it is crucial to change the default password by referring to the relevant section. So for this implementation we will first alter the default account and then apply the manifest. In order to change the default email and password run the following command:</p><ul><li><strong>Step 5a:</strong> Run: vi common/dex/base/config-map.yaml. This config-map contains the default email id and password.</li><li><strong>Step 5b:</strong> In order to change the password we need to hash our password using <a href="https://bcrypt.online/">bcrypt</a>. In order to encrypt your password run the following command:</li></ul><pre>python3 -c &#39;from passlib.hash import bcrypt; import getpass; print(bcrypt.using(rounds=12, ident=&quot;2y&quot;).hash(&lt;PASSWORD&gt;))&#39;</pre><p>The above command will generate the hashed password which will be supplied to our OIDC client in order to authenticate user login.</p><ul><li><strong>Step 5c: </strong>Now we will make changes in the config-map.yaml.</li></ul><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: dex<br>data:<br>  config.yaml: |<br>    issuer: http://dex.auth.svc.cluster.local:5556/dex<br>    storage:<br>      type: kubernetes<br>      config:<br>        inCluster: true<br>    web:<br>      http: 0.0.0.0:5556<br>    logger:<br>      level: &quot;debug&quot;<br>      format: text<br>    oauth2:<br>      skipApprovalScreen: true<br>    enablePasswordDB: true<br>    staticPasswords:<br>    - email: ahuja.rachit@hotmail.com<br>      hash: $2y$12$WT7HTjhudIwMRI0MN.Ejuuuq.moyD4.05/a1.pFalsj2yET/C5n0K<br>      # https://github.com/dexidp/dex/pull/1601/commits<br>      # FIXME: Use hashFromEnv instead<br>      username: user<br>      userID: &quot;15841185641784&quot;<br>    staticClients:<br>    # https://github.com/dexidp/dex/pull/1664<br>    - idEnv: OIDC_CLIENT_ID<br>      redirectURIs: [&quot;/authservice/oidc/callback&quot;]<br>      name: &#39;Dex Login Application&#39;<br>      secretEnv: OIDC_CLIENT_SECRET</pre><p>Now once we apply the manifest instead of the default email id and password i.e. “<a href="/service/mailto:user@example.com">user@example.com</a>” and “12341234” we will have our custom login credentials.</p><ul><li><strong>Step 5d:</strong> Install Dex inside our AKS cluster.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MJxpjzrc87I5aA4mjcqMwQ.png" /><figcaption>Applying Manifest for installing Dex</figcaption></figure><ul><li><strong>Step 5e:</strong> Install OIDC AuthService. The AuthService for OIDC expands the capabilities of your Istio Ingress-Gateway, allowing it to operate as an OIDC client.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L08gCn3avuyw9DF6kJmYUQ.png" /></figure><p>This applies the OIDC configuration with the email id as “ahuja.rachit@hotmail.com” and our custom password.</p><p><strong>Step 6:</strong> Install Knative which is used by the kubeflow components. Knative is a Kubernetes container orchestration platform extension that facilitates the operation of serverless workloads on Kubernetes clusters. It offers utilities and tools that simplify the process of building, deploying, and managing containerised applications within Kubernetes, making it a more seamless and native experience. In order to install Knative run the following commands:</p><pre>kustomize build common/knative/knative-serving/overlays/gateways | kubectl apply -f -<br>kustomize build common/istio-1-16/cluster-local-gateway/base | kubectl apply -f -</pre><p><strong>Step 7:</strong> Create Kubeflow namespace. This is where all the kubeflow components will live. In order to create the namespace run the following command:</p><pre>kustomize build common/kubeflow-namespace/base | kubectl apply -f -</pre><p><strong>Step 8:</strong> Create kubeflow cluster roles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jj6nS_Jyh5Qhv2O44aB7kw.png" /><figcaption>Creation of Cluster roles for Kubeflow</figcaption></figure><p><strong>Step 9:</strong> Generate the necessary Istio resources for Kubeflow. The current kustomization produces an Istio Gateway, referred to as kubeflow-gateway, within the kubeflow namespace. If you intend to use your own Istio, you must also include this kustomization. In order to install the Istio resources run the following command:</p><pre>kustomize build common/istio-1-16/kubeflow-istio-resources/base | kubectl apply -f -</pre><p><strong>Step 10:</strong> Install Kubeflow Pipelines. For this particular demo we will be installing <a href="https://www.kubeflow.org/docs/components/pipelines/v1/overview/multi-user/">Multi-user Kubeflow pipelines</a>. Initially the manifest first installs Argo using the secure emissary executor, run as non-root. However, it is essential to note that the installer must still evaluate the security implications that may arise when containers are run with root access. Consequently, it is highly recommended that the main containers for Kubeflow pipelines be deployed and executed as runasnonroot, without any special capabilities, to reduce security risks. We can apply</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6tGodDhJorZES6FHSsXEQg.png" /><figcaption>Multi-user Installation for Kubeflow pipeline</figcaption></figure><p><strong>Step 11:</strong> Finally we will create the <strong>user namespace</strong>. This is the most important part of the implementation. The most important thing was to separate resources at user level so that each user can create personalised experiments sharing the common resources still separating out the environment itself. Users who lack authorization cannot access resources in your Profile/Namespace. This is because the Kubeflow Pipelines API server declines requests for namespaces that the current user is not authorized to access.</p><p>By default the manifest creates user with name “kubeflow-user-example-com” but we will change the kustomize patch to create an actual user namespace. In order to change the default user following are the steps:</p><ul><li>Step 11a: Change manifests/common/user-namespace/base/params.env file and update the username.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtCDlSI5oJRrUmtRFGH_rA.png" /></figure><ul><li>Step 11b: Apply the manifest using the following command:</li></ul><pre>kustomize build common/user-namespace/base | kubectl apply -f -</pre><p>This will create the user specific namespace.</p><p>Now, with this we have successfully installed Kubeflow in your AKS cluster. To access Kubeflow, the recommended method is through port-forwarding, which allows for quick setup without any specific environment prerequisites. You can execute the following command to port-forward Istio’s Ingress-Gateway to local port 8080:</p><pre>kubectl port-forward svc/istio-ingressgateway -n istio-system 8080:80</pre><p>Upon executing the command, the Kubeflow Central Dashboard can be accessed by following these steps:</p><ol><li>Open your web browser and go to <a href="http://localhost:8080/">http://localhost:8080</a>. This should direct you to the Dex login page.</li><li>Use the user’s credentials to log in, which consist of a default email address and password.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCmn1FxCn1cFbC-M07JXvA.png" /><figcaption>Dex Log In page for Kubeflow Dashboard</figcaption></figure><p>Once you enter the login credentials user-specific dashboard should be visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7u5lC0slPC3E7rqk0mgFg.png" /><figcaption>User-Specific Kubeflow Dashboard</figcaption></figure><h4>Seldon Installation</h4><p>Now, Seldon core is by default installed with the Kubeflow installation we just did. For a detailed overview of Seldon installation you can refer <a href="https://www.kubeflow.org/docs/external-add-ons/serving/seldon/">here</a>. In order to test Seldon deployment we need to perform following steps:</p><ul><li>Step 1: Create namespace Seldon and label it for inference.</li></ul><pre>kubectl create ns Seldon<br>kubectl label namespace seldon serving.kubeflow.org/inferenceservice=enabled</pre><ul><li>Step 2: Create a Seldon Deployment with a dummy model using the deployment manifest shown beflow:</li></ul><pre>cat &lt;&lt;EOF | kubectl create -n seldon -f -<br>apiVersion: machinelearning.seldon.io/v1<br>kind: SeldonDeployment<br>metadata:<br>  name: seldon-model-example-0-classifier<br>  namespace: seldon<br>spec:<br>  name: seldon-model-example-0-classifier<br>  predictors:<br>  - componentSpecs:<br>    - spec:<br>        containers:<br>        - image: seldonio/mock_classifier_rest:1.3<br>          name: classifier<br>    graph:<br>      children: []<br>      endpoint:<br>        type: REST<br>      name: classifier<br>      type: MODEL<br>    name: example<br>    replicas: 1<br>EOF</pre><p>Now this should create the deployment name seldon-model in namespace seldon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSw_tgSVnzUiURtbPiOiDQ.png" /><figcaption>Seldon Resources for Dummy model</figcaption></figure><p>Now in order to test our dummy deployment we will port-forward the service to a local-port and curl the results. To port foward the model service run the following:</p><pre>kubectl port-forward svc/seldon-model-example -n seldon 8000:8000 </pre><p>And, to test the model run the following command:</p><pre>curl -s -d &#39;{&quot;data&quot;: {&quot;ndarray&quot;:[[1.0, 2.0, 5.0]]}}&#39; -X POST http://localhost:8000/seldon/seldon/seldon-model/api/v1.0/predictions    -H &quot;Content-Type: application/json&quot;</pre><p>You should expect the following result: <em>{“data”:{“names”:[“proba”],”ndarray”:[[0.43782349911420193]]},”meta”:{}}.</em></p><p>We have configured Kubeflow and Seldon inside our AKS cluster. The only thing left is actually start training the ML model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f14ae5267d11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11">Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…]]></title>
            <link>https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfacb7af4258</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[mlflow]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 20:45:06 GMT</pubDate>
            <atom:updated>2023-09-01T06:22:10.693Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2, Mlflow, and Seldon: Part 3</h3><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1"><strong>Part 1: Introduction and Architecture Planning</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f"><strong>Part 2: Developing Workflows for Infrastructure Deployment via CI/CD</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258"><strong>Part 3: Setting up MLflow on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11"><strong>Part 4: Setting up Kubeflow and Seldon on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286"><strong>Part 5: End-to-End Training Pipeline and Inference Deployment using Seldon.</strong></a></p><p>In Part 3 we are going to going to install Mlflow and it’s dependent resources inside our AKS cluster that we provisioned in Part 2. In order to deploy MLflow we need to deploy a Database as a prerequisite so for this implementation we will deploy Postgres in our AKS cluster and then use it as our default backend storage solution. All the manifests used here are available on: <a href="https://github.com/rahuja23/MLFlow_Deployment">https://github.com/rahuja23/MLFlow_Deployment</a>.</p><h3><strong>Deploying PostgresSQL on Kubernetes</strong></h3><p>In order to deploy PostgreSQL inside our Kubernetes cluster following steps needs to be followed sequentially:</p><h3><strong>Creation of Namespace</strong></h3><p>In order to manage and maintain all our resources related to PostgreSQL we create a namespace and we will provision all our resources inside this namespace. In order to create the namespace we need to run:</p><pre>kubectl create ns postgres</pre><h3><strong>Creation of Persistence Volume and Persistence Volume Claim</strong></h3><p>Since Kubernetes basics are not in the scope of this article, I would highly suggest readers to read the <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/">official documentation of Kubernetes</a> in order to understand what Persistence Volume (PV) and Persistence Volume Claims (PVC) are. In order to deploy stateful applications such as PostgreSQL database we’ll have to create a PVC to store the database data. In this implementation we will create a pod that mounts this PVC and runs MySQL database.</p><p>For this tutorial, we will move forward with a local volume using ‘mnt/datavol’ as the path to the volume:</p><pre>cat &lt;&lt;EOF &gt; postgres-pv.yaml<br><br>kind: PersistentVolume<br>apiVersion: v1<br>metadata:<br>  name: postgres-pv-volume  # Sets PV&#39;s name<br>  labels:<br>    type: local  # Sets PV&#39;s type to local<br>    app: postgres<br>spec:<br>  storageClassName: manual<br>  capacity:<br>    storage: 5Gi # Sets PV Volume<br>  accessModes:<br>    - ReadWriteMany<br>  hostPath:<br>    path: &quot;/mnt/datavol&quot;<br>EOF<br><br>cat &lt;&lt;EOF &gt; postgres-pvc.yaml<br>kind: PersistentVolumeClaim<br>apiVersion: v1<br>metadata:<br>  name: postgres-pv-claim  # Sets name of PVC<br>  labels:<br>    app: postgres<br>spec:<br>  storageClassName: manual<br>  accessModes:<br>    - ReadWriteMany  # Sets read and write access<br>  resources:<br>    requests:<br>      storage: 5Gi  # Sets volume size<br>EOF<br><br># Applying the manifests for the PV <br>kubectl create -f postgres-pv.yaml<br># Applying the manifests for the PVC<br>kubectl create -f postgres-pvc.yaml</pre><p>Now this should create our Persistent Volume and it’s corresponding Persistence Volume Claim. In order to check this we can run the following commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6cXxyzH3fYgOUTkGfYuSw.png" /><figcaption>Persistence Volume and Persistence Volume Claim</figcaption></figure><h3><strong>Create and apply ConfigMap</strong></h3><p>Configmaps are used in order to prevent secrets like: credentials etc of inside our application code from exposing inside the source code. It alo helps the developers from separating data from code. With the help of Configmaps one can easily deploy and update the data used by the application without actually changing the source code.</p><p>A configmap can be easily created by copy pasting the following code snippet:</p><pre>cat &lt;&lt;EOF &gt; postgres-config.yaml<br><br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: postgres-config<br>  labels:<br>    app: postgres<br>  namespace: postgres<br>data:<br>  POSTGRES_DB: postgresdb<br>  POSTGRES_USER: **USERNAME**<br>  POSTGRES_PASSWORD: **PASSWORD**<br><br>EOF<br><br># Applying the manifests<br>kubectl create -f postgres-config.yaml</pre><p>Now we can check whether the Configmap has been created or not:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sa7c1HyRhfvHXQ59CCMhJw.png" /><figcaption>Configmap used by PostgreSQL</figcaption></figure><h3><strong>Create and apply PostgreSQL as a Deployment</strong></h3><p>Deployments in Kubernetes is a declarative way in which one can define how an application should be deployed or updated inside the cluster. They are a way to manage the roll out and update process of an application inside a Kubernetes cluster.</p><pre>cat &lt;&lt;EOF &gt; postgres-dep.yaml<br><br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: postgres  # Sets Deployment name<br>  namespace: postgres<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: postgres<br>  template:<br>    metadata:<br>      labels:<br>        app: postgres<br>    spec:<br>      containers:<br>        - name: postgres<br>          image: postgres:10.1 <br>          imagePullPolicy: &quot;IfNotPresent&quot;<br>          ports:<br>            - containerPort: 5432  <br>          envFrom:<br>            - configMapRef:<br>                name: postgres-config<br>          volumeMounts:<br>            - mountPath: /var/lib/postgresql/data<br>              name: postgredb<br>      volumes:<br>        - name: postgredb<br>          persistentVolumeClaim:<br>            claimName: postgres-pv-claim<br><br>EOF<br><br># Apply the manifest<br>kubectl create -f postgres-dep.yaml</pre><p>We can check the creation of deployment and pods using the following commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZEc0Ecw30is1Ga21WyCgQ.png" /><figcaption>Pods and Deployment of PostgreSQL</figcaption></figure><p>Exposing PostgreSQL Deployment as a Service</p><p>Kubernetes Services helps developers exposing their applications in numerous ways. The default method of doing this is using “ClusterIP” service offered by Kubernetes. Cluster IP as the name suggests exposes the service to an address that can only we used inside the cluster itself.</p><p>The deployment can be exposed as a service using the following command:</p><pre> kubectl expose deployment postgres --type=ClusterIP --name=postgres-service -n postgres</pre><p>This command exposes our PostgreSQL deployment as a ClusterIP service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCBnsz5zeOUmywtRFkOsHw.png" /><figcaption>PostgreSQL deployment exposed as a ClusterIP Service</figcaption></figure><h3><strong>MLFlow Setup</strong></h3><p>Now that we have our remote storage backend deployed in our Kubernetes cluster we will now go setup Mlflow inside our cluster.</p><p>In order to deploy MLflow in our cluster first we will create a minimalist Dockerfile in order to create an image of Mlflow.</p><pre>cat &lt;&lt;EOF &gt; Dockerfile<br>From ubuntu:20.04<br>RUN  apt-get update  &amp;&amp; apt install python3-pip libpq-dev -y<br>WORKDIR /home<br>COPY . .<br>RUN pip3 install -r requirements.txt<br>ENV MLFLOW_SERVER_PORT 5000<br>EXPOSE $MLFLOW_SERVER_PORT<br>ENTRYPOINT [&quot;sh&quot;, &quot;/home/setup_mlflow.sh&quot;]<br>EOF</pre><p>This Dockerfile has a bash file defined as it’s entrypoint which runs our MLFlow server. The next step is to create the bash file which is responsible for execution of our MLFlow server.</p><pre>#!/bin/bash<br>BACKEND_STORE_URI=&quot;mysql://$MLFLOW_DB_USER:$MLFLOW_DB_PASSWORD@$MLFLOW_DB_HOST:$MLFLOW_DB_PORT/$MLFLOW_DB_NAME&quot;<br>mlflow server \<br>    --backend-store-uri &quot;$BACKEND_STORE_URI&quot; \<br>    --default-artifact-root &quot;$MLFLOW_SERVER_DEFAULT_ARTIFACT_ROOT&quot; \<br>    --host &quot;$MLFLOW_SERVER_HOST&quot; \<br>    --port &quot;$MLFLOW_SERVER_PORT&quot; \<br>    --workers &quot;$MLFLOW_SERVER_WORKERS&quot;</pre><p>Now the image based on the dockerfile defined above will run a MLflow server but requires a few arguments to be passed as environment variables. Following arguments are required:</p><ul><li>- -backed-store-uri: This will be our database that will be used to store and log metrics.</li><li>- -default-artifact-rool: This is basically the object storage solution where all the artiacts logged by Mlflow will be stored. In our case we will be using Azure Blog in order to store the metrics. There are a few ways in which we can define how to reach the blob where the artifacts needs to be stored but for this implementation we will be using HTTP method: <a href="https://storageaccount.blob.core.windows.net/container/path/to/blob">https://storageaccount.blob.core.windows.net/container/path/to/blob</a></li></ul><p>The image is available on dockerhub as racahu23/mlflow_base:1.</p><p>Now again as we did for our PostgreSQL we will provision a namespace where we will deploy all the resources provisioned for MLFlow.</p><p>The namespace can be created by running the following command:</p><pre>kubectl create ns mlflow</pre><p>Now, we can deploy Mlflow server as a deployment in this namespace. As per the default configuration the server listens on port 5000.</p><p>Now we create a configmap where we define all the environment variables which are required for the mlflow server. The manifest will look as follows:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: mlflow<br>  namespace: mlflow<br>data:<br>  MLFLOW_DB_HOST: http://postgres-service.postgres.svc.cluster.local<br>  MLFLOW_DB_USER: admin<br>  MLFLOW_DB_PORT: &quot;5432&quot;<br>  MLFLOW_DB_NAME: postgresdb<br>  MLFLOW_ARTIFACT_URI: &quot;https://storageaccount.blob.core.windows.net/container/path/to/blob&quot;<br><br>kubectl create -f configmap.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VenGPjCbHAcS6R0i4LyLAg.png" /><figcaption>Configmap containing Env variables for Mlflow Server</figcaption></figure><p>In kubernetes one of the most prevalent way to supply passwords or sensitive information used by your deployments is using <a href="https://kubernetes.io/docs/concepts/configuration/secret/">Secrets</a>. For this implementation the our mlflow deployment requires password for the PostgreSQL deployment which we just created. In order create secret run the following command:</p><pre>kubectl create secret generic mlflow-db-cred -n mlflow --from-literal=db_password=&lt;PASSWORD&gt;</pre><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: mlflow<br>  namespace: mlflow<br>  labels:<br>    app: mlflow<br><br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: mlflow<br>  template:<br>    metadata:<br>      labels:<br>        app: mlflow<br>    spec:<br>      containers:<br>        - name: mlflow<br>          image: racahu23/mlflow_base:1<br>          imagePullPolicy: Always<br>          ports:<br>            - containerPort: 5000<br>          envFrom:<br>            - configMapRef:<br>                name: mlflow<br>          env:<br>            - name: MLFLOW_DB_PASSWORD<br>              valueFrom:<br>                secretKeyRef:<br>                  name: mlflow-db-credent<br>                  key: db_password<br>                  optional: false</pre><p>In the above deployment in order to define the path of our default “BACKEND_STORAGE” we resolved the DNS of the PostgreSQL service that we exposed above. Once the deployment is created the server will start on some node of our AKS cluster. In order to access this server the simplest way is to create a service and port-forward it locally to some port and access it. But in case of production environment we would want the MLflow server to be accessible from outside itself, since we would not like to give access to our kubernetes cluster. So in order to access the Mlflow server from outside we will create a <strong>service</strong> and <strong>ingress rule</strong>.</p><p>The service can be provisioned using the following script:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: mlflow<br>  labels:<br>    app: mlflow<br>  namespace: mlflow <br>spec:<br>  selector:<br>    app: mlflow<br>  type: ClusterIP<br>  ports:<br>    - port: 5000<br>      targetPort: 5000</pre><p>The above yaml will create the default “ClusterIP” service of our deployment. To create an ingress rule, we first create an ingress controller which we will install using helm (more details <a href="https://docs.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-powershell">here</a>).</p><pre>export Namespace=&#39;ingress-resources&#39;<br>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx<br>helm repo update<br>helm install ingress-nginx ingress-nginx/ingress-nginx --create-namespace --namespace $Namespace --set controller.service.annotations.&quot;service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path&quot;=/healthz</pre><p>Once the ingress controller is installed, we can have a look at the LoadBalancer which will be provisioned with a public IP to access our MLflow server. In order to get the service following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFZbBq_Sge4ToFOZtP67Ew.png" /><figcaption>LoadBalancer exposing MLFlow server to a Public IP Address</figcaption></figure><p>As it’s shown in the above image helm installed all our ingress resources inside the ingress-resources namespace. It provisioned a LoadBalancer with a Public IP address which can be accessible from anywhere. Only ports 80 and 443 are exposed by Nginx ingress by default. Now, in order to point this public IP to expose Mlflow server we need to create ingress rule for the service of MLflow. The ingress rule is defined as follows:</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: mlflow-server-ingress<br>  annotations:<br>    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;<br>    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;<br>    nginx.ingress.kubernetes.io/rewrite-target: /$2<br>spec:<br>  ingressClassName: nginx<br>  rules:<br>    - http:<br>        paths:<br>          - path: /mlflow(/|$)(.*)<br>            pathType: Prefix<br>            backend:<br>              service:<br>                name: mlflow<br>                port:<br>                  number: 5000</pre><p>Once the above manifest is applied, the Mlflow server would be publicly accessible. For this demo, Mlflow will be used to log metrics, parameters and model artifacts. The Mlflow server will be publicly accessible on: <a href="http://20.13.41.235/mlflow/">http://20.13.41.235/mlflow/.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1ye2DhA3bpD8x-T4iQ92A.png" /><figcaption>Mlflow Server</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfacb7af4258" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258">Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…]]></title>
            <link>https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b33cba0283f</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[mlops-platform]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Mon, 05 Jun 2023 16:01:04 GMT</pubDate>
            <atom:updated>2023-09-01T06:22:40.134Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2, Mlflow, and Seldon: Part 2</h3><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1"><strong>Part 1: Introduction and Architecture planning</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f"><strong>Part 2: Developing workflows for infrastructure deployment via CI-CD</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258"><strong>Part 3: Setup MLflow on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11"><strong>Part 4: Setup Kubeflow and Seldon on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286"><strong>Part 5: End-to-End training pipeline and Inference Deployment using Seldon</strong></a></p><p>This section of the blog post focuses on the process of creating infrastructure from scratch in a reusable manner. The objective is to establish a centralised code repository where code can be pushed, triggering an Azure pipeline that provisions the infrastructure based on the code changes. It is assumed that the user has already set up an account in the Azure portal and Azure DevOps, although assistance for setting up these accounts can be found at this link: <a href="https://learn.microsoft.com/en-us/azure/devops/get-started/?view=azure-devops">https://learn.microsoft.com/en-us/azure/devops/get-started/?view=azure-devops</a>.<br>The complete code for this implementation is available Github: <a href="https://github.com/rahuja23/Blog-Post-Infrastructure/tree/main">https://github.com/rahuja23/Blog-Post-Infrastructure/tree/main</a> .</p><h3>1. Infrastructure as Code (IaC)</h3><p>Infrastructure as code (IaC) is a rapidly emerging trend in the industry, gaining significant momentum. It entails managing and provisioning infrastructure using code rather than relying on manual processes. IaC represents a crucial practice within the DevOps realm and is commonly employed in conjunction with continuous delivery practices. Adopting IaC offers numerous advantages, including increased speed, enhanced reliability, and improved scalability. However, one of the primary reasons for implementing IaC in an industrial setting is to mitigate errors and discrepancies that may arise during the provisioning or re-provisioning of infrastructure. By leveraging IaC, organisations can minimize manual intervention, reduce the likelihood of human errors, and ensure consistent and standardised infrastructure deployments.</p><h4><strong>1.1 Azure DevOps Setup</strong></h4><p>In this section we will setup our Azure DevOps organisation and create a repository for our infrastructure code:</p><ul><li>First step is to setup an organisation in AzureDevOps (<a href="https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/organization-management?view=azure-devops">here</a>). In our case we will call it <strong>“ Blog-Post”.</strong></li><li>Second step is to create a project inside this organisation. In our case we will call the project <strong>“Blog-Post-Infra”</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1sfchsdVGTg-qeHUUq96eA.png" /></figure><ul><li>Now we will have to connect our Azure DevOps account with the account we have in Azure Portal. This is done by linking the Active Directory created in our Azure Portal to Azure DevOps Organisation that we just created. We can do this by clicking on <strong>Organisation settings -&gt; Azure Active Directory-&gt; Connect directory</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwugi7rAKos3Pvs58LVo9g.jpeg" /></figure><ul><li>Now once we have connected everything we will create a repository where we will push our infrastructure code. We will name this repository <strong>“Infrastructure”.</strong> This will be the central repository for all our infrastructure we will provision.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwn0MAWJnuGnIi0bu3Ljrw.png" /></figure><p>Now we have an Azure DevOps organization with a project and a repository to contain our infrastructure code. Now what we need to setup is an authorized method for Azure DevOps to provision resources on Azure Portal. This is specifically needed because the code that provisions the infrastructure might be in a repository in Azure DevOps but the actual infrastructure won’t be provisioned on Azure DevOps itself. Since we don’t want to provision the infrastructure locally but we want to have Azure Pipelines create it for us, the best practice to do this is using<strong> </strong><a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&amp;tabs=yaml"><strong>Azure Service Connections</strong></a>. To setup service connections we would go to: <strong>Project Settings → Service connections → New service connection</strong>. For this implementation we named our service connection “<strong>terraform-basic-testing-azure-connection”</strong>. This is the service connection that our azure pipeline will use when using the terraform code in our repository to actually provision infrastructure on our behalf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S27x5fIantAd_Zwie2YPcg.png" /></figure><ul><li>The last step to complete our initial setup is to somehow manage to install terraform for our azure’s CI-CD pipelines to use. For this purpose we will install terraform as an <a href="https://learn.microsoft.com/en-us/azure/devops/extend/overview?view=azure-devops">Azure Extension</a>. To do this we go to: <strong>Organization Settings → Extensions → Browse marketplace</strong>.<strong> </strong>For this blog-post the extension we installed is by <strong>Microsoft DevLabs</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*slzsoofVG0_1FxMJuSSsoA.png" /></figure><p><strong>1.2 Infrastructure</strong></p><p>In this section we will start implementing the actual code for our infrastructure. To make the implementation as clean as possible we will initially create terraform modules for each infrastructure component that we want to provision and inside our environment directory we would have the environment specific terraform files where we will call these modules and specify the configuration with which we want our infrastructure to be provisioned. The final structure of our directory will look as follows:</p><pre>Infrastructure/<br>├─ .pipelines/<br>│  ├─ azure-pipeline.yml<br>├─ Base_Infra/<br>│  ├─ az-remote-backend-main.tf<br>│  ├─ az-remote-backend-output.tf<br>│  ├─ az-remote-backend-variables.tf<br>├─ Dev/<br>│  ├─ backend.tf<br>│  ├─ main.tf<br>│  ├─ outputs.tf<br>│  ├─ providers.tf<br>│  ├─ terraform.tfvars<br>│  ├─ variables.tf<br>Infrastructure_modules/<br>├─ kubernetes-cluster/<br>│  ├─ variables.tf<br>│  ├─ main.tf<br>├─ container-registry/<br>│  ├─ main.tf<br>│  ├─ variables.tf<br>├─ resource-group/<br>│  ├─ main.tf<br>│  ├─ variables.tf</pre><p>The sub-directories inside our main repository “Infrastructure” are as follow:</p><ul><li><strong>.pipelines</strong>: This directory will contain our azure pipeline which we will use to provision our infrastructure.</li><li><strong>Base_Infra: </strong>This directory contains the base infrastructure over which additional infrastructure would be provisioned. The terraform code inside will provision an Azure Resource group which will be used to link our whole infrastructure and a Storage account inside the resource group where we would save all our terraform state files. The provision of this base infrastructure can also be automated but in specifically our implementation we will provision base infra manually.</li><li><strong>Dev:</strong> This directory will contain the terraform files which would be provisioned via our Azure pipeline. This directory will contain environment specific configuration which would only apply for our dev environment. In future if we want to extend to multi-environment infrastructure (e.g staging) then we would have an additional directory “Staging” with terraform files containing configurations for this specific environment.</li><li><strong>Infrastructure_modules</strong>: This directory contains terraform files for infrastructure components as modules.</li></ul><p>We will start with the “Base_Infra” directory which contains the code for the base infrastructure i.e. a resource group and a storage to save our terraform state files. Again, for the purpose of this blogpost we have built the base infrastructure manually i.e. doing terraform init, terraform plan and terraform apply locally and not using CI-CD pipelines to do it.</p><pre>Base_Infra/az-remote-backend-main.tf</pre><pre>provider &quot;azurerm&quot; {<br>  features {}<br>}<br><br>terraform {<br>  required_providers {<br>    azurerm = {<br>      source = &quot;hashicorp/azurerm&quot;<br>      version = &quot;2.78.0&quot;<br>    }<br>  }<br>}<br># Generate a random storage name<br>resource &quot;random_string&quot; &quot;tf-name&quot; {<br>  length = 8<br>  upper = false<br>  number = true<br>  lower = true<br>  special = false<br>}<br># Create a Resource Group for the Terraform State File<br>resource &quot;azurerm_resource_group&quot; &quot;state-rg&quot; {<br>  name = &quot;${lower(var.company)}-tfstate-rg&quot;<br>  location = var.location<br><br>  lifecycle {<br>    prevent_destroy = false<br>  }<br>  tags = {<br>    environment = var.environment<br>  }<br>}<br># Create a Storage Account for the Terraform State File<br>resource &quot;azurerm_storage_account&quot; &quot;state-sta&quot; {<br>  depends_on = [azurerm_resource_group.state-rg]<br>  name = &quot;${lower(var.company)}tf${random_string.tf-name.result}&quot;<br>  resource_group_name = azurerm_resource_group.state-rg.name<br>  location = azurerm_resource_group.state-rg.location<br>  account_kind = &quot;StorageV2&quot;<br>  account_tier = &quot;Standard&quot;<br>  access_tier = &quot;Hot&quot;<br>  account_replication_type = &quot;ZRS&quot;<br>  enable_https_traffic_only = true<br><br>  lifecycle {<br>    prevent_destroy = true<br>  }<br>  tags = {<br>    environment = var.environment<br>  }<br>}<br># Create a Storage Container for the Core State File<br>resource &quot;azurerm_storage_container&quot; &quot;core-container&quot; {<br>  depends_on = [azurerm_storage_account.state-sta]<br>  name = &quot;core-tfstate&quot;<br>  storage_account_name = azurerm_storage_account.state-sta.name<br>}</pre><p>The variables used for this configuration can be stored in “variables.tf” file.</p><pre>Base_Infra/az-remote-backend-variables.tf<br>____________________________________________________________________</pre><pre># company<br>variable &quot;company&quot; {<br>  type = string<br>  default = &quot;blogpost&quot;<br>  description = &quot;This variable defines the name of the company&quot;<br>}<br># environment<br>variable &quot;environment&quot; {<br>  type = string<br>  default = &quot;dev&quot;<br>  description = &quot;This variable defines the environment to be built&quot;<br>}<br># azure region<br>variable &quot;location&quot; {<br>  type = string<br>  description = &quot;Azure region where resources will be created&quot;<br>  default = &quot;West Europe&quot;<br>}</pre><pre>Base_Infra/az-remote-backend-output.tf<br>____________________________________________________________________</pre><pre>output &quot;terraform_state_resource_group_name&quot; {<br>  value = azurerm_resource_group.state-rg.name<br>}<br>output &quot;terraform_state_storage_account&quot; {<br>  value = azurerm_storage_account.state-sta.name<br>}<br>output &quot;terraform_state_storage_container_core&quot; {<br>  value = azurerm_storage_container.core-container.name<br>}</pre><p>Now we will go through the infrastructure modules i.e. the sub-directories inside directory “Infrastructure modules” specifically with “kubernetes-cluster” subdirectory.</p><pre>Infrastructure_modules/kubernetes-cluster/main.tf<br>____________________________________________________________________</pre><pre>terraform {<br>  required_providers {<br>    azurerm = {<br>      source = &quot;hashicorp/azurerm&quot;<br>      version = &quot;2.78.0&quot;<br>    }<br>  }<br>}<br>resource &quot;azurerm_kubernetes_cluster&quot; &quot;aks&quot; {<br>  name                = var.cluster_name<br>  kubernetes_version  = var.kubernetes_version<br>  location            = var.location<br>  resource_group_name = var.resource_group_name<br>  dns_prefix          = var.cluster_name<br>  node_resource_group = var.node_resource_group<br><br>  default_node_pool {<br>    name                = &quot;system&quot;<br>    node_count          = var.system_node_count<br>    vm_size             = &quot;Standard_DS2_v2&quot;<br>    type                = &quot;VirtualMachineScaleSets&quot;<br>    availability_zones  = [1, 2, 3]<br>    enable_auto_scaling = false<br>  }<br><br>  identity {<br>    type = &quot;SystemAssigned&quot;<br>  }<br><br>  network_profile {<br>    load_balancer_sku = &quot;Standard&quot;<br>    network_plugin    = &quot;kubenet&quot; # azure (CNI)<br>  }<br><br>}<br>____________________________________________________________________</pre><pre>Infrastructure_modules/kubernetes-cluster/variables.tf<br>____________________________________________________________________<br>variable &quot;resource_group_name&quot; {<br>  type        = string<br>  description = &quot;RG name in Azure&quot;<br>}<br><br>variable &quot;location&quot; {<br>  type        = string<br>  description = &quot;Resources location in Azure&quot;<br>}<br><br>variable &quot;cluster_name&quot; {<br>  type        = string<br>  description = &quot;AKS name in Azure&quot;<br>}<br><br>variable &quot;kubernetes_version&quot; {<br>  type        = string<br>  description = &quot;Kubernetes version&quot;<br>}<br><br>variable &quot;system_node_count&quot; {<br>  type        = number<br>  description = &quot;Number of AKS worker nodes&quot;<br>}<br><br>variable &quot;node_resource_group&quot; {<br>  type        = string<br>  description = &quot;RG name for cluster resources in Azure&quot;<br>}<br>____________________________________________________________________</pre><pre>Infrastructure_modules/container-registry/main.tf<br>____________________________________________________________________</pre><pre>terraform {<br>  required_providers {<br>    azurerm = {<br>      source = &quot;hashicorp/azurerm&quot;<br>      version = &quot;2.78.0&quot;<br>    }<br>  }<br>}<br>resource &quot;azurerm_container_registry&quot; &quot;acr&quot; {<br>  name                = var.name<br>  resource_group_name = var.resource_group_name<br>  location            = var.location<br>  sku                 = &quot;Premium&quot;<br>  admin_enabled       = false<br>  georeplications = [<br>    {<br>      location                = &quot;westeurope&quot;<br>      zone_redundancy_enabled = true<br>      tags                    = {}<br>  }]<br>}<br>____________________________________________________________________</pre><pre>Infrastructure_modules/container-registry/variables.tf<br>____________________________________________________________________<br> variable &quot;resource_group_name&quot; {<br>  type        = string<br>  description = &quot;RG name in Azure&quot;<br>}<br><br>variable &quot;location&quot; {<br>  type        = string<br>  description = &quot;Resources location in Azure&quot;<br>}<br>variable &quot;name&quot; {<br>  type        = string<br>  description = &quot;Name for container registry&quot;<br>}</pre><p>Currently, we only require these two specific infrastructure modules. Moving forward, we will explore the environment-specific Terraform files, where we will invoke these modules to provision infrastructure tailored to our respective environments.</p><pre>Dev/backend.tf<br>____________________________________________________________________</pre><pre>terraform {<br>  // backend &quot;azurerm&quot; {<br>  //   resource_group_name  = &quot;tf_state&quot;<br>  //   storage_account_name = &quot;tfstate019&quot;<br>  //   container_name       = &quot;tfstate&quot;<br>  //   key                  = &quot;terraform.tfstate&quot;<br>  // }<br>}<br>____________________________________________________________________</pre><pre>Dev/main.tf<br>____________________________________________________________________<br>module &quot;azure_container_registry&quot; {<br>  source = &quot;../Infrastructure/container-registry&quot;<br>  resource_group_name = var.resource_group_name<br>  location = var.location<br>  name = var.registry_name<br>}<br><br><br>module &quot;azurerm_kubernetes_cluster&quot; {<br>  resource_group_name = var.resource_group_name<br>  location            = var.location<br>  cluster_name        = var.cluster_name<br>  kubernetes_version  = var.kubernetes_version<br>  system_node_count   = var.system_node_count<br>  node_resource_group = var.node_resource_group<br>  source              = &quot;../Infrastructure/kubernetes-cluster&quot;<br>}<br>____________________________________________________________________</pre><pre>Dev/providers.tf<br>____________________________________________________________________<br>provider &quot;azurerm&quot; {<br>  features {}<br>}<br><br>terraform {<br>  required_providers {<br>    azurerm = {<br>      source = &quot;hashicorp/azurerm&quot;<br>      version = &quot;2.78.0&quot;<br>    }<br>  }<br>  backend &quot;azurerm&quot; {<br>  }<br>}<br>____________________________________________________________________</pre><pre>Dev/vairables.tf<br>____________________________________________________________________</pre><pre>variable &quot;resource_group_name&quot; {<br>  type        = string<br>  description = &quot;RG name in Azure&quot;<br>}<br><br>variable &quot;location&quot; {<br>  type        = string<br>  description = &quot;Resources location in Azure&quot;<br>}<br><br>variable &quot;cluster_name&quot; {<br>  type        = string<br>  description = &quot;AKS name in Azure&quot;<br>}<br><br>variable &quot;kubernetes_version&quot; {<br>  type        = string<br>  description = &quot;Kubernetes version&quot;<br>}<br>variable &quot;registry_name&quot; {<br>  type        = string<br>  description = &quot;Name for our azure container registry&quot;<br>}<br><br>variable &quot;system_node_count&quot; {<br>  type        = number<br>  description = &quot;Number of AKS worker nodes&quot;<br>}<br><br>variable &quot;node_resource_group&quot; {<br>  type        = string<br>  description = &quot;RG name for cluster resources in Azure&quot;<br>}</pre><p>One notable aspect evident in the aforementioned Terraform files is the extensive utilization of variables to define configurations, such as the resource group names or the container registry names. In Terraform, there are two primary methods for providing or setting the values of these variables. The first approach involves storing all the values in a “.tfvars” file, which is then supplied during the execution of Terraform scripts. Alternatively, the values can be directly specified when invoking “terraform apply.”</p><p>In our specific case, we will generate a “.tfvars” file that will be accessed by our Azure pipelines when provisioning the infrastructure. This allows for seamless integration and automation of the provisioning process, as the necessary variable values can be conveniently supplied from the designated “.tfvars” file.</p><pre>Dev/terraform.tfvars<br>____________________________________________________________________<br>resource_group_name = &quot;blogpost-terraform&quot;<br>location            = &quot;West Europe&quot;<br>cluster_name        = &quot;terraform-aks&quot;<br>kubernetes_version  = &quot;1.24.3&quot;<br>system_node_count   = 3<br>node_resource_group = &quot;blogpost-tfstate-resources-rg&quot;<br>terraform_backend_storage= &quot;blogposttfhzf8zk75&quot;<br>terraform_backend_container = &quot;core-tfstate&quot;<br>registry_name = &quot;blogpost-tfstate-registry&quot;</pre><p>With the completion of our Terraform scripts for infrastructure provisioning, the subsequent step involves building an Azure pipeline. This pipeline will be responsible for retrieving and executing these scripts to effectively provision the desired infrastructure.</p><h3>2. Azure Pipelines to provision infrastructure</h3><p>In this section, our focus shifts towards creating an Azure pipeline that will actively retrieve the infrastructure scripts from the previous section. This pipeline will play a pivotal role in executing these scripts, resulting in the actual provisioning of the desired resources.</p><pre>.pipelines/azure-pipelines.yml<br>____________________________________________________________________<br>trigger:<br>  branches:<br>    include:<br>      - &#39;*&#39;</pre><pre>variables:<br>- group: BlogPost-Infra-vg<br>- name: terraformWorkingDirectory<br>  value: &#39;$(System.DefaultWorkingDirectory)/Dev&#39;<br>- name: backendAzureRmResourceGroupName<br>  value: &#39;blogpost-tfstate-rg&#39;<br>- name: backendAzureRmStorageAccountName<br>  value: &#39;blogposttfhzf8zk75&#39;<br>- name: backendAzureRmContainerName<br>  value: &#39;core-tfstate&#39;<br>- name: backendAzureRmKey<br>  value: &#39;terraform.tfstate&#39;<br>pool:<br>  vmImage: ubuntu-latest</pre><pre>stages:<br>- stage: TerraformContinuousIntegration<br>  displayName: Terraform Module - CI<br>  jobs:<br>   - job: TerraformContinuousIntegrationJob<br>     displayName: TerraformContinuousIntegration - CI Job<br>     pool:<br>        vmImage: ubuntu-20.04<br>     steps:<br>      <em># Step 2: Install Az cli and login via the service principal<br>     </em>- task: AzureCLI@2<br>       inputs:<br>        scriptType: bash<br>        azureSubscription: &#39;$(serviceConnection)&#39;<br>        scriptLocation: inlineScript<br>        workingDirectory:  $(terraformWorkingDirectory)<br>        inlineScript: |<br>        sudo curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash <br>        az --version<br>        az login --service-principal -u $(AppId) -p $(password) <br>        --tenant $(Tenant_id)\<br>     <em># Step 3: Install Terraform on Azure Pipelines agent<br>     </em>- task: TerraformInstaller@0<br>       displayName: &#39;install&#39;<br>       inputs:<br>         terraformVersion: $(terraformVersion)</pre><pre><em>     # Step 4: run Terraform init to initialize the workspace<br>     </em>- task: TerraformTaskV2@2<br>       displayName: &#39;Run Terraform init&#39;<br>       inputs:<br>        command: init<br>        workingDirectory: $(terraformWorkingDirectory)<br>        backendServiceArm: $(serviceConnection)<br>        backendAzureRmResourceGroupName:  <br>        &#39;${{variables.backendAzureRmResourceGroupName}}&#39;<br>        backendAzureRmStorageAccountName: &#39;${{ <br>        variables.backendAzureRmStorageAccountName}}&#39;<br>        backendAzureRmContainerName: &#39;${{<br>        variables.backendAzureRmContainerName }}&#39;<br>        backendAzureRmKey: &#39;terraform.tfstate&#39;</pre><pre><em>     # Step 5: Run Terraform validate to validate the HCL syntax<br>     </em>- task: TerraformTaskV2@2<br>       displayName: &#39;Run Terraform validate&#39;<br>       inputs:<br>        command: validate<br>        workingDirectory: $(terraformWorkingDirectory)<br><br>     <em># Step 6: run Terraform plan to validate HCL syntax<br>     </em>- task: TerraformTaskV2@2<br>       displayName: &#39;Run Terraform plan&#39;<br>       inputs:<br>        command: plan<br>        workingDirectory: $(terraformWorkingDirectory)<br>        environmentServiceNameAzureRM: &#39;$(serviceConnection)&#39;<br>        commandOptions: -var location=$(azureLocation)<br>     <em># Step 7: run Terraform apply to validate HCL syntax<br>     </em>- task: TerraformTaskV2@2<br>       displayName: &#39;Run Terraform apply&#39;<br>       inputs:<br>        command: apply<br>        workingDirectory: $(terraformWorkingDirectory)<br>        environmentServiceNameAzureRM: &#39;$(serviceConnection)&#39;<br>        commandOptions: -var location=$(azureLocation)</pre><p>The script mentioned above serves the purpose of installing Terraform, retrieving Terraform files from a designated variable named “terraformWorkingDirectory,” and subsequently provisioning our infrastructure while securely storing the state files in a blob storage. However, upon closer examination, it becomes apparent that sensitive information, such as our service connection and Terraform’s working directory, are supplied as environment variables within a variable group. In our case, this variable group is named “BlogPost-infra-vg”.</p><p>Azure offers a reliable option to create a secure variable group where all the required environment variables can be safely stored. This approach ensures the protection of sensitive data. Additionally, Azure provides granular control over the visibility of these variables, enabling you to determine which profiles, users, or identities can access and view the values associated with these variables. This additional level of security further safeguards the confidentiality and integrity of the environment variables within the Azure ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJOp8kJzxASP0WYez1hnUg.jpeg" /></figure><p>Once this setup is completed the pipeline will be triggered as soon as the developer will push this terraform code on azure repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I37PGIbxL_bYaBwWJfzE8A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b33cba0283f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f">Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…]]></title>
            <link>https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1?source=rss-38de9229b8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba7308df0ed1</guid>
            <category><![CDATA[mlops-platform]]></category>
            <category><![CDATA[kubeflow-pipelines]]></category>
            <category><![CDATA[kubeflow]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Rachit Ahuja]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 15:53:01 GMT</pubDate>
            <atom:updated>2023-09-05T11:24:30.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2, Mlflow, and Seldon: Part 1</h3><h3><strong>Introduction and Architecture Planning</strong></h3><h4><strong>Introduction:</strong></h4><p>The adoption of MLOps has become increasingly popular among Machine Learning engineers and data scientists, representing a significant trend in the field. MLOps involves the development of reusable workflows for training, testing, and inference of machine learning models. This article aims to provide a comprehensive guide on implementing an end-to-end MLOps pipeline, including model training and deployment on a Kubernetes-based infrastructure. It is part of a series covering various steps in this implementation. If you have any questions or collaboration requests, feel free to reach out.</p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1"><strong>Part 1: Introduction and Architecture Planning</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-2b33cba0283f"><strong>Part 2: Developing Workflows for Infrastructure Deployment via CI/CD</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-cfacb7af4258"><strong>Part 3: Setting up MLflow on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-f14ae5267d11"><strong>Part 4: Setting up Kubeflow and Seldon on AKS</strong></a></p><p><a href="https://medium.com/@rachit_231095/end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-using-terraform-kubeflow-v2-mlflow-and-2c0d18e3d286"><strong>Part 5: End-to-End Training Pipeline and Inference Deployment using Seldon.</strong></a></p><h4><strong>Architecture Design Components:</strong></h4><ul><li><strong>Kubeflow:</strong> Kubeflow is a machine learning platform designed to seamlessly integrate with Kubernetes, enabling the creation of scalable pipelines for model training and testing. While there are alternative methods for orchestrating end-to-end Machine Learning pipelines, such as creating graphs or using docker containers, Kubeflow offers notable advantages. By fully leveraging the strengths of Kubernetes, including features like Nodes, Persistence Volumes, and Network Policies, Kubeflow simplifies resource management and allocation, providing an efficient workflow for machine learning tasks.</li><li><strong>Mlflow:</strong> Mlflow serves as a central hub for streamlining machine learning processes and developments. It offers functionalities such as experiment tracking, code packaging for reproducible runs, and model deployment in production. Mlflow integrates easily with existing ML applications, requiring minimal refactoring of the source code due to its user-friendly APIs. In this implementation, Mlflow will be used to track experiments, including parameter values and metrics for analyzing training results. If a trained model meets the required quality for production deployment, Mlflow provides a model registry for securely storing the final model artifacts. Additionally, Mlflow enables real-time updates on recorded metrics through its interface. The Mlflow server will run on one of the nodes in our cluster, with Azure PSQL and Azure Containers employed to store model logs and artifacts, respectively.</li><li><strong>Seldon:</strong> Seldon is a set of machine learning tools designed to streamline and accelerate model deployment and management in a production environment. Acting as a bridge between Data Science and DevOps teams, Seldon accelerates the pace of bringing machine learning models to market and unlocking business value. Seldon Core, a production-ready tool, efficiently handles tasks such as model scaling, load management, and switching from REST requests to Grpc.</li></ul><h3>Architecture Overview</h3><p>This section discusses the architecture to be developed for the implementation. While architectural design is typically the responsibility of Solutions Architects, having a clear architecture in mind can streamline the implementation process and provide an overview of the end product. For this implementation, the desired architecture includes the following elements:</p><ol><li><strong>Centralized Code Repository:</strong> A centralized code repository will be utilized to store code and workflows for different parts of the project. Azure DevOps, offering mature pipelines and enterprise tooling, will be exploited for this purpose.</li><li><strong>Infrastructure as Code:</strong> Terraform will be employed to create infrastructure as code. Manual infrastructure creation will be avoided by creating separate CI/CD pipelines in Azure DevOps for infrastructure creation.</li><li><strong>Machine Learning Training with Kubeflow:</strong> Kubeflow, triggered programmatically using its Python API, will facilitate the actual machine learning training.</li><li><strong>Human Intervention and Supervision:</strong> Human intervention and supervision are crucial aspects of the MLOps workflow. Although an evaluation step will be included in the pipeline to select the best trained model based on a particular evaluation metric, the deployment of ML model serving using Seldon will be done manually.</li></ol><p><strong>Note:</strong> In an industrial scenario, separate Kubernetes clusters are usually used for model training and model deployment. However, for this mini implementation, everything will be performed on a single cluster.</p><p>By following this comprehensive guide, you can build end-to-end MLOps pipelines for sentiment analysis on Azure using Terraform, Kubeflow v2, Mlflow, and Seldon. Stay tuned for the upcoming parts in this series to learn more about each step of the implementation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJQbLR1PTakZ9-GM371g2w.png" /><figcaption>End-to-End Architecture Diagram for Blogpost</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba7308df0ed1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/building-end-to-end-mlops-pipelines-for-sentiment-analysis-on-azure-with-terraform-kubeflow-v2-ba7308df0ed1">Building End-to-End MLOps Pipelines for Sentiment Analysis on Azure with Terraform, Kubeflow v2…</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>