<?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 Alan Ponnachan on Medium]]></title>
        <description><![CDATA[Stories by Alan Ponnachan on Medium]]></description>
        <link>https://medium.com/@alanml23?source=rss-a2c05f3d5b6e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xRbAhj7_8gYQnt36ypcoIw.jpeg</url>
            <title>Stories by Alan Ponnachan on Medium</title>
            <link>https://medium.com/@alanml23?source=rss-a2c05f3d5b6e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:28:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alanml23/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[I Read the 1400-Paper “Context Engineering” Survey. Here’s What’s Changing for LLMs]]></title>
            <link>https://medium.com/@alanml23/i-read-the-1400-paper-context-engineering-survey-heres-what-s-changing-for-llms-951dd8bda7f3?source=rss-a2c05f3d5b6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/951dd8bda7f3</guid>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[research-paper]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[context-engineering]]></category>
            <dc:creator><![CDATA[Alan Ponnachan]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 16:27:11 GMT</pubDate>
            <atom:updated>2025-07-31T15:38:25.049Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve built anything with a Large Language Model, you know the feeling. Your proof-of-concept works beautifully, but when you scale it up — feeding it longer documents, more complex data, or a longer chat history — the model gets lost. It forgets instructions, hallucinates facts, and its once-sharp reasoning dulls completely. For a long time, we’ve treated this as a “prompt engineering” problem, a kind of dark art of coaxing the model to behave.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y2aDMDlCVa8b3YbXOoXxuQ.png" /><figcaption>AI Image generated by Author</figcaption></figure><p>But what if that’s the wrong frame entirely?</p><p>A groundbreaking new survey, “<a href="https://arxiv.org/abs/2507.13334">A Survey of Context Engineering for Large Language Models</a>,” synthesizes findings from over 1400 research papers to make a powerful argument: we need to move beyond simple prompt design and embrace a more rigorous discipline. This paper introduces <strong>Context Engineering</strong>, the formal science of designing, managing, and optimizing the entire information payload an LLM receives.</p><p>This paper provides a technical roadmap for building the next generation of AI systems. I’ve gone through the paper to distill the most critical concepts for practitioners. We’ll break down the paper’s core framework, explore its key components, and uncover its single most important — and sobering — finding about the future of LLMs.</p><h3>From Art to Science: What Exactly is Context Engineering?</h3><p>For years, our interaction with LLMs has been defined by “prompt engineering.” We treat the context window as a monolithic block of text and iterate manually until we get the output we want. It’s effective, but it’s brittle and unscalable.</p><p>Context Engineering proposes a shift from this artistic approach to a systematic, scientific one. It re-conceptualizes the context C not as a single string, but as a dynamically assembled structure of distinct informational components. In the paper, this is formalized as a function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*GW6p1DLZw-KeXuSvpY6CcA.png" /></figure><p>Let’s quickly break that down :</p><ul><li><strong>c_instr</strong>: The system instructions or rules.</li><li><strong>c_know</strong>: External knowledge, likely retrieved from a vector database (the RAG component).</li><li><strong>c_tools</strong>: Definitions of available tools or APIs the model can use.</li><li><strong>c_mem</strong>: Persistent memory from prior interactions.</li><li><strong>c_state</strong>: The current dynamic state of the user, world, or agent system.</li><li><strong>c_query</strong>: The user’s actual, immediate request.</li><li><strong>A(…)</strong>: The high-level assembly function that orchestrates all these pieces.</li></ul><p>The goal is no longer to just find a good prompt, but to find the optimal set of <em>functions</em> that generate and assemble these components. The paper defines this as a formal optimization problem, which solidifies the “engineering” discipline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*xwYesUM6wonR8kspN3dRaw.png" /></figure><p>This equation seeks to find the ideal set of functions that maximize the expected quality (the Reward) of the LLM’s output across a distribution of tasks.</p><p>The difference is profound. It’s the difference between writing a one-off SQL query (Prompt Engineering) and designing an entire data warehousing strategy with ETL pipelines, caching layers, and access controls (Context Engineering).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*93-DDve2dcijbfe1vwNWAg.png" /><figcaption>Comparison of Prompt Engineering and Context Engineering Paradigms.</figcaption></figure><p>This framework gives us a new vocabulary to diagnose problems and design solutions.</p><h3>The Building Blocks: The Foundational Components</h3><p>The survey organizes the field into a clear taxonomy. The first layer is the <strong>Foundational Components</strong> — the core technical capabilities required for effective context manipulation. Think of these as the raw parts in your toolkit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*E5dNhb5fmxI2wLaEURmgww.png" /></figure><h4>Context Retrieval and Generation</h4><p>This is all about sourcing the right information. It includes the classic prompt engineering strategies we know and love, like Chain-of-Thought (CoT) and Zero-shot CoT, which help the model structure its reasoning. More importantly, it covers the retrieval of external knowledge from databases, documents, and knowledge graphs — the heart of Retrieval-Augmented Generation (RAG).</p><h4>Context Processing</h4><p>Once you have the information, you need to process it. This component deals with some of the thorniest challenges in AI today. It includes techniques for handling <strong>long sequences</strong> and mitigating the infamous “lost-in-the-middle” problem where models forget information buried deep in the context. It also covers crucial <strong>self-refinement</strong> mechanisms, where a model iteratively critiques and improves its own output, like in the Self-Refine and Reflexion frameworks.</p><h4>Context Management</h4><p>Finally, how do you efficiently organize and store this information? Context Management addresses the fundamental constraints of the context window. This involves creating <strong>memory hierarchies</strong> (similar to a computer’s RAM and SSD) and developing <strong>compression techniques</strong> to pack more information into a limited space. Systems like MemGPT, which uses OS-inspired paging to move information between fast and slow memory, are prime examples.</p><h3>Assembling the Engine: Sophisticated System Implementations</h3><p>If the components are the parts, the <strong>System Implementations</strong> are the fully assembled engines. These are the complex, application-oriented systems that integrate the foundational building blocks to solve real-world problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*nYpB1EndvyNsnROPdCnTjw.png" /><figcaption>Taxonomy of Context Engineering in Large Language Models</figcaption></figure><h4>Advanced Retrieval-Augmented Generation (RAG)</h4><p>This is RAG 2.0. We’re moving past the naive “retrieve-then-read” pattern. Modern systems are becoming more dynamic and intelligent.</p><ul><li><strong>Modular RAG:</strong> These systems have reconfigurable parts for query rewriting, routing, and fusion, allowing for more flexible and robust pipelines.</li><li><strong>Agentic RAG:</strong> Here, the retriever is an autonomous agent that can reason about what it needs to find, perform multiple searches, and synthesize results.</li><li><strong>Graph-Enhanced RAG:</strong> Instead of just retrieving text chunks, these systems traverse knowledge graphs to find structured information and relationships, leading to far more precise answers.</li></ul><h4>Memory Systems</h4><p>These implementations aim to solve one of the biggest limitations of LLMs: their statelessness. By integrating the components of Context Management, these systems give models persistent memory, allowing them to learn from past interactions, recall user preferences, and maintain continuity over long periods.</p><h4>Tool-Integrated Reasoning</h4><p>An LLM that can only talk is a novelty. An LLM that can <em>act</em> is a tool. This area focuses on giving models the ability to use external tools, from calling a weather API and running Python code to executing complex database queries. The model’s reasoning process is tightly integrated with tool use, allowing it to generate context by actively interacting with its environment.</p><h4>Multi-Agent Systems</h4><p>This is the pinnacle of Context Engineering, where multiple specialized AI agents collaborate to solve a problem. Each agent has its own context, but they share information and coordinate their actions through sophisticated communication and orchestration protocols. Frameworks like AutoGen and CrewAI are popular examples, enabling complex workflows where one agent writes code, another tests it, and a third writes the documentation.</p><h3>The Sobering Truth: The Great Asymmetry of LLMs</h3><p>After laying out this incredible landscape of progress, the survey delivers its most critical and thought-provoking conclusion: a fundamental asymmetry exists between an LLM’s ability to <strong>understand</strong> context and its ability to <strong>generate</strong> it.</p><p>This is the <strong>“comprehension-generation gap,”</strong> and it’s the most important bottleneck you will face as a practitioner today.</p><p>What does this mean? We are getting incredibly good at building systems that allow an LLM to <em>comprehend</em> vast and complex contexts. With advanced RAG, long-context windows, and memory systems, we can feed a model an entire textbook, a codebase, or a year’s worth of financial data. The model can process this information and answer specific questions with remarkable accuracy.</p><p>However, these same models are still profoundly limited in their ability to <em>generate</em> outputs of similar complexity, coherence, and length. Ask a model that just ingested a textbook to write a new, original chapter, and you’ll likely get a rambling, repetitive, and shallow response. Ask a model that analyzed an entire codebase to write a new, complex module from scratch, and it will struggle.</p><p>This is the core challenge. The bottleneck is shifting from the <em>input</em> to the <em>output</em>. We’ve gotten great at the logistics of information delivery, but the model’s internal creative and planning faculties haven’t kept pace.</p><h3>Conclusion: We Are All Context Architects Now</h3><p>The “Survey of Context Engineering” is more than just a summary of research; it’s a call to action. It urges us to graduate from being “prompt whisperers” and become “AI information architects.”</p><p>The key takeaways are clear:</p><ol><li><strong>Embrace the Paradigm:</strong> Start thinking about your LLM applications in terms of Context Engineering. Deconstruct your system into its components: retrieval, processing, and management. This structured approach will make your systems more robust, scalable, and debuggable.</li><li><strong>Build Beyond Naive RAG:</strong> If your RAG system is just a simple retriever and a prompt, it’s time to level up. Explore agentic patterns, modular designs, and tool integration to build more dynamic and capable applications.</li><li><strong>Respect the Gap:</strong> Acknowledge the comprehension-generation gap. Set realistic expectations for your model’s generative capabilities, especially for tasks requiring long-form, structured output. Focus the model’s strengths on synthesis and analysis while being mindful of its limitations in complex creation.</li></ol><p>Mastering the flow of information to and from these models is the defining skill for building advanced AI. The next wave of innovation won’t come from a magic prompt; it will come from principled, disciplined engineering.</p><p>So, take another look at your project. Which part of the context engineering pipeline is your real bottleneck? Answering that question is the first step toward building something truly remarkable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=951dd8bda7f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Giant Language Models on Your Laptop? LLM.int8() Makes it Possible!]]></title>
            <link>https://medium.com/@alanml23/running-giant-language-models-on-your-laptop-llm-int8-makes-it-possible-ed91f8a51e44?source=rss-a2c05f3d5b6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed91f8a51e44</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[quantization]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[int8-quantization]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Alan Ponnachan]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 06:15:11 GMT</pubDate>
            <atom:updated>2025-03-02T06:15:11.286Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_hLrh3odsin8YP8J" /><figcaption>Photo by <a href="https://unsplash.com/@6690img?utm_source=medium&amp;utm_medium=referral">Jona</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Large Language Models (LLMs) are the rockstars of the AI world. Think GPT, BLOOM, and OPT — models that can write compelling text, translate languages, answer questions, and generate code. But there’s a catch: these models are <em>huge</em>. We’re talking hundreds of billions of parameters, requiring massive amounts of memory just to load, let alone run. This puts them out of reach for most researchers, developers, and hobbyists.</p><p>A research paper, “<a href="https://arxiv.org/abs/2208.07339"><strong>LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale</strong></a>,” changes the game. It introduces a clever technique that dramatically reduces the memory needed for LLM inference <em>without</em> sacrificing performance. That means you can potentially run a 175 <em>billion</em> parameter model on a single server with consumer-grade GPUs — a feat previously unthinkable.</p><p>This post will break down the core ideas behind LLM.int8() in a way that’s accessible to anyone with a basic understanding of machine learning. We’ll skip the heavy math and focus on the <em>why</em> and the <em>how</em>.</p><h3>The Problem: Big Models, Big Memory</h3><p>At their core, LLMs are built on the Transformer architecture. A crucial part of this architecture involves lots and lots of matrix multiplications, particularly in the feed-forward and attention layers. These multiplications involve the model’s parameters (weights), which are typically stored as 32-bit floating-point numbers (FP32). Even with newer 16-bit formats (FP16 or bfloat16), the memory demands are enormous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*mGKUhZn8OjbYwfDWygoiTA.png" /><figcaption>Image by Author</figcaption></figure><h3>Quantization: The Obvious (But Tricky) Solution</h3><p>The intuitive answer is <em>quantization</em>. We can represent the model’s parameters with fewer bits, like 8-bit integers (Int8). This would drastically shrink the memory footprint. FP32 to Int8 is a 4x reduction, and FP16 to Int8 is a 2x reduction.</p><p>But, there’s a problem. Naively quantizing LLMs to Int8 <em>destroys</em> their performance. Previous attempts worked for smaller models (under 350 million parameters), but accuracy took a nosedive with larger models. The researchers behind LLM.int8() figured out why and found a fix.</p><h3>The Spiky Villains: Emergent Outlier Features</h3><p>The researchers discovered something fascinating: “emergent outlier features.” These are specific feature dimensions (think of them as columns in the data matrices) that have values <em>much</em> larger than all the others. These outliers:</p><ul><li><strong>Appear Suddenly:</strong> They don’t show up much in smaller models, but become prominent around 6.7 billion parameters.</li><li><strong>Are Consistent:</strong> They aren’t random; they appear in the <em>same</em> feature dimensions across different layers and inputs.</li><li><strong>Are Sparse:</strong> They’re a tiny percentage (around 0.1%) of all the feature dimensions.</li><li><strong>Are Essential:</strong> If you zero them out, the model’s performance collapses.</li></ul><p>These outliers are the reason why simple quantization fails. Imagine trying to fit a wide range of numbers (including some very large ones) into a small number of buckets. You either lose precision for the small numbers or clip the large ones, losing vital information.</p><h3>LLM.int8(): The Two-Part Fix</h3><p>LLM.int8() tackles this problem with a two-part solution:</p><h3>1. Vector-wise Quantization: Fine-Grained Control</h3><p>Instead of quantizing the entire matrix with one scaling factor, or even using one scaling factor per row, LLM.int8() uses <em>vector-wise</em> quantization. Each <em>inner product</em> (the dot product between a row of the input matrix and a column of the weight matrix) gets its <em>own</em> scaling factor.</p><p>Think of it like having individual volume controls for each tiny part of a complex audio signal. This allows for much more precise quantization, even with only 8 bits.</p><h3>2. Mixed-Precision Decomposition: Outliers Get Special Treatment</h3><p>This is where the magic happens. LLM.int8() identifies those pesky outlier feature dimensions and treats them differently:</p><ul><li><strong>Outliers:</strong> The matrix multiplications involving outlier features are done in <em>16-bit</em> precision. This preserves the crucial information contained in these large values.</li><li><strong>Everything Else:</strong> The vast majority (99.9%) of the calculations are done using the efficient 8-bit vector-wise quantization.</li></ul><p>It’s like having a high-fidelity audio channel just for the loudest, most important sounds, while the rest of the audio is compressed.</p><h3>Putting It All Together: The LLM.int8() Process</h3><p>Here’s a simplified breakdown of how it works during a matrix multiplication (X * W = Out):</p><ol><li><strong>Decompose:</strong> Split X and W into 16-bit outlier parts (X_f16, W_f16) and 8-bit parts (X_i8, W_i8).</li><li><strong>Quantize:</strong> Quantize X_i8 and W_i8 to Int8 using vector-wise quantization.</li><li><strong>Multiply:</strong></li></ol><ul><li>Out_f16 = X_f16 * W_f16 (16-bit)</li><li>Out_i32 = X_i8 * W_i8 (8-bit, accumulated in 32-bit)</li></ul><p><strong>4. Dequantize:</strong> Dequantize Out_i32 using the scaling factors.</p><p><strong>5. Combine:</strong> Add Out_f16 and the dequantized Out_i32 to get the final 16-bit output.</p><h3>The Results: Big Models, Small Footprint</h3><p>The researchers tested LLM.int8() on models up to 175 <em>billion</em> parameters (like OPT-175B and BLOOM) and found <em>no performance degradation</em> compared to the 16-bit baseline. This is a massive achievement. It means you can load and run these gigantic models on hardware that simply couldn’t handle them before.</p><p>And it’s not just about memory. In many cases, LLM.int8() also provides <em>speedups</em> because 8-bit computations are faster, especially on larger models.</p><h3>The Bigger Picture: Democratizing AI</h3><p>LLM.int8() is a significant step towards making cutting-edge AI more accessible. It lowers the barrier to entry for researchers, developers, and even hobbyists who want to experiment with and deploy the most powerful language models.</p><p>The integration with Hugging Face Transformers through the bitsandbytes library makes this technology readily available. You can literally load a massive model with a single line of code:</p><pre>from transformers import AutoModelForCausalLM<br><br>model = AutoModelForCausalLM.from_pretrained(&quot;facebook/opt-350m&quot;, load_in_8bit=True, device_map=&quot;auto&quot;)</pre><h3>What’s Next?</h3><p>This research opens up exciting possibilities:</p><ul><li><strong>Exploring FP8:</strong> Could 8-bit floating-point formats offer even better performance?</li><li><strong>8-bit Training:</strong> Can we extend these techniques to <em>train</em> models in 8-bit, further reducing the computational cost?</li><li><strong>Understanding Emergence:</strong> What exactly <em>causes</em> these outlier features to emerge, and what can that tell us about how transformers work?</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed91f8a51e44" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>