<?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 PonEzhil on Medium]]></title>
        <description><![CDATA[Stories by PonEzhil on Medium]]></description>
        <link>https://medium.com/@connect.ponezhil?source=rss-f8eb9c0a097d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hN0cldU_T2Sa9ocK</url>
            <title>Stories by PonEzhil on Medium</title>
            <link>https://medium.com/@connect.ponezhil?source=rss-f8eb9c0a097d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:41:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@connect.ponezhil/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[Confusion Matrix -Getting Enlightenment on ML Model Performance]]></title>
            <link>https://medium.com/@connect.ponezhil/confusion-matrix-getting-enlightenment-on-ml-model-performance-273c20961da6?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/273c20961da6</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 16:31:41 GMT</pubDate>
            <atom:updated>2026-11-15T16:31:41.698Z</atom:updated>
            <content:encoded><![CDATA[<p>As in our day-to-day life,</p><p>“Confusion augments learning if it is properly induced and effectively regulated.”</p><p>Confusion Matrix in a machine learning space augments our understanding of classification model performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*JO8dYcsiHL-m_lHs.gif" /><figcaption>WEIRD?</figcaption></figure><p>Feel so it is Weird? Let me explain in detail.</p><p>Firstly, we must understand what classification in machine learning is-</p><p>Classification is a supervised machine learning method where the model tries to predict the correct label of a given input data. In classification, the model is fully trained using the training data, and then it is evaluated on test data before being used to perform prediction on new unseen data.</p><p>For Example, consider a spam mail detection model as per the below image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4gsCDS9DytmXhza2" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=273c20961da6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP vs UTCP: Does Your AI Agent Need a Middleman to Call a Tool?]]></title>
            <link>https://medium.com/@connect.ponezhil/mcp-vs-utcp-does-your-ai-agent-need-a-middleman-to-call-a-tool-1a8181fc750f?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a8181fc750f</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 16:12:19 GMT</pubDate>
            <atom:updated>2026-11-15T16:19:12.988Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YA60A-2zoAj0pBydot65fg.png" /></figure><p><em>MCP gave agents one standard way to use tools. UTCP asks whether that standard has to sit in the middle of every call.</em></p><p>Every useful AI agent eventually has to <em>do</em> something: check the weather, query a database, open a pull request. A language model on its own can only produce text, so “doing” means calling a tool. How an agent finds a tool, learns how to use it, and calls it has become one of the most argued-about layers of the AI stack.</p><p>This article walks through three stages: the mess before the <strong>Model Context Protocol (MCP)</strong>, the problems MCP solved and the new ones it created, and how the <strong>Universal Tool Calling Protocol (UTCP)</strong> approaches those problems differently. Halfway down there is an interactive sequence diagram that runs the same request, <em>“What’s the weather in Chennai?”</em>, through both protocols so you can see exactly where they differ.</p><h3>1. Before MCP: every integration was hand-made</h3><p>In 2023 and most of 2024, giving an LLM a tool meant writing glue code inside your application. You described the function in your model vendor’s format (OpenAI function calling, Anthropic tool use, a LangChain Tool class), parsed the model&#39;s output, made the API call yourself and pasted the result back into the conversation.</p><p>That worked for a single app with a few tools. It broke down as soon as there were many of both.</p><ul><li><strong>The N × M problem</strong>N AI apps that each want M tools need N × M separate integrations. A GitHub integration written for one chatbot could not be reused by another.</li><li><strong>Vendor-specific schemas</strong>Each model provider and framework described tools slightly differently, so switching models meant rewriting tool definitions.</li><li><strong>No discovery</strong>Tools were hard-coded at build time. An agent had no standard way to ask “what can you do?” at runtime.</li><li><strong>Duplicated, inconsistent effort</strong>Auth, error handling and result formatting were reinvented in every codebase, with uneven quality and security.</li></ul><h3>2. What MCP fixed</h3><p>Anthropic released MCP in November 2024 as an open standard, often described as “USB-C for AI tools”. It defines three roles:</p><ul><li><strong>Host</strong>: the AI application the user talks to (Claude Desktop, an IDE, your own agent).</li><li><strong>MCP client</strong>: a connector inside the host that holds one session with one server.</li><li><strong>MCP server</strong>: a separate process that exposes <em>tools</em>, <em>resources</em> and <em>prompts</em> over JSON-RPC 2.0, via stdio for local servers or Streamable HTTP for remote ones.</li></ul><p>Write a tool once as an MCP server and any MCP-compatible host can use it. N × M integrations become N + M. Discovery is built in (tools/list), schemas are uniform, and the ecosystem took off: thousands of servers now exist for GitHub, Slack, Postgres, file systems, browsers and more.</p><h3>3. Where MCP hurts</h3><p>MCP solved the standardization problem by putting a server in front of every tool. That server is also the source of most complaints from teams running MCP in production.</p><ul><li><strong>The wrapper tax : </strong>Most tools already exist as REST APIs, CLIs or gRPC services. To make one usable over MCP you write, deploy, version and monitor a new server whose only job is to translate MCP calls into the API calls that already worked.</li><li><strong>An extra hop on every call : </strong>Agent → MCP server → real API → MCP server → agent. For remote servers that is an extra network round trip, an extra point of failure and extra serialization on every single tool call.</li><li><strong>Re-implemented auth and security</strong>The API already has keys, OAuth scopes and rate limits. The MCP server must hold credentials of its own and re-expose access through MCP’s own authorization layer. Two security models now have to agree, and the server becomes a valuable target holding secrets.</li><li><strong>Lost native features : </strong>Caching, streaming formats, pagination and error codes from the underlying API get flattened into MCP’s generic content blocks unless the wrapper author carefully preserves them.</li><li><strong>Stateful sessions : </strong>MCP sessions start with an initialize handshake and capability negotiation. That is useful for rich interactions but makes horizontal scaling and serverless deployment harder than stateless HTTP.</li><li><strong>The tool owner has to adopt MCP : </strong>If the API provider never ships an MCP server, someone else wraps it, and you now depend on a third-party process that sits between you and the API.</li></ul><h3>4. UTCP: a manual instead of a middleman</h3><p>UTCP, an open-source protocol that appeared in mid-2025, keeps MCP’s good idea (one standard way to describe and discover tools) and drops the server in the middle. Its slogan sums it up:</p><blockquote>If a human can call your API, an AI agent should be able to call it too, with the same security and no extra infrastructure.</blockquote><p>Instead of running a wrapper, a tool provider publishes a <strong>UTCP manual</strong>: a JSON document listing each tool, its input and output schema, and a <strong>call template</strong> that says how to call it with the protocol it already speaks (HTTP, CLI, gRPC, GraphQL, WebSocket, server-sent events, even MCP itself). The UTCP client reads the manual once, then calls the real endpoint directly.</p><ul><li><strong>No wrapper server:</strong> The manual can be served from an endpoint like /utcp or just be a JSON file in your repo.</li><li><strong>Native auth:</strong> The client sends the same API key or OAuth token a human developer would use, so existing rate limits, audit logs and permissions apply unchanged.</li><li><strong>One hop:</strong> The tool call goes straight from agent to API and the response comes back as the API sent it.</li><li><strong>Protocol-agnostic:</strong> A command-line tool is described as a CLI call template; a gRPC service as a gRPC template. Nothing has to be rewritten in a new transport.</li></ul><h3>Same request, two protocols: “What’s the weather in Chennai?”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rqi0O-sGB9s2ew3iRen1Fw.png" /><figcaption>MCP Sequence diagram</figcaption></figure><p>UTCP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDB-sv3VpuckN56FzH52xw.png" /><figcaption>UTCP Sequence Diagram</figcaption></figure><p>See the difference in the mechanism now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*viERBbLdStjIgQLFohvoxQ.png" /></figure><h3>5. What the diagram shows</h3><p>Both flows have the same three phases: <strong>discover</strong> the tools, let the <strong>LLM decide</strong> which one to call, then <strong>execute</strong> the call. The difference is entirely in who executes it and where the credentials live.</p><ul><li>In MCP, discovery happens over a JSON-RPC session with the server (initialize, then tools/list). Execution is tools/call to the server, which makes the real HTTP call using <em>its own</em> stored API key and wraps the answer in MCP content blocks. The tool call costs four legs: client → server → API → server → client.</li><li>In UTCP, discovery is a plain GET /utcp that returns the manual. Execution is the client filling the call template, injecting the API key from its own environment, and calling the weather API directly. The tool call costs two legs: client → API → client.</li></ul><p>From the LLM’s point of view the two are almost identical. It sees a tool named get_weather with a city argument either way. Everything that changes is plumbing, which is exactly why it matters for latency, cost and operations.</p><h3>6. The same tool in code</h3><h3>MCP You write and run a server</h3><p>Using the official Python SDK, the wrapper is short, but it is a new service you must host, secure and keep alive:</p><pre># weather_server.py  (a new process you deploy)<br>import os, httpx<br>from mcp.server.fastmcp import FastMCP</pre><pre>mcp = FastMCP(&quot;weather&quot;)</pre><pre>@mcp.tool()<br>async def get_weather(city: str) -&gt; dict:<br>    &quot;&quot;&quot;Current weather for a city.&quot;&quot;&quot;<br>    async with httpx.AsyncClient() as client:<br>        r = await client.get(<br>            &quot;https://api.example-weather.com/v1/current&quot;,<br>            params={&quot;city&quot;: city},<br>            headers={&quot;X-API-Key&quot;: os.environ[&quot;WEATHER_API_KEY&quot;]},<br>        )<br>        return r.json()</pre><pre>if __name__ == &quot;__main__&quot;:<br>    mcp.run()   # stdio by default; Streamable HTTP for remote use</pre><h3>UTCP You publish a JSON manual</h3><p>The API keeps running exactly as it is. You describe it once:</p><pre>{<br>  &quot;utcp_version&quot;: &quot;1.0.1&quot;,<br>  &quot;manual_version&quot;: &quot;1.0.0&quot;,<br>  &quot;tools&quot;: [{<br>    &quot;name&quot;: &quot;get_weather&quot;,<br>    &quot;description&quot;: &quot;Current weather for a city.&quot;,<br>    &quot;inputs&quot;: {<br>      &quot;type&quot;: &quot;object&quot;,<br>      &quot;properties&quot;: { &quot;city&quot;: { &quot;type&quot;: &quot;string&quot; } },<br>      &quot;required&quot;: [&quot;city&quot;]<br>    },<br>    &quot;tool_call_template&quot;: {<br>      &quot;call_template_type&quot;: &quot;http&quot;,<br>      &quot;url&quot;: &quot;https://api.example-weather.com/v1/current&quot;,<br>      &quot;http_method&quot;: &quot;GET&quot;,<br>      &quot;auth&quot;: {<br>        &quot;auth_type&quot;: &quot;api_key&quot;,<br>        &quot;api_key&quot;: &quot;${WEATHER_API_KEY}&quot;,<br>        &quot;var_name&quot;: &quot;X-API-Key&quot;,<br>        &quot;location&quot;: &quot;header&quot;<br>      }<br>    }<br>  }]<br>}</pre><p>On the agent side, a UTCP client registers the manual and calls the tool. The ${WEATHER_API_KEY} placeholder is filled from the agent&#39;s own environment, so the secret never sits in a middle server:</p><pre>from utcp.utcp_client import UtcpClient</pre><pre>client = await UtcpClient.create(config={<br>    &quot;manual_call_templates&quot;: [{<br>        &quot;name&quot;: &quot;weather&quot;,<br>        &quot;call_template_type&quot;: &quot;http&quot;,<br>        &quot;url&quot;: &quot;https://api.example-weather.com/utcp&quot;,<br>        &quot;http_method&quot;: &quot;GET&quot;,<br>    }]<br>})</pre><pre>result = await client.call_tool(&quot;weather.get_weather&quot;, {&quot;city&quot;: &quot;Chennai&quot;})</pre><h3>7. Side by side</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*VzLcOsFjo-sEWq_QtgkFnQ.png" /></figure><h3>8. UTCP is not a free lunch</h3><p>A fair comparison has to cover what you give up.</p><ul><li><strong>Secrets move to the agent.</strong> Removing the middle server means the client holds API keys. In a desktop agent or multi-tenant platform that may be the wrong place for them, and a server is a natural spot for a policy and audit layer.</li><li><strong>Fatter clients.</strong> An MCP client speaks one protocol. A UTCP client needs plugins for every transport it might be asked to call.</li><li><strong>Less than MCP offers.</strong> MCP’s resources, prompts, sampling and server-pushed notifications have no direct UTCP equivalent.</li><li><strong>Prompt injection still applies.</strong> A malicious tool description or response is dangerous in both protocols. UTCP doesn’t remove the need to review which manuals your agent trusts.</li><li><strong>Ecosystem gravity.</strong> MCP is supported by every major AI vendor. UTCP adoption is much smaller, though it can call MCP servers through its MCP call template, so the two can coexist.</li></ul><h3>9. Which should you use?</h3><p>Reach for MCP when you need rich, stateful interactions (resources, prompts, sampling), when you want a central server to own credentials and policy, or when you are targeting hosts like Claude Desktop, ChatGPT or IDEs that already speak it.</p><p>Reach for UTCP when the tools you need already exist as well-secured APIs or CLIs, when latency and operational overhead per call matter, and when you would rather publish a JSON file than run another service.</p><p>The bigger lesson is that “how should an agent call a tool?” is still an open design question. MCP answered it with a <em>protocol in the middle</em>. UTCP answers it with a <em>description at the edge</em>. Many production systems will end up using both.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a8181fc750f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airport Help Desk Kiosk with a Face: Building a Talking Avatar with Ditto and Amazon Nova Sonic]]></title>
            <link>https://medium.com/@connect.ponezhil/airport-help-desk-kiosk-with-a-face-building-a-talking-avatar-with-ditto-and-amazon-nova-sonic-b1f8bdff069a?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1f8bdff069a</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 16:32:18 GMT</pubDate>
            <atom:updated>2026-11-08T16:32:18.084Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a single portrait photo, a speech-to-speech model and an open-source talking-head network became a virtual airport guide that answers out loud, with lips that move to the words.</em></p><p><strong>The idea</strong></p><p>Airport information desks get the same questions all day:</p><p><strong>Where is gate C22?</strong></p><p><strong>Is there a prayer room?</strong></p><p><strong>How do I get to the metro?</strong></p><p>I wanted to build a kiosk that answers them the way a person would:</p><p>you <strong>talk </strong>to it, and a <strong>face </strong>talks back.</p><blockquote>The result is <strong>Airport Avatar! </strong>an app I built for a fictional airport. Through this app a traveller speaks or types a question, and a few seconds later a portrait in an office setting answers in a natural voice, lip-synced, with the source documents shown under the answer.</blockquote><p><strong>Building Blocks</strong></p><p><strong>1.Amazon Nova Sonic </strong>(on Bedrock) | Hears the question, calls the search tool, speaks the answer. | in AWS Cloud |</p><p><strong>2.RAG over airport documents</strong> (Chroma dB) | The <strong>only </strong>place facts may come from | Laptop GPU (RTX 4050, 6 GB) |</p><p><strong>3</strong>. <strong>Ditto </strong>(open-source talking-head model) | Turns the answer audio and one photo into a talking video | Laptop GPU (RTX 4050, 6 GB) |</p><h4><strong>One question, from voice to talking face</strong></h4><p>The animation below walks through a single question end to end. The blue arrows carry the question, yellow is the RAG search, green is the spoken answer, and pink is the talking face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gDYN0snSmB-WlcMHSajgA.gif" /><figcaption>Sequence diagram: one question travels from the traveller through the Streamlit app and FastAPI backend to Nova Sonic, which calls the RAG search, speaks the answer, and Ditto renders it into a talking video</figcaption></figure><p><strong>Step by Step:</strong></p><p>1. <strong>Ask a question. </strong>The traveller speaks (or types) in the Streamlit app.</p><p><strong>2. Send to the backend.</strong> The app streams the audio over a WebSocket to a FastAPI backend in 100 ms frames of 16 kHz mono PCM.</p><p><strong>3. Stream to Nova Sonic. </strong>The backend opens one bidirectional stream to Nova Sonic on Amazon Bedrock.</p><p><strong>4. Nova calls the tool.</strong> Nova transcribes the question and decides to call <em>search_airport</em>.</p><p><strong>5.Guard, then search.</strong> A rule guard runs first (no live flight status, fares, visas or medical advice), then ChromaDB is searched.</p><p><strong>6.Return the evidence.</strong> Up to 4 chunks scoring 0.79 or higher come back, or nothing at all.</p><p><strong>7.Send the tool result.</strong> The chunks and their source file names go back to Nova.</p><p><strong>8.Nova answers.</strong> Nova speaks one short sentence built only from those chunks, and sends the text alongside it.</p><p><strong>9.Return to the app.</strong> The answer text and sources appear in the chat, and the 24 kHz answer audio arrives.</p><p><strong>10.Start the render.</strong> The answer audio and the portrait go to Ditto on the GPU.</p><p><strong>11.Video comes back</strong>. Ditto returns a lip-synced MP4 at 12.5 fps.</p><p><strong>12.The guide speaks.</strong> The video fades in over the still portrait, with its sources shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8JjmILKrOvgKJNux1TZJOA.png" /><figcaption>Side Paths</figcaption></figure><p>There are also three side paths. If the search finds <strong><em>nothing relevant</em>,</strong> the guide says it doesn’t know and shows no sources. A <strong><em>blocked question</em></strong> gets a fixed, polite refusal. A <strong><em>repeated question </em></strong>plays a saved clip straight away, with no new render.</p><p><strong>Why Amazon Nova Sonic?</strong></p><p>The usual way to build a voice assistant is to chain three models together: speech-to-text, then a language model, then text-to-speech. Every hop adds latency, and every hop is another service to configure, keep in sync and debug.</p><blockquote><strong>Amazon Nova Sonic</strong> replaces that whole chain with one speech-to-speech model on a single bidirectional stream.</blockquote><p>It hears the audio, understands it, decides on its own when to call my <em>search_airport </em>tool, and speaks the answer in a natural voice. With one model, the first words of the answer arrived about <em>1.5 to 2.4 seconds</em> after the traveller stopped talking, which matters a lot when a slow avatar render still has to follow.</p><p>Built-in tool use also made grounding much simpler:</p><p>Nova calls the retrieval tool itself, so I could put the safety guard <strong>inside </strong>the tool and make the documents the only source of facts. One polyglot voice (`mathew`) covers English and Hindi without switching voices. Because it runs on Amazon Bedrock, the AWS credentials stay on the server and never reach the browser.</p><p>Only the question audio and the retrieved text leave the laptop; the face images never do. For a kiosk that has to sound human, stay fast and stay honest, one managed speech-to-speech model was the simplest design.</p><p><strong>Making Ditto fast enough on a laptop GPU</strong></p><p>Nova is quick. <em>The face is the slow part. </em>Ditto creates motion from HuBERT audio features with a diffusion model, then warps and decodes every frame from the source photo. On a 6 GB laptop GPU, the first version took many times longer to render than the answer took to say. Four changes made the biggest difference:</p><ol><li><strong>Half the frames, same lip sync</strong>. Ditto produces 25 motion frames per second of speech. In “fast mode” the app still <strong><em>generates </em></strong>all 25, but only warps, decodes and writes every second one, giving a 12.5 fps video. The video stays exactly as long as the audio, so the lips stay in sync.</li></ol><p>convert = sdk.audio2motion.cvt_fmt</p><p>sdk.audio2motion.cvt_fmt = lambda seq: convert(seq)[::DITTO_FRAME_STEP] # every 2nd frame</p><p>sdk.writer = VideoWriterByImageIO(sdk.tmp_output_path, fps=25 / DITTO_FRAME_STEP)</p><p>2. <strong>Keep the frames on the GPU in fp16.</strong> Upstream Ditto copies each frame’s feature volume (about 8 MB) from the GPU to the CPU and back again, between the warp and decode stages. I replaced both stages with half-precision wrappers that pass the tensor straight through on the GPU, and upload the face’s features only once. That brought the time per frame from about <em>253 ms down to about 190 ms</em>.</p><p><strong>3. Stop ONNX threads from busy-waiting.</strong> HuBERT makes many small ONNX calls, and by default idle threads <strong>spin </strong>between them, fighting the real work for the laptop CPU. Turning spinning off produced bit-identical features <em>about 2.7× faster</em>.</p><p>sess_options.add_session_config_entry(“session.intra_op.allow_spinning”, “0”)</p><p><strong>4. Keep answers short and cache them.</strong> Every second of speech costs several seconds of rendering, so Nova <strong>is told to answer in one sentence of about 20 words. </strong>Finished clips are saved under a hash of the normalised question, the portrait, the render settings and <strong>every airport document</strong>. If a document changes, old clips stop matching automatically. For a spoken repeat, the app closes the Nova stream as soon as the transcript matches a saved clip, which cancels the rest of Nova’s turn, and the saved video plays at once.</p><p>The models load and warm up when the page opens, not on the first question, so the first traveller doesn’t pay for the cold start.</p><h3><strong>A face that belongs to the kiosk, or to you</strong></h3><p>The default avatar is a portrait of a person who agreed to be the kiosk’s face. Travellers can also use their <strong>own face:</strong></p><p>- The webcam’s <strong>OK </strong>button stays disabled until the consent box (“Your image will be used for the avatar”) is ticked.</p><p>- Ditto’s own face detector finds the largest face, and the photo is cropped square around it.</p><p>- Google’s <strong>MediaPipe selfie segmenter</strong> cuts the person out, and they are placed in front of an office background, so every avatar looks like it is standing behind the same desk.</p><p>- <strong>A visitor’s face is never saved.</strong> Their portrait, video and temporary files are deleted after each answer, and their clips are never cached.</p><p><strong>The user experience details that mattered</strong></p><p>- <strong>Push-to-talk that forgives.</strong> The button keeps recording for 300 ms after release so the last word isn’t cut off, and rejects taps shorter than 400 ms.</p><p>-<strong>Catch silent microphones early.</strong> A recording quieter than about −40 dBFS is rejected <strong>before </strong>calling Nova, with a clear “check your microphone” message instead of a vague failure.</p><p>-<strong> No blank flash.</strong> The portrait is both the stage background and the video’s poster, so the switch from still photo to talking video is a smooth fade.</p><p>-<strong>Typed and spoken questions sound the same.</strong>Typed questions also go through Nova Sonic, so both share one voice and one clip cache.</p><p><strong>Leasons Learned</strong></p><p><strong>1.The avatar, not the language model, sets your latency budget. </strong>Design the whole conversation, prompt included, around how long the face takes to render.</p><p><strong>2.A speech-to-speech model makes grounding a tool-design problem.</strong> The answer is spoken before you can check it, so the guardrails have to live inside the tool the model calls.</p><p><strong>3. Profile before you optimise.</strong> The big wins (CPU↔GPU copies, ONNX thread spinning) were nowhere near where I expected the time to go.</p><p><strong>4.Privacy is a feature you build, not a disclaimer.</strong> Consent before capture, no saved faces, and only audio and text leaving the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VV44LqjVh4mdhdx-0pKQ1Q.png" /></figure><p><strong>Wrapping up</strong></p><p>Airport Kiosk Avatar shows that a natural, grounded talking assistant can run on one gaming laptop plus one managed AWS model: Amazon Nova Sonic for hearing and speaking, a small RAG index for facts, and Ditto for the face. If you’re building something similar, start with the sequence diagram above. Every arrow in it is a place where latency, accuracy or privacy can be won or lost.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1f8bdff069a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prompt Optimization: The Hidden Skill Behind Better AI Results]]></title>
            <link>https://medium.com/@connect.ponezhil/prompt-optimization-the-hidden-skill-behind-better-ai-results-78f7ba71e79d?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/78f7ba71e79d</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Fri, 22 May 2026 15:09:31 GMT</pubDate>
            <atom:updated>2026-05-22T15:09:31.990Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence (AI) has rapidly moved from a futuristic concept to a daily productivity partner. Whether you’re writing emails, generating code, analyzing data, automating workflows, or creating business strategies, tools like ChatGPT, Claude, Gemini, and Copilot are transforming the way we work.</p><p>Yet many people experience inconsistent AI results.</p><p>Sometimes the output is brilliant. Other times, it feels generic, inaccurate, or completely disconnected from what was expected.</p><p>The difference often comes down to one overlooked skill:</p><p><strong>Prompt Optimization.</strong></p><p>Prompt optimization is the art and science of designing inputs that guide AI systems toward better, more accurate, and more useful responses.</p><p>Think of it this way:</p><blockquote>AI is powerful, but prompts determine how effectively that power is used.</blockquote><p>In this article, we’ll explore what prompt optimization is, why it matters, proven frameworks, real-world examples, and advanced strategies that can significantly improve AI outcomes.</p><h3>What is Prompt Optimization?</h3><p>Prompt optimization is the process of refining instructions given to an AI model to improve:</p><ul><li>Accuracy</li><li>Relevance</li><li>Clarity</li><li>Consistency</li><li>Context awareness</li><li>Actionable output</li></ul><p>A <strong>prompt</strong> is simply the instruction you provide to an AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDDTdgcZnsHr5W1ddWIV5g.png" /><figcaption>PROMPT OPTIMIZATION</figcaption></figure><h3>Basic Prompt Example</h3><p><strong>Weak Prompt:</strong></p><blockquote><em>Explain cloud computing.</em></blockquote><p>This is vague. The AI has no context about the audience, detail level, or objective.</p><h3>Optimized Prompt</h3><blockquote><em>Explain cloud computing for beginners using simple analogies and real-world examples in under 300 words.</em></blockquote><p>Notice the difference?</p><p>The second prompt includes:</p><ul><li>Audience</li><li>Style</li><li>Constraints</li><li>Output expectation</li></ul><p>As a result, the response becomes far more targeted.</p><p>Prompt optimization is essentially <strong>communicating with AI in a structured and intentional way</strong>.</p><h3>Why Prompt Optimization Matters</h3><p>Many users blame AI when results are poor.</p><p>But in reality:</p><blockquote><strong><em>Low-quality prompts often produce low-quality answers.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_njRynV0QxI5QyDzkfeFmg.png" /><figcaption>A well-optimized prompt can dramatically improve outcomes.</figcaption></figure><h3>Benefits of Prompt Optimization</h3><h3>1. Better Accuracy</h3><p>Specific instructions reduce ambiguity.</p><p>Instead of:</p><blockquote><em>Summarize this report.</em></blockquote><p>Try:</p><blockquote><em>Summarize this report into 5 key business insights for senior management.</em></blockquote><h3>2. Time Savings</h3><p>A good prompt reduces rework.</p><p>Without optimization:</p><ul><li>Ask prompt</li><li>Get poor answer</li><li>Clarify repeatedly</li><li>Edit manually</li></ul><p>With optimization:</p><ul><li>Ask once</li><li>Receive near-final output</li></ul><h3>3. More Consistent Results</h3><p>Teams using standardized prompts produce predictable outputs.</p><p>This is especially important in:</p><ul><li>IT operations</li><li>Customer service</li><li>Marketing</li><li>Software development</li><li>Data analytics</li></ul><h3>4. Improved Decision Making</h3><p>AI becomes more useful when prompted with context-rich instructions.</p><p>For example:</p><p>Instead of:</p><blockquote><em>Analyze Jenkins logs.</em></blockquote><p>Use:</p><blockquote><em>Analyze the Jenkins build log, identify the root cause of failure, classify severity, and recommend resolution steps with priority.</em></blockquote><p>The output becomes significantly more actionable.</p><h3>The Anatomy of a Good Prompt</h3><p>Effective prompts usually contain five components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mDljzwLm3USCFKdnWeyngw.png" /></figure><h4>1. Role</h4><p>Tell the AI who it should act as.</p><p>Example:</p><blockquote><em>Act as a senior DevOps engineer.</em></blockquote><p>or</p><blockquote><em>Act as an experienced business analyst.</em></blockquote><p>This improves response quality because the AI adopts relevant expertise.</p><h4>2. Context</h4><p>Provide background information.</p><p>Bad:</p><blockquote><em>Improve monitoring.</em></blockquote><p>Good:</p><blockquote><em>We manage enterprise applications for banking customers and must maintain 99.9% SLA. Improve application monitoring using AI.</em></blockquote><p>Context creates relevance.</p><h4>3. Task</h4><p>Clearly state what you want.</p><p>Example:</p><blockquote><em>Analyze the issue and identify root causes.</em></blockquote><p>Avoid vague instructions like:</p><blockquote><em>Help me understand.</em></blockquote><p>Specificity matters.</p><h4>4. Constraints</h4><p>Define boundaries.</p><p>Examples:</p><ul><li>Maximum length</li><li>Bullet points only</li><li>Formal tone</li><li>Beginner-friendly explanation</li><li>Include examples</li></ul><p>Example:</p><blockquote><em>Explain in less than 500 words with practical examples.</em></blockquote><h4>5. Output Format</h4><p>Specify structure.</p><p>Example:</p><blockquote><em>Present the answer in this format:</em></blockquote><ol><li>Problem</li><li>Root Cause</li><li>Resolution</li><li>Prevention Strategy</li></ol><p>This dramatically improves readability.</p><h4>A Simple Framework for Prompt Optimization</h4><p>One of the easiest frameworks is:</p><blockquote><strong>R-C-T-F Formula</strong></blockquote><h4>R — Role</h4><p>Who should AI behave as?</p><p>Example:</p><blockquote>Act as a cybersecurity consultant.</blockquote><h4>C — Context</h4><p>What background information matters?</p><p>Example:</p><blockquote>The application is hosted on AWS and users are experiencing intermittent latency.</blockquote><h4>T — Task</h4><p>What exactly should AI do?</p><p>Example:</p><blockquote>Identify possible root causes and suggest troubleshooting steps.</blockquote><h4>F — Format</h4><p>How should output look?</p><p>Example:</p><blockquote>Provide results in a table with severity levels.</blockquote><h4>Final Optimized Prompt</h4><blockquote>Act as a senior cloud architect.<br>Our banking application hosted in AWS is experiencing intermittent latency during peak hours.<br> Analyze possible root causes and suggest troubleshooting steps.<br> Present results in a table with severity, impact, and recommendation.</blockquote><p>This prompt will outperform generic prompts almost every time.</p><h4>Common Prompting Mistakes</h4><h4>1. Being Too Generic</h4><p>Bad:</p><blockquote><em>Tell me about AI.</em></blockquote><p>Good:</p><blockquote>Explain how AI improves IT operations with real examples.</blockquote><h4>2. Lack of Context</h4><p>Bad:</p><blockquote><em>Fix this issue.</em></blockquote><p>Good:</p><blockquote>A Jenkins pipeline fails during deployment after Docker image build. Analyze likely causes.</blockquote><h4>3. Asking Too Much at Once</h4><p>Bad:</p><blockquote><em>Explain AI, create architecture, write code, deployment strategy, and ROI.</em></blockquote><p>Break complex tasks into smaller prompts.</p><h4>4. No Success Criteria</h4><p>Bad:</p><blockquote><em>Write a report.</em></blockquote><p>Good:</p><blockquote>Write a professional report with executive summary, risks, recommendations, and conclusion.</blockquote><h4>5. Ignoring Iteration</h4><p>Prompt optimization is iterative.</p><p>Your first prompt rarely produces perfection.</p><p>Think of it as:</p><blockquote><strong>Prompt → Evaluate → Refine → Improve</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3NWZSkBr2q2IMBuOymuqg.png" /></figure><h4>Advanced Prompt Optimization Techniques</h4><h4>1. Few-Shot Prompting</h4><p>Provide examples.</p><p>Example:</p><blockquote>Example 1:</blockquote><blockquote>Incident: Database timeout<br> Root Cause: High connection pool usage</blockquote><blockquote>Example 2:<br> Incident: API latency<br> Root Cause: Memory spike</blockquote><blockquote>Analyze this incident similarly.</blockquote><p>This improves consistency.</p><h4>2. Chain-of-Thought Prompting</h4><p>Ask AI to reason step-by-step.</p><p>Example:</p><blockquote>Analyze the problem step by step before giving the final recommendation.</blockquote><p>Useful for:</p><ul><li>Troubleshooting</li><li>Analytics</li><li>Complex reasoning</li></ul><h4>3. Persona Prompting</h4><p>Assign expertise.</p><p>Example:</p><blockquote>Act as a senior enterprise architect with 15 years of banking domain experience.</blockquote><p>This often improves domain relevance.</p><h4>4. Constraint-Based Prompting</h4><p>Add limitations.</p><p>Example:</p><blockquote>Provide only practical solutions that can be implemented within 30 days.</blockquote><p>This prevents unrealistic recommendations.</p><h4>5. Multi-Step Prompting</h4><p>Instead of one large prompt:</p><p>Step 1:</p><blockquote>Identify root causes.</blockquote><p>Step 2:</p><blockquote>Suggest fixes.</blockquote><p>Step 3:</p><blockquote>Create implementation roadmap.</blockquote><p>Better outputs emerge from structured interactions. Advanced Prompt Optimization Techniques</p><h4>1. Few-Shot Prompting</h4><p>Provide examples.</p><p>Example:</p><blockquote>Example 1:<br> Incident: Database timeout<br> Root Cause: High connection pool usage</blockquote><blockquote>Example 2:<br> Incident: API latency<br> Root Cause: Memory spike</blockquote><blockquote>Analyze this incident similarly.</blockquote><p>This improves consistency.</p><h4>2. Chain-of-Thought Prompting</h4><p>Ask AI to reason step-by-step.</p><p>Example:</p><blockquote>Analyze the problem step by step before giving the final recommendation.</blockquote><p>Useful for:</p><ul><li>Troubleshooting</li><li>Analytics</li><li>Complex reasoning</li></ul><h4>3. Persona Prompting</h4><p>Assign expertise.</p><p>Example:</p><blockquote>Act as a senior enterprise architect with 15 years of banking domain experience.</blockquote><p>This often improves domain relevance.</p><h4>4. Constraint-Based Prompting</h4><p>Add limitations.</p><p>Example:</p><blockquote>Provide only practical solutions that can be implemented within 30 days.</blockquote><p>This prevents unrealistic recommendations.</p><h4>5. Multi-Step Prompting</h4><p>Instead of one large prompt:</p><p>Step 1:</p><blockquote>Identify root causes.</blockquote><p>Step 2:</p><blockquote>Suggest fixes.</blockquote><p>Step 3:</p><blockquote>Create implementation roadmap.</blockquote><p>Better outputs emerge from structured interactions.</p><h4>Real-World Applications of Prompt Optimization</h4><h4>IT Operations</h4><p>Prompt:</p><blockquote>Analyze Jenkins logs and identify deployment failures, root cause, SLA impact, and preventive actions.</blockquote><p>Benefits:</p><ul><li>Faster incident resolution</li><li>Reduced downtime</li><li>Better SLA compliance</li></ul><h4>Software Development</h4><p>Prompt:</p><blockquote>Review this code as a senior software architect and identify security, performance, and maintainability issues.</blockquote><p>Benefits:</p><ul><li>Cleaner code</li><li>Reduced defects</li><li>Better architecture</li></ul><h4>Marketing</h4><p>Prompt:</p><blockquote>Write a LinkedIn post about AI adoption for CIOs in a professional tone under 250 words.</blockquote><p>Benefits:</p><ul><li>Audience-specific content</li><li>Better engagement</li></ul><h4>Business Analysis</h4><p>Prompt:</p><blockquote>Analyze KPI performance trends and identify risks, dependencies, and recommendations.</blockquote><p>Benefits:</p><ul><li>Better decision support</li><li>Faster insights</li></ul><h4>Prompt Optimization for Enterprise AI</h4><p>Organizations increasingly standardize prompts to improve consistency.</p><p>This includes:</p><h4>Prompt Libraries</h4><p>Reusable prompts for:</p><ul><li>Incident analysis</li><li>Status reporting</li><li>Documentation</li><li>Customer communication</li></ul><h4>Prompt Templates</h4><p>Instead of reinventing prompts every time:</p><p><strong>Template Example</strong></p><blockquote>Role: [Expert Type]<br> Context: [Business Scenario]<br> Task: [Objective]<br> Constraints: [Limitations]<br> Format: [Output Structure]</blockquote><p>This creates scalable AI usage across teams. Prompt Optimization for Enterprise AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXcxifOPbdhFjpn_MH0l5A.png" /></figure><h3>Final Thoughts</h3><p>Prompt optimization is not about learning complicated tricks.</p><p>It is about <strong>clear communication</strong>.</p><p>The best prompts usually share common characteristics:</p><ul><li>Specific</li><li>Context-rich</li><li>Structured</li><li>Goal-oriented</li><li>Format-driven</li></ul><p>If you improve one thing when working with AI, improve how you ask.</p><p>Because in the AI era:</p><blockquote><strong><em>Better prompts lead to better thinking, faster execution, and smarter outcomes.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78f7ba71e79d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Temperature in AI: The Invisible Dial That Controls Creativity, Accuracy, and Risk]]></title>
            <link>https://medium.com/@connect.ponezhil/temperature-in-ai-the-invisible-dial-that-controls-creativity-accuracy-and-risk-e03fee7f7e30?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e03fee7f7e30</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sun, 10 May 2026 08:08:49 GMT</pubDate>
            <atom:updated>2026-05-10T08:08:49.732Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence models like OpenAI ChatGPT, Google Gemini, and Anthropic Claude often appear magical when they generate human-like responses.<br> But behind every answer lies a mathematical process that decides <em>which word comes next</em>.</p><p>One of the most important — and least understood — controls in this process is <strong>Temperature</strong>.</p><p>Temperature is not about hardware heat.<br> It is a parameter that controls <strong>how predictable or creative an AI model becomes</strong>.</p><p>A low temperature makes the model disciplined and deterministic.<br> A high temperature makes it exploratUnderstanding How AI Generates Text</p><p>Large Language Models (LLMs) do not “think” like humans.</p><p>Instead, they predict the next token based on probabilities.</p><p>A token may be:</p><ul><li>a word</li><li>part of a word</li><li>punctuation</li><li>symbol</li></ul><p>For example:</p><p>Input:</p><blockquote><em>“The sky is”</em></blockquote><p>The model internally predicts probabilities like:</p><p>TokenRaw Scoreblue8.5cloudy6.2green1.1falling0.3</p><p>These raw scores are called <strong>logits</strong>.</p><p>The model must convert these logits into probabilities before selecting the next token.</p><p>This is where temperature enters the system.ory and imaginative.</p><p>In simple terms:</p><blockquote><em>Temperature is the “creativity dial” of an AI model.</em></blockquote><p>But how exactly is this calculated?<br> What happens mathematically inside the model before a word appears on your screen?</p><p>Let’s break it down step by step.</p><h3>Understanding How AI Generates Text</h3><p>Large Language Models (LLMs) do not “think” like humans.</p><p>Instead, they predict the next token based on probabilities.</p><p>A token may be:</p><ul><li>a word</li><li>part of a word</li><li>punctuation</li><li>symbol</li></ul><p>For example:</p><p>Input:</p><blockquote><em>“The sky is”</em></blockquote><p>The model internally predicts probabilities like:</p><p>Token Raw Score</p><p>blue 8.5</p><p>cloudy6.2</p><p>green1.1</p><p>falling0.3</p><p>These raw scores are called <strong>logits</strong>.</p><p>The model must convert these logits into probabilities before selecting the next token.</p><p>This is where temperature enters the system.</p><h3>Step 1: The Model Produces Logits</h3><p>The neural network generates raw numerical scores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*AOa8q3qHnom0fk2GgGTRkA.png" /></figure><p>Example:</p><p>TokenLogitblue8.5cloudy6.2green1.1falling0.3</p><p>Higher logits mean the model believes the token is more likely.</p><p>However, these are not probabilities yet.</p><h3>Step 2: Temperature Adjusts the Logits</h3><p>The logits are divided by the temperature value.</p><p>The formula is:</p><p>zi′=ziTz_i’ = \frac{z_i}{T}zi′​=Tzi​​</p><p>Where:</p><ul><li>zi= original logit</li><li>TTT = temperature</li><li>zi′z_i’zi′​ = adjusted logit</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e03fee7f7e30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Architecture Powering the Future of AI: Mixture of Experts (MoE)]]></title>
            <link>https://medium.com/@connect.ponezhil/the-hidden-genius-behind-modern-ai-understanding-mixture-of-experts-moe-685808e88156?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/685808e88156</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Fri, 08 May 2026 15:27:47 GMT</pubDate>
            <atom:updated>2026-05-08T15:29:54.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence is evolving at an extraordinary pace. Every few months, new AI systems emerge with larger parameter counts, faster reasoning abilities, and more human-like responses. But behind many of these breakthroughs lies a powerful architectural innovation called Mixture of Experts — commonly known as <strong>MoE</strong>.</p><p>MoE is transforming how modern large language models scale, making it possible to build systems that are smarter, faster, and more efficient without requiring impossible amounts of computing power.</p><p>In this article, we’ll explore:</p><ul><li>What MoE really is</li><li>Why traditional AI architectures struggle to scale</li><li>How Mixture of Experts works internally</li><li>Real-world applications</li><li>Advantages and limitations</li><li>Why MoE may define the future of AI</li></ul><h4>The Problem with Traditional AI Models</h4><p>Traditional deep learning models are known as <strong>dense models</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ug4DYbvcZM2xn8W1aa86-A.png" /><figcaption>Traditional AI Models (Pre — MoE)</figcaption></figure><p>In a dense model:</p><ul><li>Every parameter participates in every computation</li><li>Every input activates the entire network</li><li>Computational cost grows dramatically as models become larger</li></ul><p>For example:</p><ul><li>A 10-billion-parameter model uses all 10 billion parameters for every token prediction.</li><li>This becomes extremely expensive in terms of:</li><li>GPU memory</li><li>Training cost</li><li>Energy consumption</li><li>Inference latency</li></ul><p>As companies race toward trillion-parameter AI systems, dense architectures become increasingly inefficient.</p><p>This is where Mixture of Experts changes everything.</p><h3>What Is Mixture of Experts (MoE)?</h3><p>Mixture of Experts is a neural network architecture where only a <strong>small subset of the model</strong> is activated for each task or input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEhR7tDjjn90UIiIt_lL6A.png" /><figcaption>MoE Explained</figcaption></figure><p>Instead of one giant brain handling everything, MoE creates:</p><ul><li>Multiple specialized sub-networks called <strong>experts</strong></li><li>A smart routing mechanism called a <strong>gating network</strong></li></ul><p>The gating system decides:</p><blockquote><em>“Which experts are best suited for this input?”</em></blockquote><p>Only those selected experts process the data.</p><p>This makes the system:</p><ul><li>Computationally efficient</li><li>Scalable</li><li>Specialized</li><li>Faster during inference</li></ul><h4>A Simple Analogy</h4><p>Imagine a hospital.</p><p>Instead of one doctor treating every condition:</p><ul><li>Cardiologists handle heart problems</li><li>Neurologists handle brain disorders</li><li>Orthopedic surgeons handle bone injuries</li></ul><p>A receptionist routes patients to the correct specialist.</p><p>In MoE:</p><ul><li>Experts = specialized doctors</li><li>Gating network = receptionist</li><li>Input = patient request</li></ul><p>The result?<br> Better expertise with lower overall effort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*ZVf4GcxIw9srYAfPUArwFw.png" /><figcaption>Real Life Analogy of MoE</figcaption></figure><h4>Step-by-Step Intuition</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YdVG2glDSjDae6cg.png" /></figure><blockquote><strong>1. Input Enters the Model</strong></blockquote><p>A user gives a prompt like:</p><p><em>“Write Python code for a neural network.”</em></p><p>The system first analyzes the request.</p><blockquote><strong>2. Router (Gate) Chooses Experts</strong></blockquote><p>A small neural network called the <strong>gating network</strong> acts like a smart traffic controller.</p><p>It decides:</p><ul><li>Which experts are most useful</li><li>Which experts should stay inactive</li></ul><p>Example:</p><ul><li>Coding Expert → Selected</li><li>Math Expert → Selected</li><li>Translation Expert → Ignored</li></ul><p>Only a few experts are activated.</p><p>This is called: <strong>Sparse Activation</strong></p><blockquote><strong>3. Selected Experts Process the Task</strong></blockquote><p>The chosen experts independently work on the input.</p><p>Each expert contributes specialized knowledge.</p><p>Think of it like:</p><p><em>Multiple specialists solving different parts of the same problem.</em></p><blockquote><strong>4. Outputs Are Combined</strong></blockquote><p>The model combines responses from selected experts into one final answer.</p><p>The result:</p><ul><li>Faster computation</li><li>Lower GPU cost</li><li>Better specialization</li><li>Massive scalability</li></ul><h4>Why MoE Is Revolutionary</h4><blockquote><strong>1. Massive Scaling Without Massive Cost</strong></blockquote><p>A dense 1-trillion parameter model would be incredibly expensive.</p><p>An MoE model may contain:</p><ul><li>1 trillion total parameters</li><li>But activate only 50 billion per token</li></ul><p>This dramatically reduces computation.</p><blockquote><strong>2. Better Specialization</strong></blockquote><p>Experts can become highly skilled in specific domains.</p><p>Examples:</p><ul><li>Legal reasoning</li><li>Medical analysis</li><li>Scientific computation</li><li>Programming</li></ul><p>This creates more accurate outputs.</p><blockquote><strong>3. Faster Inference</strong></blockquote><p>Since only a fraction of the model is active:</p><ul><li>Less GPU usage</li><li>Faster processing</li><li>Lower latency</li></ul><p>This is critical for real-time AI systems.</p><h4>Real-World AI Models Using MoE</h4><p>Several advanced AI systems already use MoE-style architectures.</p><p>Examples include:</p><ul><li>Switch Transformer</li><li>Mixtral</li><li>DeepSeek-V3</li><li>GShard</li></ul><p>These systems demonstrate how MoE can dramatically increase model capability while controlling costs.</p><h4>Challenges of MoE</h4><p>Despite its advantages, MoE also introduces engineering complexity.</p><blockquote>1. Load Balancing Problems</blockquote><p>Some experts may receive too much traffic while others remain unused.</p><p>This creates:</p><ul><li>Bottlenecks</li><li>Uneven training</li><li>Poor efficiency</li></ul><blockquote>2. Training Complexity</blockquote><p>MoE systems require:</p><ul><li>Advanced distributed training</li><li>Complex routing algorithms</li><li>Careful optimization</li></ul><p>Training them is far more difficult than dense models.</p><blockquote>3. Communication Overhead</blockquote><p>In distributed GPU systems:</p><ul><li>Experts may exist on different machines</li><li>Data transfer between GPUs can become expensive</li></ul><p>Efficient infrastructure is essential.</p><p><strong>MoE vs Dense Models</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bm8nC-UOEhhVO1B9ovjIOw.png" /></figure><h4>Why MoE Matters for the Future of AI</h4><p>As AI systems become larger and more capable, efficiency becomes the defining challenge.</p><p>MoE offers a path toward:</p><ul><li>Smarter AI</li><li>Lower energy usage</li><li>Reduced hardware cost</li><li>Specialized intelligence</li><li>Trillion-parameter systems</li></ul><p>Many researchers believe sparse architectures like MoE represent the future of scalable AI.</p><p>Instead of building one gigantic monolithic intelligence, the future may consist of:</p><blockquote><em>Thousands of collaborating AI specialists working together dynamically.</em></blockquote><h4>Final Thoughts</h4><p>Mixture of Experts is more than just a technical innovation — it is a fundamental shift in how artificial intelligence systems are designed.</p><p>By activating only, the right experts at the right time, MoE enables:</p><ul><li>Better scalability</li><li>Lower costs</li><li>Faster inference</li><li>Greater specialization</li></ul><p>As the AI industry pushes toward increasingly intelligent systems, Mixture of Experts is likely to become one of the most important architectures powering the next generation of machine intelligence.</p><p>The future of AI may not belong to one giant model.</p><p>It may belong to a team of experts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=685808e88156" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Behind AI Recommendations]]></title>
            <link>https://medium.com/@connect.ponezhil/the-secret-behind-ai-recommendations-75863b414e05?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/75863b414e05</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 02:24:41 GMT</pubDate>
            <atom:updated>2026-04-18T02:24:41.779Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine opening Netflix late at night. You don’t know what you want. Just vibes. Something good.</p><p>You scroll.</p><p>And somehow… it already feels like Netflix <em>knows</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IAHwlzD9HlmDjZk6J-9Dw.webp" /></figure><p>Inside Netflix, there isn’t a person watching you. There’s a quiet system — an algorithm — watching patterns.</p><p>Every time you press play, pause, or quit halfway, it takes notes.</p><p>Not in words, but in signals.</p><p>You watched three crime thrillers in a row.<br> You finished one, abandoned another, rewatched a scene in the third.</p><p>The system leans in.</p><p>Interesting…</p><p>It’s all about Similarity.</p><p>Similarity in simple terms is how close two things are in meaning or features.</p><blockquote><strong>Vector Embeddings</strong></blockquote><p><strong>Vector Embedding</strong> is a way to turn something complex — like a word, sentence, image, or even a user — into a list of numbers. That list (a vector) captures meaning in a form that a machine can compare and work with.</p><p>Think of it like this:</p><p>Imagine every word lives somewhere in a giant multi-dimensional space. Words with similar meanings end up close together. So “Dog” and “Cat” are near each other, while “Dog” and “Banana” are far apart. The coordinates of each word in that space — that’s its embedding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*Uj6hy2mp0CZ49MzH.jpg" /></figure><p>We calculate how far and how close two vectors to understand how “Similar” a vector representation is to another vector representation.</p><p>There are three ways of Calculating the distance</p><blockquote><strong>Euclidean Distance</strong></blockquote><p>This is the most familiar one — it’s just straight-line distance.</p><p>It comes from the Euclidean geometry idea of measuring the shortest path between two points.</p><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*SArnXU1iY3qb9s9iVP8NJA.png" /><figcaption>Euclidean Distance</figcaption></figure><p>Imagine two points A (1,2) and B(3,1) on a graph. Draw a straight line between them — that length is the distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*IuOkIqQWuV6DFNbm.png" /></figure><p><strong>When it’s useful:</strong></p><ul><li>When magnitude matters (actual values)</li><li>Clustering problems (like K-means)</li></ul><p><strong>Real Life applications</strong></p><ul><li>Face recognition systems</li><li>GPS Approximate distance</li><li>Medical imaging similarity (MRI, CT scans)</li></ul><blockquote>Manhattan Distance</blockquote><p>It’s named after Manhattan because it reflects how you’d move in a grid of streets — you can’t go diagonally, only along blocks.</p><p><strong>Formula</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*9uv3_L0u8Wl4DDEgmThBhA.png" /><figcaption>Manhattan distance formula</figcaption></figure><p>You walk in steps: right/left and up/down, not diagonally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*9I4WMz-sHY4j5iVDdXeCKQ.png" /></figure><p>consider (x1,x2) : (1,2) and (y1,y2) : (4,6) → distance = |4–1| + |6–2| = 7</p><p><strong>When it’s useful:</strong></p><ul><li>Grid-based systems</li><li>When movement is constrained (like paths in cities)</li></ul><p><strong>Real Life Application</strong></p><ul><li>Ride Hailing- Estimating travel distance for taxis, autos, delivery vehicles</li><li>Robotics in Warehouse -Efficient routing in fulfillment centers</li></ul><blockquote>The Magnitude Problem</blockquote><p>Consider a case where Student A and Student B marks are represented as</p><ul><li>Student A: (50, 60, 70)</li><li>Student B: (100, 120, 140)</li></ul><p>Same relative performance just scaled.</p><ul><li>Euclidean / Manhattan → The Distance will be huge.</li><li>Reality → same trend ✅</li></ul><p>How to solve the issue?</p><p>BINGO!</p><blockquote><strong>Cosine Similarity -Measure distance but <em>angle</em> between vectors</strong></blockquote><p><strong>Cosine similarity</strong> is a metric used to measure how similar two vectors are, regardless of their size. It calculates the cosine of the angle between two vectors projected in a multi-dimensional space.</p><p><strong>Formula</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*2OZ029ZUmuNUAWmRYJQ1yw.png" /></figure><ul><li>Measures how aligned two vectors are</li><li>Ignores magnitude, focuses on direction</li></ul><p><strong>Range:</strong></p><ul><li>1 → identical direction (very similar)</li><li>0 → unrelated</li><li>-1 → opposite</li></ul><p><strong>When it’s useful:</strong></p><ul><li>Text embeddings (very common)</li><li><strong>Recommendation systems</strong></li><li>When scale doesn’t matter, only meaning</li></ul><p><strong>Example:</strong><br> “dog” and “puppy” → high cosine similarity<br> “dog” and “car” → low cosine similarity</p><blockquote>Simple Way to Remember</blockquote><ul><li><strong>Euclidean</strong> → “as the crow flies”</li><li><strong>Manhattan</strong> → “walk through streets”</li><li><strong>Cosine</strong> → “are they pointing the same way?”</li></ul><p><strong>Conclusion</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*DLrTHZZ-RwoDMcJEDBvYHQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75863b414e05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolution of Embeddings in NLP]]></title>
            <link>https://medium.com/@connect.ponezhil/evolution-of-embeddings-in-nlp-2a38012574f8?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a38012574f8</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 17:14:52 GMT</pubDate>
            <atom:updated>2026-04-17T17:14:52.908Z</atom:updated>
            <content:encoded><![CDATA[<p>Natural Language Processing (NLP) has undergone a massive transformation over the years, and one of the core building blocks behind this progress is <strong>embeddings</strong>.</p><blockquote>Embeddings allow machines to understand text by converting words, sentences, or documents into vector representations, where <strong>similar meanings are mapped to nearby points in a vector space</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*pSestPa49O8V043z.jpg" /><figcaption>word’s representation in a vector space</figcaption></figure><p>The above vector space represents similar words Dog, Cat and Wolf (animals) are nearby and Banana and Apple (fruits) are represented nearby.</p><p>For example, the numerical vectors of words might be like</p><p>Banana -&gt; [0.25, -0.13, 0.78, …], Apple -&gt; [0.27, -0.10, 0.80, …]</p><p>Dog -&gt; [-0.75, 0.33, 0.19, …], Cat-&gt; [-0.73, 0.30, 0.20, …]</p><p>which means the more related words have similar vector values or similar embeddings.</p><h3><strong>Evolution of Embeddings in NLP</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRpHxB_RTZL0DeyXKEYZRg.png" /><figcaption>Text to Numbers → Static Embedding → Transfer Learning Embedding → Transformer Based Embedding</figcaption></figure><ol><li><strong>Pre Embeddings -Text to Numbers</strong></li></ol><p>Initially, when there was a need to represent text to numbers <strong>One-Hot Encoding ,Bag of words , TF-IDF </strong>were done. Both were very basic way of representing Text into Numbers.</p><blockquote><strong>ONE HOT ENCODING</strong></blockquote><p>One-hot encoding<strong> </strong>is a simple way to convert text into numbers so computers can understand them.</p><p><strong>Example sentences:</strong></p><ol><li><em>The cat sat on the wall</em></li><li><em>The ball hit the floor</em></li></ol><p>First, list unique words:<br> <strong>[the, cat, sat, on, wall, ball, hit, floor]</strong></p><p>Now encode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*0B4fP5s9nkE858zHs2xigA.png" /></figure><p>We use one hot encoding in ML programs to make the model understand the text in numbers.</p><p><strong>Disadvantages</strong></p><ol><li>Word count within the sample is not covered.</li><li>Word count within the corpus is not covered.</li><li>Word order is not mentioned.</li><li>Did not address the out of vocabulary issue.</li><li>Context is not maintained.</li></ol><p>In short through one hot encoding the system doesn&#39;t understands words how human understands. It works with numbers.</p><blockquote><strong>BAG OF WORDS</strong></blockquote><p>A bag of words is a representation of text that describes the frequency of words within a document. We just keep track of word counts and disregard the grammatical details and the word order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9FIsrTRsIP89CIPBFK-Ag.png" /></figure><p><strong>Example sentences:</strong></p><ol><li>cat sat on mat</li><li>cat ate mat</li></ol><p>Vocabulary set will be { ‘cat’ , ‘sat’ , ‘on’ ,‘mat’ , ‘ate’ } (size — 5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*RpwPtOwXxGZROPyETPzpnw.png" /></figure><p>The numerical representation of the two sentences will be → [2,1,1,2,1].</p><p>BoW checks the frequency of the words in the sentences conclude that the document is related to cat and mat.</p><p>To further dive in,</p><p>Consider the below sentences</p><ol><li>Cat sat on mat.</li><li>cat ate Mat.</li></ol><p>What will be the vocabulary set?</p><p>The sentence are similar with same no of words, but the vocabulary set changes and will be</p><p>{‘Cat’, ‘sat’, ‘on’ , ‘mat’, ‘ . ’ ,‘cat’, ‘ate’, ‘Mat’ }(size — 8)</p><p>The same two sentences with the same meaning have different vocabulary set size 5 and 9 respectively can we guess?</p><p>Yes, it considers ‘Cat’ and ‘cat’ has different words and also considers special characters ‘ . ’ . Which implies that when we use BoW, preprocessing should be done first then apply BoW.</p><p><strong>Implementing BoW using python code.</strong></p><pre>import pandas as pd<br>from sklearn.feature_extraction.text import CountVectorizer<br><br>document = [<br>&quot;Cat sat on mat .&quot;,<br>&quot;cat ate Mat .&quot;<br>]<br>labels = [&quot;Sentence1&quot;, &quot;Sentence2&quot;]<br><br>print(f&quot; - - - - - - - Without Preprocessing - - - - - -&quot;)<br># 👇 Without preprocessing<br>bow_vec = CountVectorizer( preprocessor=lambda x: x, token_pattern=r&quot;\S+&quot;,<br>lowercase=False)<br>bow_matrix = bow_vec.fit_transform(document)<br>vocab_bow = bow_vec.get_feature_names_out()<br>print(f&quot;Vocabulary: {len(vocab_bow)} words&quot;)<br>print(f&quot;Words: {list(vocab_bow)}&quot;)<br>df_bow = pd.DataFrame(bow_matrix.toarray(), columns=vocab_bow, index=labels)<br>print(&quot;\nBag of Words matrix:&quot;)<br>print(df_bow)<br>print(f&quot; &quot;)<br><br>print(f&quot; - - - - - - - After Preprocessing - - - - - -&quot;)<br># 👇 stop_words=&#39;english&#39; removes &#39;the&#39;, &#39;a&#39;, &#39;of&#39; etc.<br>bow_vec = CountVectorizer(stop_words=&#39;english&#39;)<br>bow_matrix = bow_vec.fit_transform(document)<br>vocab_bow = bow_vec.get_feature_names_out()<br>print(f&quot;Vocabulary: {len(vocab_bow)} words&quot;)<br>print(f&quot;Words: {list(vocab_bow)}&quot;)<br>df_bow = pd.DataFrame(bow_matrix.toarray(), columns=vocab_bow, index=labels)<br>print(&quot;\nBag of Words matrix:&quot;)<br>print(df_bow)<br><br>--------------------output----------------------------------------<br>-------------- Without Preprocessing-----------<br>Vocabulary: 8 words<br>Words: [&#39;.&#39;, &#39;Cat&#39;, &#39;Mat&#39;, &#39;ate&#39;, &#39;cat&#39;, &#39;mat&#39;, &#39;on&#39;, &#39;sat&#39;]<br><br>Bag of Words matrix:<br>           .  Cat  Mat  ate  cat  mat  on  sat<br>Sentence1  1    1    0    0    0    1   1    1<br>Sentence2  1    0    1    1    1    0   0    0<br>    <br>-------------- After Preprocessing-----------<br>Vocabulary: 4 words<br>Words: [&#39;ate&#39;, &#39;cat&#39;, &#39;mat&#39;, &#39;sat&#39;]<br><br>Bag of Words matrix:<br>           ate  cat  mat  sat<br>Sentence1    0    1    1    1<br>Sentence2    1    1    1    </pre><blockquote><strong>TF-IDF</strong></blockquote><p>TF-IDF (Term Frequency-Inverse Document Frequency) is a numerical statistic used in natural language processing and information retrieval to evaluate the importance of a term (word) within a document relative to a collection of documents (corpus). TF-IDF is calculated based on two main components: term frequency (TF) and inverse document frequency (IDF).TF-IDF (Term Frequency-Inverse Document Frequency) is a numerical statistic used in natural language processing and information retrieval to evaluate the importance of a term (word) within a document relative to a collection of documents (corpus).</p><p>TF-IDF is calculated based on two main components: term frequency (TF) and inverse document frequency (IDF).</p><pre>TF(t, d)= No of times the word appears in doc/ Total no of words in doc<br>IDF(t, D) = log⁡(Total no of docs in corpus ∣D∣ / <br>            No of documents containing the word)<br><br>TF-IDF(t,d,D) = TF(t,d) × IDF(t,D)</pre><p><strong>Implementing TF-IDF using python code</strong></p><pre>from sklearn.feature_extraction.text import TfidfVectorizer<br><br># Sample corpus (collection of documents)<br>corpus = [<br>    &#39;This is the first document.&#39;,<br>    &#39;This document is the second document.&#39;,<br>    &#39;And this is the third one.&#39;,<br>    &#39;Is this the first document?&#39;,<br>]<br><br># Create an instance of TfidfVectorizer<br>vectorizer = TfidfVectorizer()<br><br># Fit the vectorizer to the corpus and transform<br># the corpus into a TF-IDF matrix<br>tfidf_matrix = vectorizer.fit_transform(corpus)<br><br># Get the list of unique words (vocabulary)<br>vocab = vectorizer.get_feature_names_out()<br><br># Convert the TF-IDF matrix to a dense numpy array for easier manipulation<br>tfidf_matrix_dense = tfidf_matrix.toarray()<br><br># Print the TF-IDF matrix and the corresponding vocabulary<br>print(&quot;TF-IDF matrix:&quot;)<br>print(tfidf_matrix_dense)<br>print(&quot;\nVocabulary:&quot;)<br>print(vocab)<br><br>----------------------------output----------------------------------<br>TF-IDF matrix:<br>[[0.         0.46979139 0.58028582 0.38408524 0.         0.<br>  0.38408524 0.         0.38408524]<br> [0.         0.6876236  0.         0.28108867 0.         0.53864762<br>  0.28108867 0.         0.28108867]<br> [0.51184851 0.         0.         0.26710379 0.51184851 0.<br>  0.26710379 0.51184851 0.26710379]<br> [0.         0.46979139 0.58028582 0.38408524 0.         0.<br>  0.38408524 0.         0.38408524]]<br><br>Vocabulary:<br>[&#39;and&#39; &#39;document&#39; &#39;first&#39; &#39;is&#39; &#39;one&#39; &#39;second&#39; &#39;the&#39; &#39;third&#39; &#39;this&#39;]</pre><p><strong>2. Static Embedding</strong></p><p><strong>Static embedding</strong> is a way of representing words as fixed numerical vectors, where each word has <strong>only one meaning (one vector)</strong> no matter where it appears.</p><blockquote><strong>Word2Vec</strong></blockquote><p><strong>Word2Vec</strong> is a popular Natural Language Processing (NLP) technique developed by Google that converts words into dense, numerical vectors within a continuous vector space. It captures semantic relationships — meaning similar words are placed closer together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skm_9d-sbYD_344tYvtOfA.png" /><figcaption>Diagrammatic explanation of Word2Vec</figcaption></figure><ol><li><strong>The Input (Finding the Context)</strong></li></ol><p>First, we give the computer a massive amount of text (like Wikipedia or a library of books). The model looks at a specific word — like <strong>“King”</strong> — and examines the words that usually surround it.</p><ul><li>Does it often appear near “Royal”? “Crown”? “Man”?</li><li>By looking at these neighbors, the computer starts to learn the “vibe” or context of the word.</li></ul><p><strong>2. The Process (Training the Model)</strong></p><p>The “Training Model” (represented by the gears in the diagram) is a neural network. It takes the word “King” and tries to predict the words around it.</p><ul><li>If it guesses wrong, it adjusts its internal settings.</li><li>After millions of attempts, it gets very good at knowing which words belong together. This is where the “Contextual Meaning” is born.</li></ul><p><strong>3. The Output (Creating the Vector)</strong></p><p>The result of all that training is a <strong>Vector</strong> — which is just a list of numbers (like [0.8, -0.4, 0.2]).</p><ul><li>You can think of these numbers as <strong>coordinates</strong> on a map.</li><li>In this “Semantic Space,” words with similar meanings are placed physically close to each other. “Apple” and “Fruit” will be in one corner, while “Cat” and “Dog” will be in another.</li></ul><h4>The “Magic” of Math</h4><p>The coolest part of Word2Vec is shown in the graph on the bottom right. Because words are now numbers, you can actually do math with them:</p><blockquote>King — Man + Woman = Queen</blockquote><p>If you take the vector for “King,” subtract the “Manliness” from it, and add “Womanliness,” the computer lands on the exact coordinate for “Queen.” It understands the <strong>relationship</strong> between gender and royalty without ever being told what a woman or a king actually is!</p><p><strong>Advantages</strong></p><ol><li>Captures Semantic Relationships.</li><li>Reduces Dimensionality.</li><li><strong>Pre-trainable:</strong> You can train a model on a massive dataset (like Google News).</li><li>Word count within the corpus is covered.</li></ol><p><strong>Disadvantages</strong></p><ol><li><strong>The Polysemy problem</strong> Word2Vec creates <strong>one</strong> vector per word.</li></ol><ul><li><em>Example:</em> The word “Bank” in “riverbank” and “investment bank” has the exact same vector. It cannot distinguish between different meanings based on context.</li></ul><p>2. <strong>Out-of-Vocabulary (OOV) Issues:</strong> If the model encounters a word it wasn’t trained on (like a new slang term or a typo), it has no idea what to do with it. It sees it as a complete “unknown.”</p><p>3.<strong> Requires Huge Datasets:</strong> To get accurate “coordinates” for words, you need millions of sentences. On small datasets, the relationships it learns are often weak or nonsensical.</p><p>4.<strong> Ignores Sub-word Information:</strong> It treats “running,” “runner,” and “runs” as three entirely separate entities. It doesn’t understand that they all share the root word “run.”</p><h4>Implementing Word2Vec using python code</h4><pre>from gensim.models import Word2Vec<br><br># 1. Define your data: A list of sentences (already tokenized into words)<br># We use sentences that show relationships between royalty, gender, and food.<br>sentences = [<br>    [&#39;king&#39;, &#39;is&#39;, &#39;a&#39;, &#39;man&#39;],<br>    [&#39;queen&#39;, &#39;is&#39;, &#39;a&#39;, &#39;woman&#39;],<br>    [&#39;king&#39;, &#39;rules&#39;, &#39;the&#39;, &#39;kingdom&#39;],<br>    [&#39;queen&#39;, &#39;rules&#39;, &#39;the&#39;, &#39;kingdom&#39;],<br>    [&#39;apple&#39;, &#39;is&#39;, &#39;a&#39;, &#39;fruit&#39;],<br>    [&#39;orange&#39;, &#39;is&#39;, &#39;a&#39;, &#39;fruit&#39;],<br>    [&#39;man&#39;, &#39;eats&#39;, &#39;apple&#39;],<br>    [&#39;woman&#39;, &#39;eats&#39;, &#39;orange&#39;]<br>]<br><br># 2. Train the Word2Vec model<br># vector_size: The number of dimensions (coordinates) for each word<br># window: How many words to the left and right to look at for context<br># min_count: Ignore words that appear fewer than this many times<br>model = Word2Vec(sentences, vector_size=10, window=2, min_count=1, workers=1)<br><br># 3. Look at the &quot;Vector&quot; for a word<br>print(&quot;Vector for &#39;king&#39;:&quot;)<br>print(model.wv[&#39;king&#39;])<br><br># 4. Find words most similar to &#39;king&#39;<br>print(&quot;\nWords most similar to &#39;king&#39;:&quot;)<br>print(model.wv.most_similar(&#39;king&#39;))<br><br># 5. Perform &quot;Word Math&quot; (King - Man + Woman = ?)<br># positive=[A, B] means add them, negative=[C] means subtract it<br>result = model.wv.most_similar(positive=[&#39;king&#39;, &#39;woman&#39;], negative=[&#39;man&#39;],<br>         topn=1)<br>print(f&quot;\nKing - Man + Woman = {result[0][0]}&quot;)<br><br>--------------------------- output -----------------------------------------<br>Vector for &#39;king&#39;:<br>[ 0.02348376 -0.04519032  0.08388732 -0.09858163  0.06764641  0.02914417<br> -0.04932832  0.04398187 -0.01739575  0.06711384]<br><br>Words most similar to &#39;king&#39;:<br>[(&#39;woman&#39;, 0.5111573338508606), (&#39;kingdom&#39;, 0.3862057030200958),<br> (&#39;eats&#39;, 0.30024561285972595), (&#39;fruit&#39;, 0.141779825091362),<br> (&#39;orange&#39;, 0.05755753815174103), (&#39;the&#39;, -0.027840567752718925), <br> (&#39;apple&#39;, -0.05889715999364853), (&#39;queen&#39;, -0.09835173189640045), <br> (&#39;man&#39;, -0.10107498615980148), (&#39;rules&#39;, -0.25342026352882385)]<br><br>King - Man + Woman = eats</pre><blockquote><strong>GLOVE</strong></blockquote><p><strong>GloVe</strong> is an algorithm developed by researchers at Stanford University that learns word meanings based on how frequently words co-occur (appear together) in a large corpus of text.</p><p>In simple terms, it represents each word as a vector (list of numbers) such that <strong>similar words have similar vectors</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yc5jYSA-uhcsNKv406r8Tg.png" /></figure><h4>1. The Input (The Co-Occurrence Matrix)</h4><p>Unlike Word2Vec, which looks at one small window of words at a time, GloVe starts by building a <strong>Global Co-occurrence Matrix</strong>.</p><ul><li>Imagine a massive grid where every word is a row and every word is a column.</li><li>The numbers in the grid represent <strong>how often two words appear together</strong> in the entire dataset (e.g., how many times “King” and “Queen” show up in the same document).</li><li>This captures the “Global Statistics” of the language.</li></ul><h4>2. The Process (Ratios of Probabilities)</h4><p>The “magic” of GloVe is that it doesn’t just care if words appear together; it cares about the <strong>ratios</strong> of their probabilities.</p><p>For example, the word “water” appears often with both “ice” and “steam.”</p><ul><li>However, the word “solid” appears much more often with “ice” than with “steam.”</li><li>GloVe uses these ratios to distinguish fine-grained meanings, which is shown by the complex math formula in the middle of the diagram ($J = \sum f(X_{ij})…$).</li></ul><h4>3. The Output (Vector Space)</h4><p>Just like the previous model, the end result is a map of coordinates. However, <strong>GloVe</strong> is often better at capturing <strong>analogies</strong> beyond just gender, such as city-country relationships (Berlin → Germany) or groups of related objects (Car/Truck/Bus).</p><h4><strong>Implementing Glove with a python code</strong></h4><pre>import gensim.downloader as api <br><br># 1. Load a pre-trained GloVe model (trained on 6 billion words from Wikipedia)<br># This may take a moment to download the first time<br>print(&quot;Loading GloVe model...&quot;)<br>model = api.load(&quot;glove-wiki-gigaword-100&quot;) <br><br># 2. Find similar words<br>print(&quot;\nWords similar to &#39;apple&#39;:&quot;)<br>print(model.most_similar(&#39;apple&#39;, topn=3))<br><br># 3. Solve an analogy: Paris is to France as Rome is to ?<br># Equation: France - Paris + Rome = ?<br>result = model.most_similar(positive=[&#39;france&#39;, &#39;rome&#39;], negative=[&#39;paris&#39;], topn=1)<br>print(f&quot;\nParis : France :: Rome : {result[0][0].capitalize()}&quot;)<br><br># 4. Find the &#39;odd one out&#39;<br>print(&quot;\nWhich word doesn&#39;t belong? [&#39;car&#39;, &#39;bus&#39;, &#39;apple&#39;, &#39;truck&#39;]&quot;)<br>print(model.doesnt_match([&#39;car&#39;, &#39;bus&#39;, &#39;apple&#39;, &#39;truck&#39;]))<br><br>-------------------- output-----------------------------------------<br>Words similar to &#39;apple&#39;:<br>[(&#39;microsoft&#39;, 0.7449405193328857), (&#39;ibm&#39;, 0.6821643114089966), (&#39;intel&#39;, 0.6778088212013245)]<br><br>Paris : France :: Rome : Italy<br><br>Which word doesnt belong? [&#39;car&#39;, &#39;bus&#39;, &#39;apple&#39;, &#39;truck&#39;]<br>appleWords similar to &#39;apple&#39;:<br>[(&#39;microsoft&#39;, 0.7449405193328857), (&#39;ibm&#39;, 0.6821643114089966), (&#39;intel&#39;, 0.6778088212013245)]<br><br>Paris : France :: Rome : Italy<br><br>Which word doesn&#39;t belong? [&#39;car&#39;, &#39;bus&#39;, &#39;apple&#39;, &#39;truck&#39;]<br>apple</pre><blockquote><strong>FAST TEXT</strong></blockquote><p><strong>FastText</strong> is an open-source library developed by Meta Platforms for <strong>efficient text classification and word representation (embeddings)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWt0E-eBDt0LDre5CeQIBw.png" /></figure><h4>1. Input: Character N-Gram Decomposition</h4><p>Standard models see the word <strong>“UNHELPFUL”</strong> as one single ID. FastText, however, treats it like a puzzle:</p><ul><li><strong>Boundary Markers:</strong> It adds brackets (like &lt; and &gt;) to the start and end of the word so it can distinguish between the sequence &quot;un&quot; at the start of a word (a prefix) and &quot;un&quot; in the middle of a word (like in &quot;reunion&quot;).</li><li><strong>The Chunks (N-Grams):</strong> It breaks the word into overlapping pieces of length $n$. If $n=3$, “unhelpful” becomes &lt;un, unh, nhe, hel, elp, lfu, ful, and ul&gt;.</li><li><strong>Handling OOV:</strong> This is why “anti-unhelpful” works. Even if the model has never seen that specific long word, it recognizes the “anti” chunk and the “unhelp” chunks from its training data.</li></ul><h4>2. Process: Training &amp; Neural Architecture</h4><p>The middle of the image shows the “brain” of the model. FastText usually uses an architecture similar to <strong>Skip-gram</strong> (predicting surrounding words from a target word):</p><ul><li><strong>The Math:</strong> The formula $J = \sum \log P(w_j \mid \sum z_g)$ looks complex, but it essentially means: “The probability of a word being in this context is the sum of the vectors ($z_g$) of all its tiny character pieces.”</li><li><strong>The Hidden Layer:</strong> Instead of having one vector for “king,” the model looks up the vectors for kin, ing, &lt;ki, etc., and <strong>averages/sums</strong> them together.</li><li><strong>Weight Adjustment:</strong> During training, if the model guesses the wrong context word, it goes back and slightly adjusts the values of those tiny n-grams until the math works out.</li></ul><h4>3. Output: Semantic &amp; Morphological Vector Space</h4><p>The final section shows the “Map of Meaning” (Vector Space).</p><ul><li><strong>Semantic Relations:</strong> Just like GloVe, it learns that “King” relates to “Man” in the same way “Queen” relates to “Woman.”</li><li><strong>Morphological Clusters:</strong> This is the unique strength of FastText. Because “Helpful,” “Helping,” and “Helper” all share the n-gram help, the model naturally groups them together in space.</li><li><strong>Dense Vectors:</strong> The final result for any word is a “Dense Vector” (a list of numbers). Because these numbers are derived from subwords, words with similar roots or suffixes will have vectors that point in very similar directions.</li></ul><h4>Implementing FastText with a python code</h4><pre>from gensim.models import FastText<br><br># 1. Sample data (sentences)<br>sentences = [<br>    [&quot;the&quot;, &quot;king&quot;, &quot;rules&quot;, &quot;the&quot;, &quot;kingdom&quot;],<br>    [&quot;the&quot;, &quot;queen&quot;, &quot;helps&quot;, &quot;the&quot;, &quot;king&quot;],<br>    [&quot;running&quot;, &quot;is&quot;, &quot;a&quot;, &quot;good&quot;, &quot;exercise&quot;],<br>    [&quot;the&quot;, &quot;runner&quot;, &quot;runs&quot;, &quot;fast&quot;]<br>]<br><br># 2. Train the model<br># min_n and max_n define the range of character n-grams (subwords)<br>model = FastText(sentences, vector_size=10, window=3, min_count=1,<br>         min_n=3, max_n=6)<br><br># 3. Get vector for a word in the vocabulary<br>print(&quot;Vector for &#39;king&#39;:&quot;, model.wv[&#39;king&#39;])<br><br># 4. MAGIC: Get vector for a word NOT in the vocabulary (OOV)<br># Even though &#39;runny&#39; wasn&#39;t in the training data, it knows &#39;run&#39;<br>print(&quot;Vector for &#39;runny&#39;:&quot;, model.wv[&#39;runny&#39;])<br><br># 5. Find most similar words<br>print(&quot;Most similar to &#39;runner&#39;:&quot;, model.wv.most_similar(&quot;runner&quot;))<br><br><br>------------------------- Output ---------------------------------------<br>Vector for &#39;king&#39;: [ 0.03789086  0.00864838  0.00805052  0.02808878 <br>                     0.02641913 -0.00887341  0.01138848  0.02170363 <br>                    -0.01058162 -0.00500708]<br>Vector for &#39;runny&#39;: [-0.0297992   0.01527493 -0.0020144   <br>                      0.02378171  0.00670121  0.00403339<br>                     -0.03827518 -0.00907472  0.00314262  0.00309879]<br><br>Most similar to &#39;runner&#39;: [(&#39;running&#39;, 0.5256751179695129), <br>(&#39;helps&#39;, 0.3551099896430969),<br> (&#39;king&#39;, 0.25253236293792725), (&#39;kingdom&#39;, 0.19924651086330414), <br>(&#39;runs&#39;, 0.11857877671718597), (&#39;fast&#39;, 0.10497688502073288), <br>(&#39;rules&#39;, 0.00594911677762866), (&#39;is&#39;, -0.005365453660488129), <br>(&#39;good&#39;, -0.034609049558639526), (&#39;queen&#39;, -0.09404084831476212)]<br>Vector for &#39;king&#39;: [ 0.03789086  0.00864838  0.00805052  <br>0.02808878  0.02641913 -0.00887341<br>  0.01138848  0.02170363 -0.01058162 -0.00500708]<br>Vector for &#39;runny&#39;: [-0.0297992   0.01527493 -0.0020144  <br> 0.02378171  0.00670121  0.00403339<br> -0.03827518 -0.00907472  0.00314262  0.00309879]<br>Most similar to &#39;runner&#39;: [(&#39;running&#39;, 0.5256751179695129), (&#39;helps&#39;, 0.3551099896430969), (&#39;king&#39;, 0.25253236293792725), (&#39;kingdom&#39;, 0.19924651086330414), (&#39;runs&#39;, 0.11857877671718597), (&#39;fast&#39;, 0.10497688502073288), (&#39;rules&#39;, 0.00594911677762866), (&#39;is&#39;, -0.005365453660488129), (&#39;good&#39;, -0.034609049558639526), (&#39;queen&#39;, -0.09404084831476212)]<br></pre><h4><strong>Conclusion</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlCiuxm6JK8vZ40HKWbgUw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a38012574f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizier’s in Deep Learning]]></title>
            <link>https://medium.com/@connect.ponezhil/optimiziers-in-deep-learning-234508efdf82?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/234508efdf82</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 02:47:35 GMT</pubDate>
            <atom:updated>2025-04-12T02:47:35.571Z</atom:updated>
            <content:encoded><![CDATA[<p>In deep learning, optimizers are algorithms that adjust a neural network’s weights and biases to minimize the loss function, enabling the model to learn effectively.</p><p><strong>Purpose:</strong></p><ul><li>Optimizers are essential for training deep learning models by iteratively refining the model’s parameters (weights and biases) to minimize the loss function.</li></ul><p><strong>How they work:</strong></p><ul><li>Optimizers use optimization algorithms to adjust the model’s parameters during each training epoch, based on the feedback received from the data.</li><li>So, the choice of optimizer can significantly impact the model’s performance, speed of convergence, and overall effectiveness.</li></ul><p><strong>Common Optimizers Types</strong></p><ol><li>Gradient descent</li><li>Stochastic gradient descent</li><li>Adadelta</li><li>AdaGrad</li><li>RMSProp</li><li>Gradient descent</li></ol><p>In simple terms, consider you are holding a ball resting at the top of a bowl. When you lose the ball, it goes along the steepest direction and eventually settles at the bottom of the bowl. A Gradient provides the ball in the steepest direction to reach the local minimum which is the bottom of the bowl.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MUP_eEklrsr5hgUdN1ji7A.png" /></figure><p>The above equation means how the gradient is calculated. Here <em>η</em> is the step size that represents how far to move against each gradient with each iteration.</p><p>Gradient descent works as follows:</p><ol><li><strong>Initialize Coefficients:</strong> Start with initial coefficients.</li><li><strong>Evaluate Cost:</strong> Calculate the cost associated with these coefficients.</li><li><strong>Search for Lower Cost:</strong> Look for a cost value lower than the current one.</li><li><strong>Update Coefficients:</strong> Move towards the lower cost by updating the coefficients’ values.</li><li><strong>Repeat Process:</strong> Continue this process iteratively.</li><li><strong>Reach Local Minimum:</strong> Stop when a local minimum is reached, where further cost reduction is not possible.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*lf5RmUrgTrbuI8gY-vX4lA.png" /></figure><p>2. Stochastic gradient descent</p><p>“Stochastic” means “randomly determined,” it introduces randomness into our optimization process.</p><p>Instead of using all data points to calculate the gradient, SGD randomly selects one data point at each step. It uses this single point to calculate an estimate of the gradient and update the parameters.</p><p>Because SGD only looks at one data point at a time, it can make more frequent updates to the parameters. This allows it to traverse the error surface more quickly, especially for large datasets.</p><p>However, this speed comes at a cost. Since we’re using a single data point to estimate the gradient of the entire dataset, our estimates are much noisier. This means our path down the error surface is less smooth and more erratic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*kb8vgDCQl2XINqUc.jpg" /></figure><p><strong>Need for SGD</strong></p><p><strong>1. Large datasets:</strong> In ML, it is common to have very large datasets with millions or even billions of data points. Using traditional gradient descent algorithms on such large datasets is computationally expensive and impractical. In such cases, SGD works well because it uses randomly selected data points to update the model parameters, making the process faster and more efficient.</p><p><strong>2. Non-Convex optimization problems:</strong> In many ML problems, the objective function is not convex, which means there are multiple local minima. Traditional gradient descent algorithms may get stuck in one of the local minima, resulting in suboptimal models. SGD, on the other hand, is less likely to get stuck because it updates the parameters using only a few data points at a time, making it more likely to find the global minimum.</p><p>The gradient can be used to update the model parameters using the following formula:</p><p><strong>θ = θ — η * gradient</strong></p><p>where η is the learning rate. The learning rate is a hyperparameter that controls how much the model parameters are updated each iteration.</p><p><strong>3. AdaGrad <em>(Adaptive Gradient Algorithm)</em></strong></p><p>It is an optimizing algorithm, designed to adapt the learning rate for each parameter based on its historical gradients. This approach allows Aagard to improve the efficiency of Machine learning models, especially in scenarios where sparse data is involved or when different parameters have varying rates of convergence.</p><p><strong>θ(t+1) = θ(t) — η * G(t)^(-1/2) * g(t)</strong></p><ul><li><strong>θ(t):</strong> Represents the parameter value at time step t.</li><li><strong>θ(t+1):</strong> Represents the updated parameter value at the next time step.</li><li><strong>η:</strong> Is the learning rate, a hyperparameter that determines the size of the parameter updates.</li><li><strong>G(t):</strong> Is a diagonal matrix where each element (G(t,i,i)) stores the sum of squared gradients for parameter i up to time step t.</li><li><strong>g(t):</strong> Represents the gradient of the loss function with respect to parameter i at time step t.</li><li><strong>G(t)^(-1/2):</strong> Represents the inverse square root of the diagonal matrix G(t).</li><li><strong>η * G(t)^(-1/2) * g(t):</strong> This term calculates the update step for each parameter.</li></ul><p><strong><em>AdaGrad is one such algorithm that adjusts the learning rate for each parameter based on its prior gradients.</em></strong></p><p>4. <strong>Adadelta</strong></p><p><strong>Adadelta -(</strong>Adaptive Learning Rates) can be considered a further extension of gradient descent that builds upon AdaGrad , and changes the calculation of the custom step size so that the units are consistent and in turn no longer requires an initial learning rate hyperparameter.</p><p>In Simpe terms, Imagine you have a complex, hilly terrain, and you’re trying to find the lowest point. Different parts of the terrain may have steeper or shallower slopes. With AdaDelta, you can dynamically adjust your step size based on how steep or flat the terrain is at each location. This adaptability allows you to take larger steps when the terrain is gentle and smaller steps when it’s steep, improving your chances of reaching the lowest point efficiently.</p><p><strong>5. RMSProp</strong></p><p>RMSProp, short for <strong>Root Mean Square Propagation</strong>, is a widely used optimization algorithm in deep learning. It’s an improvement over <strong>AdaGrad</strong> (Adaptive Gradient Algorithm) and addresses some of AdaGrad’s key limitations, especially for models dealing with sparse data.</p><p>RMSProp keeps track of an exponentially decaying average of the squared gradients. Instead of accumulating all past squared gradients as AdaGrad does, RMSProp uses a moving average. This means that RMSProp gives more weight to recent gradients, allowing it to adapt more effectively without diminishing the learning rate too quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/0*4lRfYKLhaaAxxNs8.png" /></figure><p>where:</p><ul><li>η is the learning rate,</li><li>ϵ is a small constant added to prevent division by zero.</li></ul><p>in a nut shell ,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*W6pKLk6i9fi9VPrsshKzSg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=234508efdf82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measuring Errors in Linear Regression Models]]></title>
            <link>https://medium.com/@connect.ponezhil/measuring-errors-in-linear-regression-models-e94675383144?source=rss-f8eb9c0a097d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e94675383144</guid>
            <dc:creator><![CDATA[PonEzhil]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 03:52:46 GMT</pubDate>
            <atom:updated>2024-08-19T02:56:25.550Z</atom:updated>
            <content:encoded><![CDATA[<p>Linear Regression is a linear approximation of relationship between two or more variables. For example (below image), we will consider the classic prices of houses Vs size of the house. When there is an increase in the size of the house there is an increase in the price, the relationship between the price and size of the houses follows a linear approximation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*wiwAM7ZKDHnHpL2tn_PXtg.jpeg" /></figure><p><strong>Linear Regression models</strong></p><p>When we are creating a model for the linear regression -we will be designing a model, which best suits the sample data we have, and we predict or infer how the population will be behaving. The Linear Regression model when predicting the population pattern follows a linear pattern which can be denoted by</p><blockquote><strong>y = mx + c + ε</strong></blockquote><blockquote>(y: dependent variable, x: independent variable, m: slope, c: intercept, ε: error)</blockquote><p>The predicted values of a linear regression model will be following a straight line called as the <strong>Best Fit Line, </strong>which aligns itself to ensure the error is minimum.</p><p><strong>Errors in Linear Regression</strong></p><p>When we look into the below image, we have taken a single data point (Xi,Yi) for the value of Xi , Yi is the actual data and ŷi is the predicted data by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*FfNhSRzxbP6vAuFOtFj8gQ.png" /></figure><p>So the deviation between the actual data and the observed data is considered as error at the xi value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*1czuaZhkbvSXv6fyPD9LBQ.png" /><figcaption>Deviation between the actual and predicted values is considered error.</figcaption></figure><p>There will be many xi values and for each xi value there is yi and y ^i value and ei values (Error Values).</p><p>The Measures of errors are needed to evaluate the model designed. So that we can decide to use the model or go for an efficient model.</p><p>Broadly when we are classifying supervised learning in ML, we classify it as Regression and Classification, and there are sets measures of error for regression and classification respectively. Out of these measures of errors, we can use each measure as per business needs.</p><p><strong>Types of Measures of Error in Regression</strong></p><blockquote>Mean Absolute Error (MAE)</blockquote><blockquote>Mean Square Error (MSE)</blockquote><blockquote>Root Mean Square Error (RMSE)</blockquote><blockquote>Mean Absolute Percentage Error (MAPE)</blockquote><blockquote>R2</blockquote><h4>Mean Absolute Error (MAE)</h4><p>The MAE provides the difference between our predicted and the actual value. It can be done by summing all the errors and divide them by a total number of observations. MAE must be as low as possible for the model to perform good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*FyR3tZMS_ImzjGb_b57U_g.png" /><figcaption>Formula for Mean Absolute Error</figcaption></figure><p>MAE is useful when the training data has outliers, and the outliers doesn&#39;t affect the business requirement.</p><p><strong>Commonly used: </strong>MAE is used in crowd counting problems.</p><p><strong>Advantages</strong></p><blockquote>It is very simple.</blockquote><blockquote>It doesn’t hurt the outliers.</blockquote><blockquote>MAE is of the same unit output variable.</blockquote><p><strong>Disadvantages</strong></p><blockquote>The large errors coming from the outliers end up being treated as the same as low errors.</blockquote><blockquote>Many optimization algorithms tend to use differentiation to find the optimum value for parameters in the evaluation metric, but MAE cannot be differentiable.</blockquote><p>To overcome the disadvantages of MAE next metric was introduced that was MSE.</p><h4>Mean Square Error (MSE)</h4><p>MSE is the most used and very simple metric. It is the squared difference between actual and predicted values. We perform squared to avoid the cancellation of negative terms. A low MSE indicates the prediction of the model is good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*JPnE9nXX0ASlYKGetAkg1g.png" /><figcaption>Formula for MSE</figcaption></figure><p>When we predict quantities, and the range of that quantity is large or highly variable, skewed MSE can be used.</p><p><strong>Common usage:</strong></p><ul><li><strong>Regression analysis</strong>: Assessing the goodness of fit of the regression models.</li><li><strong>Model evaluation</strong>: Comparing the performance of the different machine learning algorithms.</li><li><strong>Optimization</strong>: Minimizing MSE during the model training to the improve predictive accuracy.</li><li><strong>Predictive modeling</strong>: Evaluating the accuracy of the regression and forecasting models.</li><li><strong>Image processing</strong>: Assessing the quality of the image reconstruction and restoration algorithms.</li><li><strong>Financial modeling</strong>: Analyzing the performance of the investment strategies and risk models.</li></ul><p><strong>Advantages</strong></p><blockquote>Helpful in removing out outliers with large errors from the model by putting more weight on them.</blockquote><blockquote>Magnifies the huge errors in the model by squaring them.</blockquote><blockquote>Differentiation can be done to get the optimize and find the minimum value.</blockquote><p><strong>Disadvantages</strong></p><blockquote>The sensitivity to outliers magnifies the high errors by squaring them.</blockquote><blockquote>MSE will have the same effect for a single large error as too many smaller errors.</blockquote><h4>Root Mean Square Error (RMSE)</h4><p>As the name suggest it is a simple square root of mean squared error. It measures the average magnitude of the errors and is concerned with the deviations from the actual value. The lower the RMSE it is good for the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*14g1YoQsODfxfFud.png" /><figcaption>Formula for RMSE</figcaption></figure><p>It is in between the MAE and MSE, it will not suppress the outliers as MAE does or it will not blow up the outliers as MSE does. It is mostly preferred for deep learning error measurement.</p><p><strong>Common usage:</strong></p><p><strong>Transportation and Logistics — </strong>RMSE may be used to assess how well demand forecasting models anticipate passenger / freight quantities. This data is necessary for managing inventories, scheduling resources efficiently, and optimizing transportation routes.</p><p><strong>Finance </strong>— Stock market predictions models efficiency can be checked using RSME</p><p><strong>Climate — </strong>Climate predictions models (These models predict future climate patterns, such as temperature, precipitation, and sea level rise) accuracy can be checked using RSME.</p><p><strong>Advantages</strong></p><blockquote>The output value you get is in the same unit as the required output variable which makes interpretation of loss easy.</blockquote><p><strong>Disadvantages</strong></p><blockquote>It is not that robust to outliers as compared to MAE.</blockquote><p><strong>R Square</strong></p><p>R2 score is a metric that tells the performance of your model, and not the loss. R2 will be high if the model performance is also high. The Value will range from 0 -1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*A0aTHGw5sM-AOLM3.png" /><figcaption>Formula for R squared</figcaption></figure><h4>Mean Absolute Percentage Error (MAPE)</h4><p>MAPE also referred as Mean Absolute Percentage Deviation (MAPD)is derived by dividing the absolute difference between the actual and predicted values by the actual value. Its result is in percentage value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/0*8ykrfFhmMcCM2SEJ.png" /><figcaption>Formula for MAPE</figcaption></figure><p>MAPE increases linearly with error. Lower the MAPE value it is better for model performance. When MAPE is around 0–20 % its good for the model.</p><p><strong>Advantages</strong></p><blockquote>MAPE independent of the scale of the variables since its estimates are provided in terms of percentage.</blockquote><blockquote>Since all errors are normalized on a common scale and it is easy to understand.</blockquote><p><strong>Disadvantages</strong></p><blockquote>It will be difficult to calculate MAPE when the actual value is 0 , by the above stated formula denomination is 0.</blockquote><blockquote>If there is an error in the actual value it will magnify the error.</blockquote><p>Apart from the above-mentioned Measures of error there are others too</p><blockquote>Mean Bias Error (MBE)</blockquote><blockquote>Relative Absolute Error (RAE)</blockquote><blockquote>Relative Squared Error (RSE)</blockquote><blockquote>Normalized Root Mean Squared Error (NRMSE)</blockquote><blockquote>Relative Root Mean Squared Error (RRMSE)</blockquote><blockquote>Root Mean Squared Logarithmic Error (RMSLE)</blockquote><blockquote>Hyber Loss</blockquote><blockquote>Log Cosh Loss</blockquote><blockquote>Quantile Loss</blockquote><h3>Conclusion</h3><p>The below tabulation explains the measures of errors and their characteristics in a nutshell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*VrSWOG_zsza2EHuBjuS7UA.png" /><figcaption>Comparison of Measures of error characteristics</figcaption></figure><p>In real world regression problems. we need to know which evaluation matrices is crucial for accessing the performance of a model. Evaluation metrics serve as valuable tools for model selection, optimization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e94675383144" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>