<?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 Max Pavlov on Medium]]></title>
        <description><![CDATA[Stories by Max Pavlov on Medium]]></description>
        <link>https://medium.com/@maxpavlov?source=rss-6e2a6b0825a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-r0EDhTD8MDYD5POacK3gQ.jpeg</url>
            <title>Stories by Max Pavlov on Medium</title>
            <link>https://medium.com/@maxpavlov?source=rss-6e2a6b0825a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:54:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maxpavlov/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[MCP Isn’t Dead]]></title>
            <link>https://maxpavlov.medium.com/mcp-isnt-dead-8ce6fc7da88b?source=rss-6e2a6b0825a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ce6fc7da88b</guid>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Max Pavlov]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 14:38:54 GMT</pubDate>
            <atom:updated>2026-04-23T14:38:54.171Z</atom:updated>
            <content:encoded><![CDATA[<h3>The advice to kill it should be.</h3><p>Today I got an email with Medium trending articles and one particularly clickbait-ish title caught my attention: MCP is Dead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*pe68s8TW8axc78zqYVS46A@2x.jpeg" /></figure><p>When I opened it I was hoping to see something like MCP is dead! Long live MCP! Instead, the article was about challenges with MCP, how token-hungry the calls are, and why we should abandon it altogether. The proposed alternative: have AI apps call terminal CLIs and APIs directly. For fairness, it’s worth mentioning that the author did try to bring up tool call schemas — baked directly into your AI app — as a bulletproof way for AI to know how to make calls on budget.</p><p>This is dangerous. Because when bad advice becomes trendy, there is a risk that many will buy into it and hurt their own progress — until they finally realize it was just an opinion, and a very questionable one.</p><p>Let me put it simply: if right now, in April 2026, MCP hadn’t been invented yet — we’d need someone to <strong>invent it</strong>. It is the most widely adopted <strong>plug-and-play</strong> connector mechanism for AI applications, and for good reason. MCPs are straightforward to build once you understand the protocol and its features.</p><p>But first, let’s address the “just use direct API calls” advice. That recommendation fundamentally misunderstands what MCP is solving. <strong>MCP doesn’t replace your API calls — it standardizes how AI applications discover and invoke those calls at runtime.</strong> The proposed alternative — baking tool schemas directly into your AI app — is just a worse, proprietary version of MCP. You lose dynamic tool discovery, versioning, and portability. Any API change downstream requires updating your embedded schemas. You end up with a tightly coupled system that breaks quietly. That’s not control. That’s fragility with extra steps.</p><p>To be fair, the <strong>structured tool calling</strong> recommendation <strong>is not wrong</strong> on its own terms — defining typed schemas natively in the Anthropic or OpenAI SDK does give you determinism and tight control, and for a single contained application it’s a perfectly reasonable pattern. The problem is it doesn’t scale beyond that application. There is no plug-and-play here. Every new AI app that wants to use the same tool rebuilds the same schema from scratch. Every update on the provider side ripples into every consumer independently. <strong>MCP moves that contract to where it belongs — on the provider</strong> — and lets any compatible client pick it up for free. That’s not overhead. <strong>That’s the whole point.</strong></p><p>And the <strong>token consumption </strong>argument? Real concern, wrong conclusion. A well-designed MCP server exposes <strong>focused, minimal tools</strong>. The Figma MCP eating 20k tokens is a Figma MCP design problem — not a protocol problem. More to the point: those “direct API call schemas” the article recommends also consume context window. You are not escaping the token budget by switching approaches. You’re just obscuring the cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*9_q8qi7fEovltb4RVLEncQ@2x.jpeg" /><figcaption><em>Chef blaming the knife for burnt food</em></figcaption></figure><p><strong>MCP</strong>, if done right, <strong>is</strong> also<strong> a crucial source of standardization</strong> around the most important aspect of modern app interoperability — <strong>authentication</strong> and <strong>authorization</strong>. While most enterprises are still figuring out how to do MCP auth properly, the protocol provides a comprehensive and secure way for AI application users to authenticate with tool provider servers. The direction it’s heading — OAuth 2.1 with proper scopes and token delegation — gives each tool invocation the right semantics: the <strong>agent acts on behalf of the user</strong>, with <strong>scoped permissions</strong>, not ambient credentials sitting in environment variables. Enterprises working through AI agent governance don’t want a hundred bespoke integration patterns. They want one. MCP is positioned to be that one.</p><p>The security risk argument in the article actually cuts the other way. “Direct API calls from an AI agent” means your secrets are in env vars or in prompts. A mature MCP Auth implementation is strictly more secure, not less.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*d7_cxrkx8OU6ajHGeMslVg@2x.jpeg" /><figcaption>Keys are secured and managed properly</figcaption></figure><p>It is also worth mentioning that almost no one is using the <strong>instructions field</strong> in the MCP initialize response — a crucial and mostly overlooked feature that enables dramatic improvement in backing model instruction-following for MCP tool calls.</p><p>When an MCP server includes instructions in its initialize response, compatible clients inject that content directly into the system prompt. This is your designated space to <strong>teach an AI application</strong> <strong>exactly how to use your MCP correctly</strong> — which tools to call in which sequence, what error patterns to handle, when not to invoke a tool. Done right, this directly addresses the reliability complaints raised in the article. Models won’t misuse tools they’ve been properly briefed on. We basically have a proper place to “teach” an AI app how to use MCP correctly — and most servers leave it blank.</p><p>Reliability isn’t a protocol weakness. It’s a missed configuration opportunity at massive scale.</p><p>MCP is not perfect. The ecosystem is still maturing, the tooling has rough edges, and yes — a poorly designed MCP server will cost you tokens and cause headaches. But the answer to a poorly implemented abstraction is never to abandon the abstraction. It’s to implement it well.</p><p>Fix your MCPs. Use the instructions field. Scope your tools tightly. <strong>MCP isn’t dead</strong> — it’s just <strong>not being used to its full potential yet</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*bG1f_6yJQYMhiVra60B48w@2x.jpeg" /><figcaption>Don’t ditch the USB, just hold it right</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ce6fc7da88b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Single vs Multi-agent systems: when to build which]]></title>
            <link>https://maxpavlov.medium.com/single-vs-multi-agent-systems-when-to-build-which-1f336c676bd7?source=rss-6e2a6b0825a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f336c676bd7</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Max Pavlov]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 06:55:15 GMT</pubDate>
            <atom:updated>2025-06-19T06:55:15.636Z</atom:updated>
            <content:encoded><![CDATA[<p>The architecture of AI agent-based systems is a critical decision in the rapidly establishing field of AI engineering. Fortunately, traditional software architecture skills remain highly relevant, meaning we don’t need an entirely new discipline to design AI-centric systems — at least not yet. This article explores the debate between single-agent and multi-agent AI systems, drawing insights from two key articles: one from Cognition.ai advocating against multi-agent systems and another from Anthropic detailing their multi-agent research system.</p><blockquote><em>Takeaway:</em> <strong><em>pre-AI era software architecture skills are applicable for designing AI-centric systems</em></strong></blockquote><p>The tech industry is buzzing with discussion about whether multi-agent systems will become the standard for AI applications. Some industry leaders argue that multi-agent orchestration is a transformative outcome of the AI revolution, potentially surpassing the impact of historical shifts like the industrial revolution. While this perspective is compelling, it’s crucial to avoid adopting multi-agent systems just because they’re trendy, much like the rush to microservices in the past. The choice between single-agent and multi-agent architectures should be a deliberate, rational decision based on the system’s purpose.</p><blockquote><em>Takeaway:</em> <strong><em>most AI systems will probably end up being a multi-agent orchestrations, however this has to be a concious and rational design decision</em></strong></blockquote><h3>Anthropic’s Multi-Agent Research System</h3><p><a href="https://www.anthropic.com/engineering/built-multi-agent-research-system">Anthropic’s article</a>, “How we built our multi-agent research system”, describes their approach to building a multi-agent system for Claude’s “deep research” feature. This system uses Claude as the user-facing interface, with a lead agent orchestrating multiple sub-agents to perform complex research tasks, such as summarization and projection, often relying on web searches for up-to-date information. The architecture excels at breadth-first queries, reducing research time by up to 90% through parallel processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jXQ5sQuDgGDFrsdP" /><figcaption>Multi-agent research system diagram by Antropic (from <a href="https://www.anthropic.com/engineering/built-multi-agent-research-system">citated artcile</a>)</figcaption></figure><p>However, Anthropic acknowledges significant challenges:</p><ul><li>Coordination Complexity: Early versions of their system spawned excessive sub-agents or got stuck in loops.</li><li>Reliability Issues: Ensuring consistent performance across agents is difficult.</li><li>High Token Usage: Multi-agent systems consume approximately 15 times more tokens than simple chat systems, leading to higher computational costs.</li></ul><p>Anthropic’s system demonstrates that multi-agent architectures are powerful for tasks requiring diverse expertise or parallel processing but require careful design to manage these challenges.</p><blockquote><em>Takeaway:</em> <strong><em>multi-agent systems are powerful and complex. Also a challange of reliability. Burn through tokens quickly thus inflicing high computational costs. Use wisely.</em></strong></blockquote><h3>Cognition.ai’s Case for Single-Agent Systems</h3><p>In contrast, <a href="https://cognition.ai/blog/dont-build-multi-agents">Cognition.ai’s article</a>, “Don’t build multi-agents”, argues that the AI industry is in an early stage of agent development, akin to the web’s early days with only HTML and CSS. They caution against prematurely standardizing on multi-agent systems, which can be fragile and prone to errors due to miscommunication between agents. Instead, they advocate for “context engineering” — carefully refining the context provided to a single agent to improve its performance.</p><p>Cognition.ai illustrates this with an example of building a “Flappy Bird clone.” In a multi-agent setup, one sub-agent might misinterpret its task (e.g., building a background resembling Super Mario Bros.), and another might create an incompatible component, leading to errors when combining outputs. A single agent with well-refined context can avoid such issues, maintaining consistency and reducing complexity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*19toU_XI6wq3OE20.png" /><figcaption>Single agent flow as depicted by Congintion.ai (from <a href="https://cognition.ai/blog/dont-build-multi-agents">citated article</a>)</figcaption></figure><blockquote><em>Takeaway:</em> <strong><em>Single-agent systems are effective for tasks that a single human expert could handle efficiently, offering better reliability and lower coordination overhead.</em></strong></blockquote><h3>Comparing the Approaches</h3><p>The debate between single-agent and multi-agent systems hinges on task suitability:</p><ul><li><strong>Single-Agent Systems</strong>: These are ideal for tasks like small-scale coding, document generation, or lightweight research, where a single expert could complete the work sequentially. They minimize handoff issues and are less resource-intensive.</li><li><strong>Multi-Agent Systems</strong>: These excel in complex tasks requiring diverse skills or parallel processing, such as in-depth research or large-scale software development. However, they demand robust coordination mechanisms and consume more resources.</li></ul><p>Cognition.ai suggests that multi-agent systems are currently fragile but hold long-term potential. Anthropic’s experience shows that while multi-agent systems can outperform single-agent systems in specific scenarios (e.g., 90.2% better on internal research evaluations), their complexity requires careful management.</p><blockquote><em>Takeaway:</em> <strong><em>Choose single-agent systems for tasks manageable by one expert; reserve multi-agent systems for tasks requiring diverse expertise or parallelism.</em></strong></blockquote><h3>Decision-Guiding Questions</h3><p>To make an informed choice between single-agent and multi-agent architectures, consider these refined questions:</p><p><strong>Task Decomposition</strong>:</p><ul><li>Can the task be broken into subtasks?</li><li>Are these subtasks independent or interdependent?</li></ul><p><strong>&gt;</strong> Independent subtasks that can be processed in <strong>parallel</strong> favor <strong>multi- agent </strong>systems. <br> <strong>&gt;</strong> Interdependent or <strong>sequential</strong> subtasks favor <strong>single-agent</strong> systems to maintain context.</p><p><strong>Expertise Requirements</strong>:</p><ul><li>Does the task require <strong>diverse skills or tools</strong> that a single agent might struggle with?</li></ul><p><strong>&gt;</strong> If <strong>yes</strong>, <strong>multi-agent</strong> systems with specialized agents are advantageous.<br><strong>&gt;</strong> If <strong>no</strong>, a <strong>single agent</strong> with appropriate tools is sufficient.</p><p><strong>Parallelism Potential</strong>:</p><ul><li>Can subtasks be processed simultaneously to save time?</li></ul><p><strong>&gt;</strong> If <strong>integration of parallel outputs</strong> is <strong>straightforward</strong>, <strong>multi-agent</strong> systems are beneficial.<br><strong>&gt;</strong> If <strong>integration</strong> is <strong>complex</strong>, <strong>single-agent</strong> systems may be better to avoid context loss.</p><p><strong>Resource Constraints</strong>:</p><ul><li>Are computational resources (e.g., token limits, processing power) limited?</li></ul><p>&gt; <strong>Multi-agent </strong>systems are<strong> resource-intensive</strong>; <br>&gt; <strong>Single-agent</strong> systems are more <strong>economical</strong>.</p><p><strong>Development Complexity</strong>:</p><ul><li>Is your team equipped to handle the complexity of multi-agent systems?</li></ul><p><strong>&gt;</strong> <strong>Multi-agent</strong> systems are <strong>harder to design and debug</strong>; <br><strong>&gt;</strong> <strong>Single-agent</strong> systems are <strong>simpler</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fcj5Kj%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fcj5Kj%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2Fcj5Kj%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="458" frameborder="0" scrolling="no"><a href="https://medium.com/media/40f85d35c3192d925c090790bea3be82/href">https://medium.com/media/40f85d35c3192d925c090790bea3be82/href</a></iframe><h4>Summary and Conclusion</h4><p>Single-agent AI systems are simpler and more reliable for tasks that a single expert can handle sequentially, such as small-scale coding or document generation. Multi-agent systems, as evidenced by Anthropic’s 90.2% performance boost, may excel in complex, parallelizable tasks like in-depth research, but they introduce challenges in coordination, reliability, and resource usage. The evidence leans toward balancing capability with complexity, with no one-size-fits-all answer. By assessing task structure, expertise needs, resource constraints, and reliability requirements, engineering teams can choose the architecture that best aligns with their project’s goals.</p><h4>Key Citations</h4><ul><li><a href="https://www.anthropic.com/engineering/built-multi-agent-research-system">Cognition.ai: Don’t Build Multi-Agents</a></li><li><a href="https://cognition.ai/blog/dont-build-multi-agents">Anthropic: How We Built Our Multi-Agent Research System</a></li><li><a href="https://github.com/openai/swarm">OpenAI: Swarm Library for Multi-Agent Systems</a></li><li><a href="https://github.com/FoundationAgents/MetaGPT">MetaGPT: Framework for Multi-Agent Collaboration</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f336c676bd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First steps with ML.NET — object detection realm]]></title>
            <link>https://maxpavlov.medium.com/first-steps-with-ml-net-object-detection-realm-55d7efb7968?source=rss-6e2a6b0825a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/55d7efb7968</guid>
            <dc:creator><![CDATA[Max Pavlov]]></dc:creator>
            <pubDate>Tue, 17 Aug 2021 07:20:06 GMT</pubDate>
            <atom:updated>2021-08-17T07:20:06.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>First steps with ML.NET — object detection realm</h3><p>ML.NET is a free machine learning library from Microsoft to power the .NET ecosystem with machine learning capabilities. Not only it allows for easy integration with the existing machine learning models, but it is also a powerful toolset for the creation of own reusable models.</p><h4>What will you learn by reading this article?</h4><p>As a .NET developer, you will be able to write C# code that uses ML.NET in order to perform specific machine learning tasks — text sentiment analysis and object detection. You will learn how to use an existing, pre-trained machine learning model (YOLO v4) that is capable of detecting objects of certain types (types are called “classes” in ML terms) from an arbitrary image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuSyCF-ECipER3GZ8koraw.png" /></figure><h3>Some theory</h3><p>Machine learning is a subset of <strong>a<em>rtificial intelligence</em></strong><em> </em>(AI), an area of scientific study. While AI deals with making computers mimic human capabilities, <strong><em>machine learning</em> </strong>is a subset of AI that enables computers to improve on the tasks they are given without being explicitly programmed for each improvement. Machine “learns” as it does its work. <strong><em>Deep learning</em></strong>, in turn, is a subset of machine learning that deals with the creation of deep learning models, which use multiple computational layers in the network architecture. As we won’t go deeper into the ML theory in this article, I suggest your read on those terms elsewhere for a deeper understanding. However, this is not required to start practical experiments with deep learning as you will see in the following paragraphs.</p><p>Machine learning models use historical data to predict correct outputs based on the new inputs, the model “has never seen before”. If the model is trained on a lot of photos of cats while being explicitly told that “this is a cat”, the model can be given any photo it wasn’t trained on and with relative confidence, it will try to guess, if there is a cat on that photo or not.</p><p>One final boring <em>(read — non-practical)</em> piece: the difference between <strong>machine learning algorithm</strong> and <strong>machine learning model</strong>:</p><ul><li>ML algorithm is an algorithm that is being applied to data.</li><li>ML model is a program that takes inputs and predicts outputs.</li></ul><blockquote>ML algorithms + Data = ML Model.</blockquote><h3>If a model is a program, then what is its format?</h3><p>Machine learning models can be created in different formats. Usually, the format is dictated by the software which is used to create the model, with the most notable examples being: <a href="https://en.wikipedia.org/wiki/TensorFlow">TensorFlow</a>, <a href="https://en.wikipedia.org/wiki/Keras">Keras</a>, <a href="https://en.wikipedia.org/wiki/Caffe_(software)">Caffe</a>, <a href="https://en.wikipedia.org/wiki/Torch_(machine_learning)">Torch</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*ABKjU5zsd7Cpuusr.png" /><figcaption>ONNX ecosystem logo</figcaption></figure><p>There is a model format created specifically for cross-tool compatibility — ONNX (read as Onix). ONNX is a common platform, most of the ML model formats can convert from and into ONNX. One can train algorithms into an ONNX model directly. For our computer vision-related demo’s we will be consuming a popular model called YOLOv4 that is as well provided in ONNX format by its developers.</p><h3>A simple enough example of ML.NET</h3><p>I suggest one goes through a simple ML.NET tutorial by Microsoft that can be found <a href="https://dotnet.microsoft.com/learn/ml-dotnet/get-started-tutorial/intro">here</a>. It will walk you through an installation of the dependencies and provisioning of the first ML.NET-enabled project. At the end of the tutorial, you have an auto-generated solution with two projects — class library and console application projects. In my case those are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*BoqNQCvGyGrt-j9DnSCLvQ.png" /><figcaption>A simple auto-generated solution with classification task implementation sample</figcaption></figure><p>The generated solution provides the functionality of guessing a sentiment of the text comment, which is given as an input parameter. This type of ML task is called a Classification task — a program classifies if the given text represents a positive or a negative comment.</p><p>By the way, if you, for some reason, prefer not to follow the tutorial, you can simply get the source code being reviewed from <a href="https://github.com/maxpavlov/basic-mlnet-sentiment-classification">GitHub</a>.</p><p>There are several classes generated here that are of interest to us, however, as this article isn’t intended to go into details on how one can train/create a model, we will focus on model consumption. I am convinced that the best way to embrace new technology is by using it initially, and only then inspect how it is engineered. <em>ModelBuilder.cs</em> in <em>SampleClassification.ConsoleApp </em>is a generated class that shows how a model can be created and saved based on the automatically selected set of ML algorithms. We will cover this aspect in depth in the subsequent articles and we will not review model creation logic here.</p><p><em>SampleClassification.Model</em> project hosts another class called<em> ConsumeModel. </em>This class exposes the functionality that other classes can “use” to work with the generated model. Let’s break it down to see how it works:</p><ol><li><em>ConsumeModel</em> itself is just a wrapper class that exposes the <em>Predict</em> method:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*gDyQYB_0dDb78_ZXmaYalA.png" /></figure><p>As we will learn along the way, typical consumption of an ML model in code involves having an input and output types defined that enable code to represent the parameters that are passed into a model and the format of the output that the model produces after processing the inputs. POCO classes <em>ModelInput</em> and <em>ModelOutput</em> in the generated solution are exactly those types in our demo case.</p><p>2. The <em>Predict</em> method takes an instance of <em>ModelInput</em> class as a parameter, does “ml magic” and returns an instance of <em>ModelOutput</em> class.</p><p><em>ModelInput</em> class looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*BhFVjLH_6MDwBy0R_TEQyg.png" /></figure><p>Before we proceed, let’s quickly review what those <em>ColumnName</em> and <em>LoadColumn</em> attributes are for here. When ML.NET steps through the data transformation pipeline (it does it during training of a new model and while using it), it uses a generic container to store data being processed and passed from one step of the pipeline to another. An implementation of an interface called IDataView is being used in ML.NET to store intermediary and resultant data. Think of it as an in-memory data table that implements IDataView. Table operates with columns and rows (classical tabular data model). ML.NET operates with column names. Whenever we need ML.NET to be able to map something from IDataView to our POCO objects, we use attributes to be able to “tell ML.NET” which column to map to. [ColumnName(“col0”), LoadColumn(0)] basically means “take the value from this property, load it into column 0 (the first one), name it “col0” for future reference by ML.NET mechanisms. (since it’s an Input model, attributes tell ML.NET how to “parse” these POCO models onto a standard IDataView construct.</p><p><em>ModelOutput</em> class looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*sJulMrNYsGUJYYwUA0eEZA.png" /></figure><p>In this context, [ColumnName(“PredictedLabel”)] means that our model when it produces output, was configured to output the result, and the result we are interested in mapping to a <em>Prediction</em> property is exactly located in the PredictedLabel column of the output. If we sneak peek into our ModelBuilder which I decided to omit in this article, we see exactly this in the model configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iQKerX64LMa9olMw7tEww.png" /></figure><p>Now that we have reviewed Input and Output models, we can finish the review of the <em>ConsumeModel.cs</em>.</p><p>At the top of the class, we have a property called PredictionEngine. It is a lazy-loaded object of type <em>PredictionEngine&lt;ModelInput, ModelOutput&gt;. </em>It is being used in Predict method we’ve seen earlier to perform the actual prediction when called from external application code. As you will progress learning ML.NET, you will see that it is not mandatory, but it is a very good practice for wrapping the ML.NET pipeline into an instance of PredictionEngine generic class. It serves as an encapsulating class for all the plumbing that is required to actually get the output after providing the input.</p><p>Just like any other laze-loaded object, when it is being called for the first time, the initializer method (in our case CreatePredictionEngine) is called. Let’s quickly inspect its contents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w-0lzXx1koOxEhgP-N_qjA.png" /></figure><p>One of the core classes in ML.NET —<em> MLContext</em> appears here. Microsoft documentation provides a concise description of the purpose of this class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fg-M3iwsiQMmbRTE3XeZYA.png" /></figure><p><em>MLContext</em> is like a <em>RequestContext</em> in ASP.NET where “everything we need to process the web request” is “mounted” onto a defined object and we interact with it. In ML.NET, <em>MLContext</em> is that class.</p><p>Now that we have a “home where everything can happen” (meaning MLContext instance), to create a prediction engine a pre-built Model is being loaded from the file (<em>mlContext.Model.Load</em> call), and finally, the prediction engine is created and returned (<em>mlContext.Model.CreatePredictionEngine&lt;ModelInput, ModelOutput&gt; </em>call).</p><p>Pretty simple, just 3 steps and we have the wrapper that takes input and gives us the desired output back. Well, there is obviously much more to this, like probabilities (how confident the model is in the given prediction being made). But more on that later. Now, let’s review how this works with visual data, not just text.</p><h3>Object detection with ML.NET</h3><p>A computer program being able to take any text and try to identify if its positive or negative while also providing a piece of information on “how sure” it is about the prediction is cool enough already, but let’s see how we can use ML.NET to inspect a camera input and detect objects on the fly.</p><p>In our simple text-to-sentiment prediction example above we relied on the instance of the <em>PredictionEngine&lt;ModelInput, ModelOutput&gt;</em> class to make our predictions. In the case of the computer vision task, where we want to detect objects, we could do the same, but logically, <em>ModelInput</em> would be an image, and <em>ModelOutput</em> needs to contain information about objects that have been detected by the algorithm on the provided image. Well, it turns out we can do just that.</p><p>Here is a wider diagram that includes .NET classes involved in a “plug-and-play” ML.NET implementation we could use as an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9chK8BET8p2a-2k-FykXuA.png" /></figure><p>Before we break down the proposed class hierarchy, let me briefly explain the term YOLO and which computer vision model we will use in our practical example.</p><p>In Machine Learning, YOLO is a popular abbreviation that refers to “You Only Look Once”. It is a name of an object detection algorithm that has gained fame due to its performance and simplicity. The “look once” part refers to the essential aspect of the algorithm being used, which is — an object detection is performed via a single forward propagation through a neural network. The predictions in the entire image happen during a single algorithm run — thus the performance gain. Convolutional Neural Network is used to predict various class probabilities and bounding boxes simultaneously. YOLO is also known to have great learning capabilities which we will review in a subsequent article.</p><p>YOLO has seen several of its implementation versions published over the recent years. We will now focus on an “already outdated” YOLOv4 by <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Bochkovskiy%2C+A">Alexey Bochkovskiy</a>. One can easily download the ONNX version of this model from ONNX GitHub repo <a href="https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/yolov4">here</a>. (you will need it if you are to run my demo project locally).</p><p>But let’s get back to the .NET code!</p><p>Our consuming code can be anything — a web app, a desktop app, or an API implementation. As long as the “consuming code” can feed our object detector an image, we should be able to detect and classify objects on it.</p><p>In my diagram above <em>IPredictionProvider</em> and the <em>YOLOPredictionProvider</em> are generic wrapper classes, a syntactical sugar to nicely wrap the actual “meat” of the ML.NET implementation, which is, similarly to our first demo project, relies on <em>MLContext</em> to do all of the work. Let’s inspect them more closely:</p><p><em>IPredictionProvider</em> is an interface that our “consuming code” will be using:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*f-Hqp_IZZCLEe3fRRvE6mA.png" /></figure><p><em>YOLOPredicionProvider</em> is the implementation of <em>IPredictionProvider</em>. The essential part of the “setting up” happens in the class constructor. Please refer to the source code for proper inspection, file name is YoloV4PredictionProvider.cs, lines 33–63.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47TuoEe14vwDI_W_S25wlA.png" /><figcaption>Yeah, I know you can’t read well from that screenshot, it’s here to outline where to look at in code</figcaption></figure><p>Lets dissect the code that implements the provider initialization and configuration. <em>MLContext</em> instance is created. Next line assigns a object of type <em>EstimatorChain&lt;OnnxTransformer&gt;. </em>As the name suggests, we are creating a chain of transformers that will be processing out input data in order to arrive with an output which is our prediction.</p><p>First estimator in the chain would be <em>ResizingImageEstimator</em>, a class that takes the image from the <em>IDataView</em> (remember we met this guy in a previous example?), resizes it and places the resized image onto a column with a name specified in <em>outputColumnName</em> parameter — “input_1:0” in our example. So it takes and image and returns an image (a bitmap).</p><p>Next one in line is the <em>ImagePixelExtractingEstimator</em> added via <em>.Append(mlContext.Transforms.ExtractPixels…)</em> call. This is an estimator that takes an image and converts it into a̶n̶ ̶a̶r̶r̶a̶y̶…sorry, a vector.</p><p>The final and the most complex <em>.Append</em> statement adds an <em>OnnxScoringEstimator</em>, the one that actually does the main workload — attempts to identify objects an an input image. Remember, at this point image is already converted into a numeric vector.</p><p>Let’s review how we configure the <em>OnnxScoringEstimator</em> with the parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*cxuN3eyp62wU2BVAU5XSiw.png" /></figure><p><em>shapeDictionary</em> is a configuration parameter that allows model users (us, developers, in this case) to specify the “dimensional configuration” of the model’s input and output parameters. For simplicity’s sake I suggest you just need to know which shapes are fit for which model by learning it from the model’s documentation.</p><p><em>inputColumnNames</em> and <em>outputColumnNames</em> parameters allow us to specify the name from the input and output(s) after the transformation is performed. Basically we define the naming to be used in the <em>IDataView</em>. It is a normal practice to investigate the Onnx model “signature” (e.g. what it takes as an input and what it produces) via a visual tool like <a href="http://netron.app/">Netron</a> or via code. Netron renders YOLOv4 Onnx model we are using like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJL5Ar5YvBMTC9ZhHh566w.png" /></figure><p>It can tell us what are the names of the inputs and the outputs model expects and produces. It is fine to have those correspond in the <em>IDataView</em> mapping. Netron also reveals the format of the tensor shape, with <em>unk_ </em>representing an unknown token which the decoder couldn’t process. We must acquire a supplementary documentation and usage examples from the model authors since, as the example shows, not all of the parameters are “auto-discoverable” via utilities like Netron.</p><p><em>modelFile </em>parameter is self-explanatory — it allows us to specify where the .onnx model is on the volume, so that our ml.net runtime can find it and interact with it.</p><p><em>gpuDeviceId</em> defines which GPU within a system to use when working with the model, <em>null</em> in our case means that we are not intending to use a GPU.</p><p><em>fallbackToCpu</em> controls if the OnnxRuntime will try to do the work on the CPU instead of a GPU.</p><p>Once the <em>EstimatorChain</em> is created, we need to create a <em>TransformerChain</em>. Remember, out ultimate goal is to create a correctly pre-configured <em>PredictionEngine</em> instance. We are almost there.</p><p>Transformer is obtained by providing an input model (a POCO class) to the <em>EstimatorChain</em> within a <em>.Fit(..</em> method call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kwCSSjlzRODLQ-EU7ZClVw.png" /></figure><p>We are “fitting” the input model we are to supply to an estimator chain in order to “prepare” the chain and acquire a <em>TransformerChain</em>. Estimators are algorithms, which, when “fitted” with a <em>DataView</em>, produce a Transformer. Transformers are algorithm capable of producing a new <em>DataView</em> entry as an output, while being provided a <em>DataView</em> as an input. For instance Transformer takes a <em>DataView</em> with and image, and outputs a <em>DataView</em> with predictions. <em>YoloV4BitmapData</em> is a C# class that will be a part of <em>IDataView</em> when it is supplied for prediction.</p><p>One final step to generate a <em>PredictionEngine</em> is to call <em>MLContext.Model.CreatePredictionEngine&lt;TSrc, TDst&gt; </em>and supply both input and expected output structures, again, a pure C# classes in ML.NET case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bqfbw47lTdG3cSuH2kFRVA.png" /></figure><p>Let’s discuss what POCO classes we use as inputs and outputs in PredictionEngine. <em>YoloV4BitmapData</em> is trivial:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*FAhgJHJ9smECB9Ihv2SXmg.png" /></figure><p>However the output class, <em>YoloV4Prediction</em> is not.</p><p>A few short comments on the most vivid elements of the prediction class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*05DdWNeEleVM84CqjnsS_w.png" /></figure><p>Anchors are the common aspect in object detection. Their use is not limited to YOLO set of algorithms. Anchors define the scale and the form using which the ML algorithm will try to identify objects on the input image. Fine tuning the anchors enables a model to be more effective at predicting objects. In our case, we just know which anchors are used with YOLOv4 and map those in .NET types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mmsT_5NUXKeR36FpudcIsw.png" /></figure><p>Strides are also a common concept, defining the “step” between bounding boxes. Since the detection of objects relies in YOLOv4 on a level of concentration of the potential bounding boxes determined by each “predictor” within a model, stride configuration also influences if some objects are detected or skipped during the detection. In our “Results parsing class” strides are required to derive a bounding box that can be overplayed to an original input image.</p><p>XYScale parameter is used to be able to determine the real bounding boxes of an object that has been detected, given that the prediction output from the model is originally can’t be mapped 1-to-1 to an input image. Since we want to draw a detected object box on an input image, we need to know this value for the model.</p><p>Shapes variable is also predefined for YOLOv4 and is used during results parsing.</p><p>The <em>GetResults </em>of the <em>YoloV4Prediction</em> class is where the actual “parsing” of the model output happens, so at the end we can make “normal C# bounding boxes” for predicted objects available to the calling application code.</p><p>After our code in <em>GetResults</em> parses the “model-native” prediction information, we get a rather clean-looking POCO class instance — an instance of <em>YoloV4Result</em> class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNEbXy2xSKES_7PaVgsyVA.png" /></figure><p>With the properties of that class we can easily “use” that data in the application, it basically tells us where the detected objects are, what is the class label (what type of the object is detected) and how confident the model was about this prediction.</p><p>While there still is a part of the demo application that we haven’t broken down into details, I believe it is a rather trivial part of objects and data manipulations that are clear to a .NET engineer. As for ML part, I think we have covered the practical aspects of using a third-party ML model for object detection and how it maps to ML.NET primitives.</p><h3>Conclusions</h3><p>ML.NET 1.6 is already a rather mature ML framework. It allows us to natively automate a variety of ML tasks, stick to the managed code and in the recent version even choose if we want to bind our work to the GPU or the CPU.</p><p>In a future article I will try to focus on enhancing an object detection model with own training data using ML.NET.</p><h4>Links</h4><p>Source code for a reviewed examples:</p><ul><li>Text Sentiment Analysis — <a href="https://github.com/maxpavlov/basic-mlnet-sentiment-classification">GitHub repo</a></li><li>YOLOv4 Object detection — <a href="https://github.com/maxpavlov/ml-object-detection">GitHub repo</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55d7efb7968" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Jeff Bezos sells AWS to .NET startups with the help of Blue Origin’s tickets to space?]]></title>
            <link>https://maxpavlov.medium.com/how-jeff-bezos-sells-aws-to-net-startups-with-the-help-of-blue-origins-tickets-to-space-5ff8261510c0?source=rss-6e2a6b0825a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ff8261510c0</guid>
            <category><![CDATA[industry-trends]]></category>
            <category><![CDATA[cloud-migration]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Max Pavlov]]></dc:creator>
            <pubDate>Thu, 06 May 2021 21:38:13 GMT</pubDate>
            <atom:updated>2021-05-07T08:12:07.676Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Jeff Bezos sells AWS to .NET startups with the help of Blue Origin’s tickets to space?</h3><p>or why company CTOs sometimes prefer AWS even when there is no rationale to it.</p><p><strong>Once upon a time,</strong> there was a company that operated a legacy Microsoft stack-based solution deployed on-prem (local data center with manual VM management, RDP access for every occasion, all that cool stuff).</p><p>A CTO of that company was considering a migration to a public cloud but didn’t know which one is best for his solution. That CTO asked for advice from his trusted technology partner, stating that only AWS and Azure are being considered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*BL6BHiXBNGiT9kIylOB1Hg.png" /></figure><blockquote><em>Disclaimer: <br>I am not affiliated with AWS in any way. <br>I am a long-time fan of Microsoft Azure. <br>I am still convinced the the client reffered to in this article would have been better off choosing Azure as their public cloud hosting environment.</em></blockquote><p>Our client was looking for an intelligent suggestion on which public cloud to choose. The client was recently acquired by a large IT conglomerate, so their parent company had both partnerships in place, with AWS and Microsoft Azure.</p><p>As we knew that the client was operating and in fact expanding his deeply legacy Microsoft stack-based solution, a cloud migration, and some platform upgrades were long overdue.</p><p>We have quickly assembled a working group to present both cloud migration options. The process involved investigating what components make up a solution, what was the overall architecture we were dealing with, deciding how to migrate, and mainly — where to.</p><p>A few meetings have passed, we learned that the client would like to immediately shift from the existing on-prem hosting environment due to reliability concerns, thus we decided to go with a “lift-and-shift” as the first phase suggested.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PL6fTiAGMx8D_hBExwkk1w.jpeg" /><figcaption>Photo by Wolfe House &amp; Building Movers — wolfehousebuildingmovers.com, CC BY-SA 1.0</figcaption></figure><p>Just kidding, the solution was not that “legacy”.</p><p>The client also mentioned that the overall hosting cost after the migration would be a concern, as he considered the on-prem option unreliable but cheap, and wasn’t willing to create a budgeting problem for the ongoing financial year.</p><p>The target at that point became clear — everything needs to be done fast: initial migration, move towards cloud-nativeness, arriving at an optimal cloud cost.</p><blockquote>At that point we assumed that cloud-native would mean “more cost-effective” in that particular, and in fact most, of the cases. I still believe that well-built cloud-native solutions can leverage the benefits of the economies of scale presented by PaaS offerings better than those that rely more on IaaS offerings (aka permanently running virtual machines with custom setups on them). <br>Fully cloud-native solutions are more technologically homogenious and thus DevOps pipelines serving change to such environements are more clear, predictable and thus the system is more reliable as a whole. It all depends on a proper quality control and implementation, of course.</blockquote><p>Four business days and one weekend away from an initial request we were ready to present our vision of “fast and dirty” migration phases, along with the side-to-side comparison of how his solution would happen in both AWS and Azure.</p><p>Here is what we assumed two paths would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJp_rhYJLPZADRJ_-8TgoQ.png" /></figure><p>Note that those items that appear as simple boxes with text in them represent some module that has to be hosted on an IaaS instance, thus costing more, than its colored counterpart, which represents a cloud-native PaaS offering instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*w7mcTfNjTsr5hatyXmU_4g.png" /></figure><p>We suggested we start with a simple “lift-and-shift” meaning we will stand up an instance of the solution on the VMs in the cloud, migrate the production data, and then at some point switch the production workload to a cloud instance, abandoning on-prem hosting.</p><p>Then we would do a series of commando-like redesigns aimed at converting more and more of the solution to run on cloud-native offerings in both clouds.</p><p>We were explicit with our assumption, that if we throw approximately the same amount of effort as we move from one stage to another, we would achieve a target cloud-nativeness with Azure much sooner. Mainly because some Azure PaaS offerings were (and still are) built “on top” of the same native Windows components as the legacy solution was using while being hosted on-prem. Microsoft has just done an amazing job of “wrapping them up” into a PaaS resource type in Azure while giving it some taste of auto-scaling and thus making them more cost-effective.</p><p>Basically, our message to the client was: you literally will spend less time, effort, and money if you choose Azure for hosting your solution.</p><p>The point of our suggestion was not to claim that we offered a most well-thought-through solution with those two paths, we actually don’t think we did. But it was a simple display of what the client could expect from each public cloud short term, considering the constraints we had declared.</p><p>As you might have probably guessed, the client said “wow, thank you, I need to think about it”. And in a few days came back stating they decided to go with AWS. His parent company stakeholders saw AWS as a better long-term strategy for the entire conglomerate, so they weren’t so much after the immediate rationale after all. Those “almost-forever-IaaS” components (in case of moving to AWS) were fine to be kept in costly containers, while things like CDN and the databases could become cloud-native in AWS almost just as early as they could have in Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*63ZkX23JskK_a5mHp48-Hw.png" /></figure><p>We obviously didn’t argue or challenged this decision in any way. Over time I simply forgot about this case as most of our clients come in having some infrastructure already in one cloud or another. The case that had me recall all this and write the article happened just recently in spring 2021 — a prospect looking to expand its development capacity with my employer told me a so-familiar story — a legacy .NET solution, big plans of cloud migration, AWS, and only AWS. This time I had a chance to ask emotionally — “but why?”. The response was yet again very distant from pure technical feasibility — “In the industry, we operate in <em>(which is gambling/gaming)</em>, it is a matter of reputation to be hosted in AWS. All of our competitors are there”.</p><p>It seems in both cases the underlying reasoning behind the decision is — AWS is simply winning by its brand. Whether it’s Jeff Bezos contributing to AWS&#39;s reputation by his other successful and visionary endeavors, or a well-established national or industry tradition, more and more .NET-based solutions are getting hosted in AWS, despite often having a chance to land in a more comfy home of Azure. Whether this trend is to stay and expand or fade away over time, we are yet to see. With Microsoft basically succeeding in making modern .NET cross-platform, AWS’s advantage over Azure is growing even more rapidly. I wonder what my favorite cloud would do to challenge the strong contender.</p><p>I would like to hear your opinion on the topic, my dear readers, please be welcome to comment. Maybe I am missing an “elephant in the room” and AWS is being chosen not because it is trendy, but because it has something better out of the box that Azure is lacking? Anything that you disagree or agree with — happy to hear and discuss.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ff8261510c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>