<?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 Lathashree Harisha on Medium]]></title>
        <description><![CDATA[Stories by Lathashree Harisha on Medium]]></description>
        <link>https://medium.com/@lathashreeh?source=rss-315f28d8d7b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0DIE87M9ZTx5OGcn5cgHOA.jpeg</url>
            <title>Stories by Lathashree Harisha on Medium</title>
            <link>https://medium.com/@lathashreeh?source=rss-315f28d8d7b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:00:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lathashreeh/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[Understanding MCP: From Architecture to Building My First MCP Server]]></title>
            <link>https://lathashreeh.medium.com/understanding-mcp-from-architecture-to-building-my-first-mcp-server-755c3b1c42c6?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/755c3b1c42c6</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 19:21:50 GMT</pubDate>
            <atom:updated>2026-10-21T20:49:12.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Is it too late to learn about MCP? Let&#39;s do it anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ruxdu5zXha2Sm7Cb" /><figcaption>Photo by <a href="https://unsplash.com/@kevinache?utm_source=medium&amp;utm_medium=referral">Kevin Ache</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you are anything like me, trying to keep up with all the AI developments around the world, you have probably heard about MCP, briefly read about it, and moved on to the next technology the following day.</p><p>Well, until one day you realise you understand it only superficially, but not well enough to explain how it actually works. So, I finally decided to learn it properly and build a little MCP server to understand the concepts hands-on.</p><h3>What is MCP?</h3><p>MCP (Model Context Protocol) is an open-source standard introduced by Anthropic in November 2024. It provides a standardised way for AI applications to connect with external tools, data sources, and services.</p><p><em>Let’s take an example: Imagine you are building a personal AI assistant that organises and keeps track of your emails. To make this useful, your assistant needs access to your Gmail account.</em></p><p>Traditionally, you would need to build custom integrations to connect your application to these services, handle their APIs, and manage how the resulting capabilities are exposed to your AI application.</p><p>Now imagine a standardised way through which compatible AI applications can expose and consume these capabilities, regardless of the underlying model or vendor. That’s what MCP defines for us.</p><h3>Understanding the MCP architecture</h3><p>MCP has three core components:</p><ul><li><strong>MCP Host</strong>: The AI application that manages the user interaction, coordinates MCP clients, and determines how available capabilities are used.</li><li><strong>MCP Client</strong>: A component within the host that establishes and maintains a connection with an MCP server, handling protocol communication.</li><li><strong>MCP Server:</strong> A program that exposes capabilities, such as tools, resources, and prompts, to MCP clients.</li></ul><p>Before diving into the implementation, let’s understand how these three components interact. Coming back to our personal AI assistant, say it receives a request:</p><p><em>“Find my latest email from my manager and summarise the action items.”</em></p><p>For this to happen, our AI application needs access to an email service. Let’s assume we have a Gmail MCP server that exposes capabilities to search and retrieve emails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00L9DSppxI2TVqI9CnWlww.png" /></figure><p>Here is what happens, step by step:</p><ol><li><strong>User → Host:</strong> You type the request into the AI application.</li><li><strong>Host → MCP Client:</strong> The host asks its MCP client to connect to the Gmail server and find out what it offers.</li><li><strong>MCP Client → Host:</strong> The MCP server describes its capabilities (tools, resources and prompts), and the client passes them to the host.</li><li><strong>Host → LLM:</strong> The host sends your request to the model along with the definitions of the available tools.</li><li><strong>LLM → Host:</strong> The model decides it needs a tool and replies with a tool call, such as search_emails with a few arguments. The model only <em>asks</em> for the call. It never executes anything itself.</li><li><strong>Host → MCP Client → Server:</strong> The host runs the call through its MCP client, and the server does the real work, thereby calling the Gmail API.</li><li><strong>Server → MCP Client → Host:</strong> The result (the email details) travels back to the host.</li><li><strong>Host → LLM:</strong> The host gives the result to the model, which reads the email and drafts the summary of action items.</li><li><strong>Host → User:</strong> The host delivers the answer.</li></ol><blockquote>The key takeaway from the MCP ecosystem is that <strong>the LLM never talks to the MCP server directly</strong>. The host sits in the middle, manages the connections, and decides what the model gets to see and do.</blockquote><blockquote><strong>MCP standardises the conversation between the host and the outside world, so the same server works with any compatible host.</strong></blockquote><h4>What can an MCP server expose?</h4><p>MCP Servers can offer three kinds of capabilities, and each has a different “owner”:</p><ul><li><strong>Tools</strong> are actions the <em>model</em> can decide to call, like search_emails.</li><li><strong>Resources</strong> are data the <em>application</em> can read, like a file or a database record.</li><li><strong>Prompts</strong> are reusable templates the <em>user</em> can trigger, like “summarise action items from this sender”.</li></ul><h3>Building my first MCP server</h3><p>Reading about something only gets you so far; let&#39;s build a small MCP server to understand how it works. We will build a mock inbox with the same shape: search emails, read one, and a prompt for pulling out action items.</p><h4>Setup</h4><p>I used uv, but plain pip works too:</p><pre>uv init mock-gmail-mcp &amp;&amp; cd mock-gmail-mcp<br>uv add &quot;mcp[cli]&quot;</pre><h4>The Server</h4><p>Create a Python file named <em>server.py </em>and paste the code:</p><pre><br>from mcp.server.mcpserver import MCPServer<br><br>mcp = MCPServer(&quot;mock-gmail-mcp&quot;, description=&quot;A mock Gmail inbox for testing MCP clients.&quot;)<br><br>EMAILS = [<br>    {<br>        &quot;id&quot;: &quot;1&quot;,<br>        &quot;sender&quot;: &quot;manager@company.com&quot;,<br>        &quot;subject&quot;: &quot;Q4 planning follow-up&quot;,<br>        &quot;date&quot;: &quot;2026-10-14&quot;,<br>        &quot;body&quot;: (<br>            &quot;Thanks for the update. Action items: 1) send the revised &quot;<br>            &quot;budget by Friday, 2) book the review meeting with design, &quot;<br>            &quot;3) share the draft roadmap with the team.&quot;<br>        ),<br>    },<br>    {<br>        &quot;id&quot;: &quot;2&quot;,<br>        &quot;sender&quot;: &quot;newsletter@ai-weekly.com&quot;,<br>        &quot;subject&quot;: &quot;This week in AI&quot;,<br>        &quot;date&quot;: &quot;2026-10-16&quot;,<br>        &quot;body&quot;: &quot;Ten stories you might have missed...&quot;,<br>    },<br>    {<br>        &quot;id&quot;: &quot;3&quot;,<br>        &quot;sender&quot;: &quot;manager@company.com&quot;,<br>        &quot;subject&quot;: &quot;Quick one-to-one notes&quot;,<br>        &quot;date&quot;: &quot;2026-10-09&quot;,<br>        &quot;body&quot;: &quot;Action items: update the onboarding doc.&quot;,<br>    },<br>]<br><br><br>@mcp.tool()<br>def search_emails(sender: str = &quot;&quot;, max_results: int = 5) -&gt; list[dict]:<br>    &quot;&quot;&quot;Search the inbox, newest first. Optionally filter by sender.&quot;&quot;&quot;<br>    matches = [e for e in EMAILS if sender.lower() in e[&quot;sender&quot;].lower()]<br>    matches.sort(key=lambda e: e[&quot;date&quot;], reverse=True)<br>    return [<br>        {&quot;id&quot;: e[&quot;id&quot;], &quot;sender&quot;: e[&quot;sender&quot;], &quot;subject&quot;: e[&quot;subject&quot;], &quot;date&quot;: e[&quot;date&quot;]}<br>        for e in matches[:max_results]<br>    ]<br><br><br>@mcp.tool()<br>def get_email(email_id: str) -&gt; dict:<br>    &quot;&quot;&quot;Return the full content of one email by its id.&quot;&quot;&quot;<br>    for e in EMAILS:<br>        if e[&quot;id&quot;] == email_id:<br>            return e<br>    raise ValueError(f&quot;No email with id {email_id}&quot;)<br><br><br>@mcp.resource(&quot;inbox://stats&quot;)<br>def inbox_stats() -&gt; str:<br>    &quot;&quot;&quot;A quick summary of the inbox.&quot;&quot;&quot;<br>    return f&quot;{len(EMAILS)} emails in the inbox.&quot;<br><br><br>@mcp.prompt()<br>def summarise_action_items(sender: str) -&gt; str:<br>    &quot;&quot;&quot;Template: find the latest email from a sender and list action items.&quot;&quot;&quot;<br>    return (<br>        f&quot;Find the latest email from {sender}, read it, and list the &quot;<br>        &quot;action items as a short numbered list.&quot;<br>    )<br><br><br>if __name__ == &quot;__main__&quot;:<br>    mcp.run()  # stdio transport by default</pre><p>Three details matter more than they look:</p><ul><li><strong>Type hints and docstrings are the interface: </strong>The SDK turns them into the tool definitions the host sends to the model in step 4. A vague docstring means the model picks the wrong tool.</li><li><strong>Never </strong><strong>print() to stdout</strong> in a stdio server. stdout carries the protocol messages, so stray output corrupts them. Use logging (stderr) instead.</li><li><strong>Transport is a separate decision:</strong> stdio runs the server as a local subprocess of the host. For a server that several machines can reach, you would switch to Streamable HTTP.</li></ul><p><strong>Testing with the Inspector</strong></p><p>Before connecting any AI app, I tested the server with the MCP Inspector, which ships with the SDK’s CLI tools (it needs Node.js installed):</p><pre>uv run mcp dev server.py</pre><p>It opens a web UI where you can list the tools, call search_emails by hand, and see the raw responses. This is where steps 2 and 3 of the diagram stopped being abstract for me, because you can watch the server describe itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZlFSQYI1WwDalqqWdWFOg.png" /><figcaption>The web UI when you run your MCP server. Feel free to use your tools and see how it works!</figcaption></figure><h4>Connecting it to your host:</h4><p>You are now ready to integrate your MCP server into any of your applications. For easier integration, I tested this with Claude Desktop.<br>If you want to try this too, first we need to add the server details to claude_desktop_config.json :</p><blockquote>Open Claude Desktop, go to <strong>Settings → Developer → Edit Config</strong>. This opens the folder containing claude_desktop_config.json</blockquote><p>Here is the MPC server config you will need to add:</p><pre>&quot;mcpServers&quot;: {<br>  &quot;mock-gmail&quot;: {<br>    &quot;command&quot;: &quot;uv&quot;,<br>    &quot;args&quot;: [&quot;--directory&quot;, &quot;/absolute/path/to/mock-gmail-mcp&quot;, &quot;run&quot;, &quot;server.py&quot;]<br>  }<br>}</pre><p>Restart the Claude app, then we can ask the question:</p><blockquote><em>Find my latest email from my manager and summarise the action items.</em></blockquote><p>The assistant should call search_emails, then get_email, and then summarise the three action items. You can watch each step from the diagram happen: the tool list arrives, the model picks a tool, the host runs it, and the result goes back to the model. You will see a response like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0TWoea5R3MaphVVoMz21Ag.png" /><figcaption>Screenshot from my Claude app</figcaption></figure><h3>Yay! That was a successful integration of an MCP server to an AI application.</h3><h3>So what did I learn?</h3><p>(If you followed the article till here, you learnt these too!)</p><ul><li><strong>MCP is plumbing, and a form of standardisation.</strong> Once the server exists, I didn’t write any glue code to make a host use it.</li><li><strong>Good tool descriptions matter more than clever code.</strong> The model only sees the name, the docstring and the parameters.</li><li><strong>The host is in control.</strong> It decides which servers to connect, what the model sees, and (in most apps) whether you approve a tool call first.</li><li><strong>Treat servers like the code you’re installing.</strong> A server can read your data and take actions, so only connect ones you trust, and give them the least access they need.</li></ul><h4>References:</h4><ul><li>The <a href="https://github.com/lathashree01/mock-gmail-mcp">GitHub repo</a> for mock-gmail-mcp</li><li>Learn more about MCP here — <a href="https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro">https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=755c3b1c42c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scalable Systems: Heard about the P50, P95 as a performance metric?]]></title>
            <link>https://lathashreeh.medium.com/scalable-systems-heard-about-the-p50-p95-as-a-performance-metric-f745914d88f3?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f745914d88f3</guid>
            <category><![CDATA[scalable-systems]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 00:33:31 GMT</pubDate>
            <atom:updated>2026-06-08T11:51:28.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UWC_GhKMOrq6r6oL" /><figcaption>Photo by <a href="https://unsplash.com/@rockthechaos?utm_source=medium&amp;utm_medium=referral">Kolleen Gladden</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What does it mean to build “Scalable Systems”?</h3><p><strong>“Scalability”</strong> is the ability of a system to continue delivering acceptable performance as load increases.</p><p>Before deciding whether a system is scalable, we first need to define two things:</p><h4>Load</h4><p>We first need to understand the current load on the system. This helps us identify the load parameters and reason about what happens when they increase.</p><p>Examples of load parameters could be:</p><ul><li>Reads or writes to a database</li><li>Requests per second to an API</li><li>Purchase orders processed during a Prime Day sale</li><li>Messages consumed from a queue</li></ul><p>The important thing is that load parameters are specific to your system and architecture.</p><h4>Performance</h4><p>Once you understand what load means for your system, you can define how performance should behave as load increases.</p><p>There are two useful ways to think about this:</p><ol><li>If the load increases while system resources remain the same, how does performance change?</li><li>If the load increases, how many additional resources are required to maintain the same level of performance?</li></ol><p>For online systems, one of the most important performance metrics is <strong>response time</strong> — the time between a client sending a request and receiving a response.</p><blockquote><strong>Latency</strong> refers to delays within the system, such as network transit time, queueing delays, or waiting for resources, whereas <strong>Response time</strong> is the total time experienced by the user, including latency, server processing, and network delays.</blockquote><p>Many factors can affect the response time, some of which are outside your control. So, looking at individual requests is rarely useful. You could calculate the average response time over a fixed window (the last 1 hour, the last 10 minutes, etc.), but that does not give the right picture you are looking for. Hence, a better way is to look at these response times as a distribution of values and calculate a percentile over it.</p><p><strong>Understanding percentiles — <em>How do you calculate a percentile?</em></strong></p><p>Say you collect all your response times for the last 10 minutes and arrange them from fastest to slowest. The value in the middle of your distribution is the <strong>median</strong>, which means that half of your requests completed faster than that median value. This median is also known as the <strong>50th percentile (</strong>often called<strong> P50)</strong>.</p><p>In practice, engineers often pay close attention to <strong>P95</strong> and <strong>P99</strong> response times, where:</p><ul><li><strong>P95</strong> means 95% of requests are completed within that time.</li><li><strong>P99</strong> means 99% of requests are completed within that time.</li></ul><p>These higher percentiles reveal how the slowest requests behave. The requests at the far end of the distribution are commonly referred to as <strong><em>tail latencies</em></strong><em>.</em></p><p>This matters because users rarely notice your average response time. They notice the occasional request that takes several seconds longer than expected. For example, a system with a P50 response time of 100 ms and a P99 response time of 5 seconds may look fast on average, but one in every hundred requests takes 5 seconds. Users remember those slow requests far more than the average.</p><h4>Scaling the Systems</h4><p>Now that you have defined what the load parameters for your system and what is the performance you are targeting, there are two common approaches: <strong>scaling out </strong>(horizontal scaling) and <strong>scaling up</strong> (vertical scaling).</p><ul><li><strong>Scaling out</strong> means adding more machines to distribute the workload to multiple servers while maintaining the desired level of performance. Horizontal scaling can handle much larger workloads, but it introduces additional complexity around coordination, consistency, networking, and failure handling.</li><li><strong>Scaling up</strong> means adding more resources to a single machine so it can handle more load and process requests faster. Both approaches have their own advantages and disadvantages. Vertical scaling sounds simpler — just put together a bigger machine, but there is a practical limit to how powerful a single machine can become, and larger machines are usually more expensive.</li></ul><p>There is no one-size-fits-all solution here; the right choice of scaling depends on the system, the workload, and the performance goals you are trying to achieve.</p><p>Distilled by my latest reading of <em>Designing Data-Intensive Applications</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f745914d88f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A2UI: The Agentic UI of the Future]]></title>
            <link>https://lathashreeh.medium.com/a2ui-the-agentic-ui-of-the-future-b3f0c7043ed4?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3f0c7043ed4</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ui-design]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 00:34:12 GMT</pubDate>
            <atom:updated>2026-01-20T00:34:12.429Z</atom:updated>
            <content:encoded><![CDATA[<p>Transforming Future User-Interfaces driven by AI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VBRtmdswfGys1G3u" /><figcaption>Photo by <a href="https://unsplash.com/@kikisad?utm_source=medium&amp;utm_medium=referral">Killian Cartignies</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The ChatGPT revolution has redefined our expectations of interaction. It is changing the way we interact with the world. Hours of searching for the right information are now at your fingertips, using a tool like Perplexity or any other search tool. In fact, when searching for information to compose code, AI has become the interface itself. Yet the way we visualise and interact with these intelligent systems remains primitive — text boxes and chat windows.</p><p>Consider a chatbot that helps you book a hotel. It begins with a greeting, then asks a series of questions: your check-in date, time of arrival, and number of guests in a back-and-forth exchange. While functional, this interaction can feel unnecessarily sequential and time-consuming.</p><p>Now imagine a smarter alternative: instead of a drawn-out chat, the system dynamically generates a quick UI modal that collects all the required information at once. This not only shortens the interaction but also enhances the overall user experience.</p><p>But here’s the real challenge — what happens when the same company decides to expand from hotel bookings to co-working space reservations? Should their developers rewrite application logic, redesign forms, and build new interfaces from scratch? Ideally, no. The future of UI should allow the <em>intent</em> of the task to define the <em>interface</em>, not the other way around.</p><h3>What if?</h3><h4>AI could generate these dynamic UI for you.</h4><p>Google recently developed a Protocol called A2UI, which allows agents to generate dynamic UI safely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*za5KqsNEuZckbBhMj--kOA.png" /><figcaption>Image Generated by Google’s Nano Banana</figcaption></figure><blockquote>A2UI enables AI agents to generate rich, interactive user interfaces that render natively across web, mobile, and desktop — without executing arbitrary code.</blockquote><p>Here is a summary of what A2UI is:</p><p><strong>Key highlights:</strong></p><ul><li>Declarative UI with cross-platform support: Agents describe <em>what</em> the interface should be, not <em>how</em> to build it, typically through structured JSON. Interfaces render natively across web, mobile, and desktop platforms without additional coding effort.</li><li>Secure and sandboxed AI: By avoiding arbitrary code execution, A2UI prevents security risks while maintaining trust in the host environment.</li><li>Control over Core UI: The host application renders components using its own design system, ensuring brand and UX consistency.</li><li>Open-Source: A2UI is part of an open project that invites contributions from developers and researchers to extend its renderers and integrations, allowing faster upgrades and feature additions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ABSmqJnVD2zylPFI.png" /><figcaption>From: <a href="https://developers.googleblog.com/introducing-a2ui-an-open-project-for-agent-driven-interfaces/">Blog</a></figcaption></figure><h3>Personal Footnotes:</h3><p>This seems like a really cool idea, and I would love to have a UI that is generated to my taste and personalised to my needs. It is really exciting to see how the community is creating various tools and adapting to this rapid AI revolution.</p><h3>References</h3><ul><li><a href="https://a2ui.org/">https://a2ui.org/</a></li><li><a href="https://developers.googleblog.com/introducing-a2ui-an-open-project-for-agent-driven-interfaces/">https://developers.googleblog.com/introducing-a2ui-an-open-project-for-agent-driven-interfaces/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f0c7043ed4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Venturing into writing Tech Blogs: Here are some things I found encouraging]]></title>
            <link>https://lathashreeh.medium.com/venturing-into-writing-tech-blogs-here-are-some-things-i-found-encouraging-c7a44fbe5f5e?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7a44fbe5f5e</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[new-writers-welcome]]></category>
            <category><![CDATA[technical-blog]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 08:25:48 GMT</pubDate>
            <atom:updated>2025-07-13T08:25:48.088Z</atom:updated>
            <content:encoded><![CDATA[<p>Reflections on starting a technical blog and how it is helping me grow as a developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*O-YCGmEeCwD-k7LC" /></figure><p>Ever felt like you have learnt something new or cool and wanted to share it with the world? Ever felt like writing things down helps you understand them better?</p><p>I have — many times!</p><h3>Why Write Now?</h3><p>A few years ago, I wanted to write technical blog posts because I had started working on amazing technologies and learning a lot of new things. I tried a few times, but I could not stay consistent and never really pursued it further.</p><p>Over the past few months, I have decided to take writing seriously. It might be a simple thing I learnt, a collection of articles that helped me understand a topic better, or even something about psychology or philosophy (I love them both!).</p><p>I started focusing more on how people wrote, especially on how they captivated me from the beginning and kept me engaged till the end, and by the time I finished the article, left with a feeling that I had learnt something from it.</p><p>That feeling is best — and in my opinion, it is the purpose of writing.</p><h3>Inspiration Then and Now</h3><p><a href="https://youtu.be/YODPgBadj80">There is a talk by Quincy Larson on “Writing tech blogs”</a>, it was the best one I watched many years ago when I wanted to write, and I rewatched it again — it still inspires me to take up writing; hence, I thought of sharing it.</p><p>I have loved <strong>FreeCodeCamp</strong> for a long time — I used to read their articles and do their courses even before they were widely known. It has always been a great resource, and I am so glad they have the visibility they truly deserve :clapping a lot:</p><h3>TLDW: Key summary from the talk</h3><h3>It does not matter why you want to write.</h3><blockquote>Elaborating on that: Your motivation to write could be because you want to share insights, could be that you want your future employers to find you, could be that you are solidifying your own knowledge by sharing with the world; It does not matter why you write — What matters is that you write!</blockquote><h3>Main three lessons while writing</h3><h4><strong>Lesson 1: Substance matters — do your homework</strong></h4><ul><li>Know your topic well</li><li>You can write about the same topic in different ways, tailor it for different audiences or give more visual explanations and analogies. There is always room to add value, as long as you have put in the effort to truly learn and share your insights.</li></ul><h4><strong>Lesson 2: Packaging the substance for Consumption</strong></h4><ul><li>Once you have strong content, it is important to present it well.</li><li>For example: Do you have a good headline? Are you using visuals that help readers understand better? Is your formatting easy to read? What platform are you using? These choices significantly impact how your writing is received.</li></ul><h4><strong>Lesson 3: Publicise your writing</strong></h4><ul><li>I personally believe that gone are the days when one could say — I will do my work and people will recognise me for it. Not that technical writing is the only way, but it is a good way to present your knowledge.</li><li>Many of you working professionally probably already know — you have to advocate for yourself.</li><li>Once your content is ready and well-packaged, you will need to share it with the right people. It could be a simple LinkedIn post linking to your article. It could be sharing it in groups or forums. You need to draw people to your content and build your credibility over time.</li></ul><p>If you are someone who is thinking of writing technical blogs, I hope you make that first move, stay consistent and share that great knowledge of yours!</p><h4>Remember: <br><strong>You can write for any purpose — follow the three lessons!</strong></h4><p>Wishing you all the best.</p><p><em>Originally published at </em><a href="https://substack.com/home/post/p-168166897"><em>https://lathashree.substack.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7a44fbe5f5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ML Model Card: What Should You Include?]]></title>
            <link>https://lathashreeh.medium.com/ml-model-card-what-should-you-include-7a5f45cc9d36?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a5f45cc9d36</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[responsible-ai]]></category>
            <category><![CDATA[ai-ethics]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 18:06:51 GMT</pubDate>
            <atom:updated>2025-07-12T18:43:10.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v13jB3OxMfUN2sKJ" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is Model Card anyway?</h3><p>ML model card captures thorough information such as datasets used for development, intended usage, failure cases and evaluation results and much more.</p><p>Continuing from my previous article on <a href="https://medium.com/@lathashreeh/ai-governance-how-should-we-do-it-1d24b928135c">Responsible AI</a>, where I summarised Google’s responsible AI progress report. I wanted to document further about the concept of <strong>“Model card”</strong> — its general structure, purpose and why it&#39;s needed in ML workflows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*EFUqWzVWCc52WCk3_LycnA.png" /><figcaption>Google’s recommendation of a model card [from a <a href="https://arxiv.org/abs/1810.03993">paper</a> published in 2019]</figcaption></figure><h3>What can/should it have?</h3><p>A model card is a standardised documentation framework introduced to enhance transparency and accountability in ML systems. It provides critical metadata about an ML model. Typically, a well-structured model card could include sections such as:</p><ul><li><strong>Model details</strong>: A description of what the model does, its architecture, and its version.</li><li><strong>Intended use</strong>: Context and applications where the model is suitable, along with explicitly stated <em>out-of-scope</em> use cases.</li><li><strong>Training and evaluation datasets</strong>: Detailed information on the datasets used for training, validation, and testing, including any preprocessing steps.</li><li><strong>Factors: </strong>Model cards ideally provide a summary of model performance across a variety of relevant factors, including groups, instrumentation, and environments.</li><li><strong>Metrics</strong>: The chosen evaluation metrics should reflect the potential real-world impacts of the model.</li><li><strong>Ethical considerations</strong>: Acknowledgement of potential harms, misuse scenarios or societal impacts.</li><li><strong>Limitations and recommendations</strong>: Areas where the model may underperform or produce unreliable results. Any recommendations towards using the model could also be provided to give a better understanding to the user.</li></ul><p>Model cards act as an internal checkpoint during development and a communication tool for external stakeholders. They also support reproducibility, regulatory compliance, and responsible deployment practices, especially important as ML systems continue to be integrated into high-stakes domains. There are also multiple variations of model cards, such as those used for <a href="https://github.com/openai/gpt-3/blob/master/model-card.md">GPT-3</a> or <a href="https://huggingface.co/docs/hub/en/model-cards">models hosted on Hugging Face</a>.</p><h4>Example Model Card:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*EbEzJqATq7fznLbNR_iqtg.png" /><figcaption>An example model card from the paper</figcaption></figure><h3>Finally,</h3><p>I strongly believe the model cards are not one-size-fits-all. The depth and level of details often depend on who is using the model and how mature the team’s MLOps practices are. Nonetheless, model cards should be treated as living documents, something you revisit, refine and improve over time as part of building AI responsibly and transparently.</p><h3>References</h3><ul><li>Paper “Model cards for Model Reporting”: <a href="https://arxiv.org/pdf/1810.03993">https://arxiv.org/pdf/1810.03993</a></li><li>HuggingFace write-up on Model Cards: <a href="https://huggingface.co/docs/hub/en/model-cards">https://huggingface.co/docs/hub/en/model-cards</a></li><li>OpenAI GPT-3 Model Card: <a href="https://github.com/openai/gpt-3/blob/master/model-card.md">https://github.com/openai/gpt-3/blob/master/model-card.md</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a5f45cc9d36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Governance and Responsible AI: Key Takeaways from Google’s Progress Report]]></title>
            <link>https://lathashreeh.medium.com/ai-governance-how-should-we-do-it-1d24b928135c?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d24b928135c</guid>
            <category><![CDATA[ai-ethics]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[governance]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Fri, 27 Jun 2025 00:13:10 GMT</pubDate>
            <atom:updated>2025-07-12T18:43:52.138Z</atom:updated>
            <content:encoded><![CDATA[<p>Building AI responsibly requires collaboration among researchers, developers, regulators, and end users. Embedding ethical safeguards and governance practices throughout the AI lifecycle helps foster trust in AI systems and ensures alignment with human values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RZGG5kydj81yo9NS" /><figcaption>Photo by <a href="https://unsplash.com/@amstram?utm_source=medium&amp;utm_medium=referral">Scott Graham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is AI Governance?</h3><p>AI governance refers to the framework of policies, processes and practices that ensure the responsible development and use of AI systems. It aims to maximise the benefits of AI while minimising potential harms and risks, such as bias, lack of transparency and ethical concerns. Effective AI governance requires collaboration between various stakeholders, including governments, tech companies, researchers, and the public.</p><h3>AI Governance in Practice: Google’s Approach</h3><p>In February 2025, Google published a detailed report outlining its end-to-end AI governance framework, showcasing how it builds responsible AI at scale. The report explains how Google integrates responsible practices across infrastructure, model development, and product deployment to manage AI systems at scale.</p><h3>What is “Full-Stack” Governance?</h3><p>Google’s framework emphasises that governance cannot be an afterthought but must be embedded throughout the AI lifecycle, involving:</p><ul><li>Data curation and documentation</li><li>Model development and evaluation</li><li>Application design and launch</li><li>Post-deployment monitoring and iteration</li></ul><p>This “full-stack” perspective combines technical, organisational, and procedural elements to embed responsibility into every stage.</p><h3>Key highlights</h3><p>Google’s governance principles and approach are based on the <a href="https://airc.nist.gov/airmf-resources/playbook/">NIST AI Risk Management Framework</a> and focus on governance, mapping, measuring, and managing risks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*rd87MK8vXutAP1QSk-ke-g.png" /><figcaption>Google’s AI governance approach</figcaption></figure><h3>Tackling pre- and post-launch reviews of AI systems</h3><h4>Model requirements</h4><p>Google mandates that all models meet rigorous standards for data quality, performance, and compliance:</p><ul><li>Training data is filtered to remove harmful or low-quality content.</li><li>Models must adhere to defined responsible AI principles.</li><li>Each model is accompanied by technical reports and model cards, which document performance, intended use, and limitations.</li></ul><h4>Application requirements</h4><p>Before any AI-powered application goes live, it must pass several governance gates:</p><ul><li>Risk assessments, testing and design guidance</li><li>Human-in-the-loop design reviews</li><li>Adherence to launch protocols tailored for high-risk domains (e.g., health, applications developed for minors)</li></ul><h4>Leadership reviews</h4><p>One of the report’s standout features is the emphasis on cross-functional leadership reviews. Executives with expertise in responsible AI are directly involved in go/no-go decisions for launches, reinforcing accountability at the highest levels.</p><h4>Post-launch requirements</h4><p>Governance continues <strong>after launch</strong>, with ongoing evaluations of:</p><ul><li>Emerging risks (such as model drifts, misuse of products)</li><li>User feedback and real-world performance</li><li>Gaps in mitigation strategies and policies that only appear at scale</li></ul><p>Post-launch reviews are treated not as optional retrospectives, but as core governance events.</p><h4>Infrastructure used for launching applications</h4><p>The infrastructure is continuously streamlined for AI applications, responsibility testing and progress monitoring.</p><h3>Documentation</h3><p>Google places significant emphasis on rigorous model documentation as part of its AI governance framework. Technical reports are routinely published for advanced models, offering in-depth detail on model design, training data, evaluation procedures, and intended use cases. These reports are complemented by model cards, which present key information in a standardised, accessible format designed for developers and for policy stakeholders.</p><h4>Model Cards</h4><p>External model cards and technical reports are published regularly as transparency artefacts. Below is an example of Google’s suggestion for a model card in 2019 [<a href="https://arxiv.org/pdf/1901.10002">paper</a>]. While the format has evolved, the core principle of transparent, standardised model documentation gives a really good picture of the model’s development and capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*vksnw0ns5mprA9yj3EGZxg.png" /><figcaption>Google’s model card suggestion from 2019</figcaption></figure><h4>Data and Model lineage</h4><p>To support responsible scaling of AI systems, Google is also investing in infrastructure for data and model lineage tracking, which involves maintaining end-to-end visibility into the lifecycle of datasets and models. Such lineage systems are critical for debugging, compliance, and auditability, particularly in high-stakes applications where traceability is non-negotiable. By embedding lineage as a core technical capability, Google ensures that every AI system it deploys can be examined retrospectively with clarity on provenance and transformation history.</p><h3>Conclusion</h3><p>Overall, Google’s report presents a thorough and technically grounded AI governance framework. Its focus on documentation, post-deployment oversight, and lineage demonstrates an institutional commitment to responsible AI.</p><p>While the specific mechanisms may vary across organisations, the underlying principles of transparency, traceability and cross-functional oversight are essential components of responsible AI development.</p><h3>References</h3><ul><li>Google’s responsible AI progress report: <a href="https://ai.google/static/documents/ai-responsibility-update-published-february-2025.pdf">https://ai.google/static/documents/ai-responsibility-update-published-february-2025.pdf</a></li><li>NIST AI Risk Management Framework: <a href="https://airc.nist.gov/airmf-resources/playbook/">https://airc.nist.gov/airmf-resources/playbook/</a></li><li>“Model Cards for Model Reporting” paper: <a href="https://arxiv.org/abs/1810.03993">https://arxiv.org/abs/1810.03993</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d24b928135c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAG Architecture Made Simple: A Guide to Indexing and Inference Pipelines]]></title>
            <link>https://lathashreeh.medium.com/rag-architecture-keeping-it-simple-17677ee3ade9?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/17677ee3ade9</guid>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[production-ml]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Mon, 09 Jun 2025 13:05:33 GMT</pubDate>
            <atom:updated>2025-07-12T18:45:05.984Z</atom:updated>
            <content:encoded><![CDATA[<p>Grounding the LLM to the data you care about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L4GsVEZuOEireODg" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As our interactions with AI and conversational systems become increasingly common, we’ve all experienced moments where a chatbot drifts off-topic, discussing irrelevant information when we’re seeking answers grounded in a specific context. The key challenge is ensuring that the chatbot stays focused on the data or document we care about and generates responses based on that context. This is precisely where <strong>Retrieval-Augmented Generation (RAG)</strong> proves valuable.</p><h3><strong>Retrieval-Augmented Generation</strong></h3><p>RAG is a hybrid architecture that combines two key components: a <strong>retriever</strong> and a <strong>generator</strong>.</p><p>The retriever is responsible for fetching relevant pieces of information from a large corpus or knowledge base, while the generator (typically a large language model) uses this retrieved content to craft a context-aware response. This architecture aims to ground the model’s output in facts and domain-specific data, thus improving relevance, factual accuracy, and controllability.</p><p>Traditional LLMs, when used in isolation, rely solely on their pre-trained parameters to answer questions. This leads to a few key limitations:</p><ul><li>They may hallucinate facts.</li><li>They cannot access new or proprietary information unless they are fine-tuned on it.</li><li>They struggle to stay within a defined domain of knowledge.</li></ul><p>RAG addresses these issues by introducing an <strong>external source of truth</strong> during the inference process.</p><p>A typical RAG system consists of two main stages: <strong>indexing</strong> and <strong>inference</strong>.</p><h4>Indexing Phase</h4><p>This phase involves preparing and storing the documents in a form suitable for retrieval at inference time. A simple indexing pipeline may look like the following:</p><ol><li><strong>Document Ingestion</strong><br> Start with a collection of documents, which may be in formats such as PDFs, Word files, HTML, or plain text.</li><li><strong>Parsing and Preprocessing</strong><br>Use document parsers (e.g. PDF readers) to extract raw text content. This may also include removing boilerplate, normalising whitespace, or handling non-textual elements.</li><li><strong>Chunking</strong><br> Split the documents into smaller, manageable chunks (by paragraphs or sliding windows of N tokens). It’s important that each chunk contains enough and semantically meaningful information, so it can provide relevant context to our LLM during generation.</li><li><strong>Embedding Generation</strong><br>Use a sentence embedding model (e.g. Sentence-BERT, OpenAI’s text-embedding-3-small, or Cohere embeddings) to convert each chunk into a dense vector representation.</li><li><strong>Storage in Vector Database</strong><br>Store these embeddings in a vector database alongside metadata like document ID, source and text. This allows for efficient similarity search for retrieval at inference time.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5p6BBWcTz1qlMLp4WqoW4g.png" /><figcaption>Simple document indexing pipeline for RAG systems</figcaption></figure><h4>Inference Phase</h4><p>When a user submits a query, the system goes through the following steps:</p><ol><li><strong>Query Embedding</strong><br>The input query is converted into a dense vector using the same embedding model employed during the indexing phase. This ensures alignment in vector space between the query and document chunks.</li><li><strong>Context Retrieval</strong><br>The query embedding is used to perform a similarity search, typically using cosine similarity or approximate nearest neighbours, in the vector database. This retrieves the top-K most relevant document chunks based on semantic similarity.</li><li><strong>LLM Input Construction</strong><br>The retrieved chunks are formatted and injected into the input prompt of the language model, along with the original user query.</li><li><strong>LLM Generation and Output Post-processing</strong><br>The LLM generates a response grounded in the retrieved context. This output may be post-processed to enforce constraints such as user-specific policies, safety filters, or formatting requirements. The final response is then returned to the user.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGUAbosUUqu9lkX2pYznlA.png" /><figcaption>Simple RAG-based inference pipeline</figcaption></figure><h3>Conclusion</h3><p>RAG provides a robust framework for building context-aware, domain-specific AI systems by combining the strengths of information retrieval with large language models. By grounding responses in retrieved content, RAG systems improve factual accuracy and enable dynamic knowledge integration.</p><p>There are numerous optimisation strategies for deploying RAG-based applications in production. I highly encourage exploring these in depth, and I plan to share some of the techniques I have used in my own projects in upcoming articles.</p><p>Ultimately, as the demand for trustworthy and adaptable AI grows, RAG stands out as a practical and scalable solution for real-world applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17677ee3ade9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the LLM’s inference]]></title>
            <link>https://lathashreeh.medium.com/understanding-the-llms-inference-36a767f98a83?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/36a767f98a83</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llm-inference]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 10:03:13 GMT</pubDate>
            <atom:updated>2025-06-11T12:23:39.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*80b4bJAk8gU8EC4Z" /><figcaption>Photo by <a href="https://unsplash.com/@dbeamer_jpg?utm_source=medium&amp;utm_medium=referral">Drew Beamer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>LLMs have revolutionised natural language understanding and generation. Whether you are building chatbots, drafting emails, or generating code, a trained model runs in the backend to produce outputs from users’ inputs. However, the process of inference is more nuanced than “feed in a prompt and receive text.”</p><p>In this article, we will explore the two main stages of autoregressive LLM inference, namely as <strong>Prefill</strong> phase and the <strong>Decode</strong> phase. I will also delve into practical techniques for controlling output length, mitigating repetitiveness, and leveraging beam search.</p><p>By the end, you should have a better technical understanding of how LLMs generate text and how you can steer them towards desired behaviours.</p><h3>Overview of Autoregressive Inference</h3><p>Most recent LLMs (e.g. GPT-style models) are autoregressive, meaning they generate text one token at a time, conditioning on all previously generated tokens.</p><p>At a high level, the process has two phases:</p><ol><li><strong>Prefill (Prompt Encoding):</strong> The model processes the user’s prompt in full, producing hidden states (and typically key-value caches) that summarise the prompt’s content.</li><li><strong>Decode (Autoregressive Generation):</strong> The model enters a loop, where at each step it takes the hidden state of the tokens generated so far, predicts a distribution over the next token, samples or selects one, appends it to the sequence, and updates its hidden state (via cached keys/values).</li></ol><p>Understanding the distinction between these phases is crucial for optimising latency and for implementing decoding strategies that influence output quality.</p><h3>Prefill Phase</h3><p>When you supply a prompt, say, “Once upon a time, in a distant kingdom…” the model must convert each token in that input text into internal representations. This involves several steps:</p><h4>Tokenisation</h4><p>The input text is split into units called <em>tokens</em>, which are then encoded to obtain corresponding numbers (called <em>token_id) </em>for the substrings from a predefined vocabulary.</p><h4>Embedding Lookup</h4><p>Each <em>token_id</em> is mapped to a dense vector (<em>token embedding</em>), and a <em>positional embedding</em> is added to capture the positional information of each token in the sequence.</p><h4>Attention Mechanism</h4><p>The embedded tokens are processed by a stack of transformer blocks, each comprising:</p><ul><li><strong>Self-attention</strong> enables each token to attend to all others in the input sequence, capturing contextual relationships.</li><li><strong>Feed-forward networks</strong> apply nonlinear transformations to each token.</li></ul><h4>Key-Value Cache Construction</h4><p>In decoder-only architectures, each transformer layer outputs <em>key</em> and <em>value</em> matrices used in future attention computations. Caching these avoids recomputing attention from scratch at every decode step.</p><p>Once the prefill is done, the model holds a “snapshot” of hidden states and caches representing the entire input sequence.</p><h3>Practical Considerations</h3><h4>Latency vs. Throughput</h4><ul><li>Prefill is a one-time cost per prompt.</li><li>Decode occurs once per generated token.</li><li>For long completions, caching substantially reduces compute; for short completions, the prefill overhead might dominate.</li></ul><h4>Batching</h4><ul><li>Multiple prompts can be processed in parallel during prefill.</li><li>However, batching increases the chance that fast requests are delayed by slow ones.</li><li>Optimal batch sizing balances GPU utilisation and end-to-end latency.</li></ul><h4>Memory Footprint</h4><ul><li>Caches grow with sequence length, hidden size, and number of layers.</li><li>For high-throughput systems, careful memory management is essential, especially with long prompts or large batch sizes.</li></ul><h3>Decode Phase</h3><p>After prefill, the model enters the autoregressive loop:</p><ol><li>Take the hidden state of the last token.</li><li>Compute attention over cached key-value pairs.</li><li>Predict the distribution over the vocabulary.</li><li>Determine the next token (via greedy, top-k, nucleus sampling, or beam search).</li><li>Append the token to the sequence.</li><li>Update the cache with the new token’s key and value.</li></ol><p>This loop continues until a stop condition is met which would commonly be an end-of-sequence token or a maximum token limit.</p><h3>Output Control Techniques</h3><h4>Greedy Sampling</h4><p>Greedy sampling basically chooses the next token based on the highest probability it can achieve at every step.</p><h4>Beam Search</h4><p>Unlike greedy sampling, Beam search maintains multiple paths in parallel, expanding the most promising sequences. This helps the model to overlook more than just the next maximising token. This improves coherence at the cost of computation.</p><h4>Temperature and Top-k/Nucleus Sampling</h4><ul><li><strong>Temperature</strong> controls the randomness of sampling. This is applied as a scaling factor for the output logits before the softmax operation to control generation to be more deterministic or non-deterministic. Higher temperature values scale the distribution more and introduce a non-deterministic nature for next token selection and vice versa.</li><li><strong>Top-k sampling</strong> restricts choices to the k most likely tokens and randomly samples out of the top-k tokens.</li><li><strong>Nucleus (top-p) sampling</strong> chooses from the smallest set of tokens whose cumulative probability exceeds p.</li></ul><h4>Length Penalty and Max Tokens</h4><p>To prevent overly long or short generations, users can set maximum token limits and apply length penalties to the generation score.</p><h4>Repetition Penalty</h4><p>Models often repeat phrases. A repetition penalty modifies the logits of already-used tokens to discourage reuse.</p><h3>Conclusion</h3><p>Understanding how LLMs perform inference is vital for building efficient and responsive applications. The prefill and decode phases involve different trade-offs, from latency and memory to sampling and quality. With the right strategies like caching, batching, and careful sampling, you can harness the full potential of LLMs for your application needs.</p><h3>References</h3><ul><li>LLM inference: <a href="https://huggingface.co/learn/llm-course/chapter1/8?fw=pt#inference-with-llms">https://huggingface.co/learn/llm-course/chapter1/8?fw=pt#inference-with-llms</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36a767f98a83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long Tail Object Detection - How do we deal with it?]]></title>
            <link>https://lathashreeh.medium.com/dealing-with-long-tailed-object-detection-c8666485f356?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8666485f356</guid>
            <category><![CDATA[ml-system-design]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 17:48:51 GMT</pubDate>
            <atom:updated>2025-06-11T12:28:55.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_UZmpGS82m6d23u_" /><figcaption><a href="https://unsplash.com/@cferdo?utm_source=medium&amp;utm_medium=referral">Fernando @cferdophotography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Long tail Object Detection</h3><p>In many real-world datasets, object classes follow a varied distribution, a few classes are very common, while many others appear infrequently. For example, you will see a huge amount of data on cats and dogs, but not a lot on specific species. Frequently occurring classes are called “head” and rare data classes are called “tail” classes. Performing object detection using such a dataset poses a set of challenges:</p><ul><li>Models become biased towards head classes</li><li>Tail classes suffer from poor generalisation due to limited data</li></ul><p>So, how can we improve feature learning so the model can perform well across the full spectrum of class frequencies?</p><h3>Popular methods to mitigate Long-tailed object detection</h3><p>The most popular ways to mitigate long-tailed object detection can be divided into two categories:</p><h4>Data-level strategy</h4><ol><li>Address the class imbalance by resampling — Under-sampling the majority classes and over-sampling the minority classes</li><li>Use open-source datasets to increase the minority classes</li><li>Increase the dataset by augmentations or generate synthetic datasets</li></ol><h4>Model-level or Architecture-level strategy</h4><ol><li>Add weightage to the loss function where you penalise the wrong predictions on minority classes more than the majority classes</li><li>Use a loss function that handles the class imbalance. E.g.. Focal loss</li><li>Leverage a pre-trained model backbone</li></ol><p>These are really great strategies to address the class imbalance and enhance the model&#39;s learning. However, these pre-training paradigms leave some key detection components randomly initialised and tend to overlook the suboptimal performance issues caused by long-tailed distributions during the pre-training process.</p><p>In one of the recent papers, I read a nice way to mitigate the long-tailed distribution targeting from the pretraining phase using contrastive learning.</p><h4>Quick Refresher on Contrastive Learning</h4><p><strong><em>Contrastive learning</em></strong> is a self-supervised approach that helps models learn useful representations by comparing data samples.</p><p>The core idea is to bring similar samples (called positives) closer in the feature space while pushing dissimilar ones (negatives) apart. In the computer vision domain tasks, this often involves taking two augmented views of the same image as positives, and treating views from other images as negatives. This encourages the model to focus on underlying semantic features rather than low-level noise.</p><p>It’s a foundational idea behind methods like SimCLR and MoCo, and has been widely adopted in pre-training for tasks such as classification and detection.</p><h4>Long-Tailed Object Detection Pre-training: Dynamic Rebalancing Contrastive Learning with Dual Reconstruction</h4><p>The paper stresses the importance of pretraining, as it plays a crucial role in object detection, especially when the data is imbalanced. It introduces a framework called Dynamic Rebalancing Contrastive Learning with Dual Reconstruction, which consists of three components: Holistic-Local Contrastive Learning, Dynamic Rebalancing, and Dual Reconstruction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*p4wKf5I_oRZfR-Z9hyMiuQ.png" /><figcaption>Proposed method <a href="https://arxiv.org/pdf/2411.09453">paper</a></figcaption></figure><h4>Holistic-Local Contrastive Learning (HLCL)</h4><p>This module aims to pretrain both the backbone and the detection head by encouraging learning at both global (image) and local (object proposal) levels.</p><ul><li>Holistic Contrastive Learning (HCL): Learns general visual features from the entire image using augmented views.</li><li>Local Contrastive Learning (LCL): Focuses on features from object proposals generated by a class-agnostic region proposal network.</li></ul><h4>Dynamic Rebalancing</h4><p>This part focuses on improving representation learning for tail classes by dynamically resampling the training data.</p><p>Unlike traditional methods like Repeat Factor Sampling (RFS), this method looks at:</p><ul><li>How often does each class appear across images (image-level)</li><li>How many object instances belong to each class (instance-level)</li></ul><p>It calculates a harmonic mean of both to get a balanced repeat factor, which shifts over time to focus more on instance-level balancing as training progresses.</p><h4>Dual Reconstruction</h4><p>To counter simplicity bias (where models overly rely on shortcuts), this module encourages the model to learn both visual fidelity and semantic consistency.</p><ul><li>Appearance Reconstruction: Reconstructs the original image from features using a pixel-wise loss.</li><li>Semantic Reconstruction: Applies a mask to the reconstructed image and ensures the features remain consistent with the original.</li></ul><h4>Summary</h4><p>By dynamically rebalancing training focus and enforcing both visual fidelity and semantic consistency, it significantly improves the quality of pre-trained representations. These enhancements lay a strong foundation for building object detectors that perform robustly across diverse and imbalanced datasets. It is an elegant and robust way to:</p><ul><li>Align pretraining with downstream object detection</li><li>Adaptively rebalance class distributions</li><li>Preserve both low-level and high-level representations</li></ul><h3>References</h3><ul><li>Long-Tailed Object Detection Pre-training: Dynamic Rebalancing Contrastive Learning with Dual Reconstruction <a href="https://arxiv.org/pdf/2411.09453">https://arxiv.org/pdf/2411.09453</a></li><li>A wonderful blog on Contrastive Learning — <a href="https://lilianweng.github.io/posts/2021-05-31-contrastive/">https://lilianweng.github.io/posts/2021-05-31-contrastive/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8666485f356" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Types of Training for Large Language Models]]></title>
            <link>https://lathashreeh.medium.com/understanding-the-types-of-training-for-large-language-models-c728ec8b205b?source=rss-315f28d8d7b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c728ec8b205b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Lathashree Harisha]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 12:56:42 GMT</pubDate>
            <atom:updated>2025-06-11T22:57:26.780Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Types of training for LLMs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OJc3QfmEJM3aMBSt" /><figcaption>Photo by <a href="https://unsplash.com/@tjerwin?utm_source=medium&amp;utm_medium=referral">Trent Erwin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Pretraining, Fine-tuning, and Instruction Tuning Explained</h3><p>The rise of Large Language Models (LLMs) like GPT, Gemini, and LLaMA has revolutionised natural language processing by enabling models to perform diverse tasks with minimal task-specific supervision. Central to their effectiveness is the <strong>multi-stage training process</strong> these models undergo, training phases such as <strong>pretraining</strong>, <strong>fine-tuning</strong>, and increasingly, <strong>instruction tuning </strong>for certain use cases where a user instruction needs to be followed.</p><p>Understanding these stages is essential for aspiring ML engineers and organisations leveraging foundation models. Here’s a short breakdown of what each training phase entails, why it matters, and how they differ.</p><h3>Pretraining: Learning the Foundations</h3><p><strong>Objective:</strong> Equip the model with a general understanding of language, grammar, reasoning patterns, and world knowledge.</p><p><strong>Approach:</strong><br> Pretraining is carried out on vast amounts of <strong>unlabelled text</strong> using <strong>self-supervised learning</strong>. In the case of GPT-style models (decoder-only), this means <strong>causal language modelling</strong> — predicting the next token given the previous ones.</p><p><strong>Data Sources:</strong></p><ul><li>Books, articles, websites (e.g., Common Crawl)</li><li>Code (e.g., GitHub)</li><li>Multilingual corpora</li></ul><p><strong>Outcome:</strong><br> The model becomes a <strong>foundation model</strong> — a general-purpose LLM capable of understanding and generating natural language.</p><blockquote>Example:<em> GPT-3 is pretrained on 300+ billion tokens from a wide range of internet sources, without any explicit task-specific labels.</em></blockquote><h3>Post Training</h3><h3>Fine-Tuning: Specialising for Specific Tasks</h3><p><strong>Objective:</strong> Adapt the pretrained model to perform a <strong>specific downstream task</strong> such as sentiment analysis, named entity recognition, summarisation, or domain-specific QA.</p><p><strong>Approach:</strong><br>Fine-tuning uses <strong>supervised learning</strong> on <strong>labelled datasets</strong>, where the model is trained to map from inputs to expected outputs.</p><ul><li>Often involves a smaller, task-specific dataset.</li><li>Can update all model parameters (full fine-tuning) or just a subset (e.g. adapters, LoRA, or QLoRA).</li></ul><p><strong>Examples of Tasks:</strong></p><ul><li>Text classification</li><li>Medical or legal domain QA</li><li>Multimodal extensions (e.g., VQA)</li></ul><p><strong>Why it matters:</strong><br> Fine-tuning enables customisation and improves performance in specialised contexts, making the model practical for real-world applications.</p><blockquote>Example:<em> Fine-tuning GPT on financial documents to improve reasoning over balance sheets and contracts.</em></blockquote><h3>Supervised Fine-tuning or Instruction Tuning: Making Models Follow Directions</h3><p><strong>Objective:</strong> Teach the model to <strong>follow instructions</strong> and perform multiple tasks based on natural language prompts.</p><p><strong>Approach:</strong><br>Instruction tuning is a form of <strong>supervised fine-tuning</strong>, but instead of training on isolated tasks, the model is trained on a diverse set of <strong>instruction–response pairs</strong>.</p><ul><li>Prompt: “Translate this sentence into French.”</li><li>Response: “Voici la phrase traduite en français.”</li></ul><p>Instruction tuning is typically done after pretraining (and sometimes after fine-tuning), enabling models to generalise to unseen instructions.</p><p><strong>Why it matters:</strong><br> This step dramatically improves usability by aligning the model’s behaviour with human expectations, making it more helpful, reliable, and controllable.</p><blockquote>Example:<em> InstructGPT outperforms GPT-3 on many NLP tasks despite being smaller, thanks to instruction tuning on prompt–response examples.</em></blockquote><h3>Preference Tuning (PreFT)</h3><p>A post-training technique that aligns the LLM to human preferences. Initially collect human preferences and use that data to align LLMs</p><h3>Conclusion</h3><p>The journey from raw text to task-aware intelligence involves strategically combining <strong>pretraining</strong>, <strong>fine-tuning</strong>, and <strong>instruction tuning</strong>. Each phase builds upon the previous one, starting from foundational knowledge, to specialised skills, and ultimately to usable, aligned behaviour.</p><p>As models continue to scale and evolve, mastering these training paradigms is crucial for deploying LLMs safely and effectively in real-world systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c728ec8b205b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>