<?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 Subhash Saravanan on Medium]]></title>
        <description><![CDATA[Stories by Subhash Saravanan on Medium]]></description>
        <link>https://medium.com/@subhashve4?source=rss-75fa810df3b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ElQgJKAMO9TAMxswybcbbg.png</url>
            <title>Stories by Subhash Saravanan on Medium</title>
            <link>https://medium.com/@subhashve4?source=rss-75fa810df3b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:19:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@subhashve4/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[Knowledge Distillation: DeepSeek R1 Distill Llama 7b is not DeepSeek R1]]></title>
            <link>https://medium.com/@subhashve4/how-deepseek-r1s-distilled-models-differ-from-the-real-thing-a-guide-to-knowledge-distillation-0d3d46dd8a9e?source=rss-75fa810df3b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d3d46dd8a9e</guid>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[distillation]]></category>
            <category><![CDATA[deepseek-r1]]></category>
            <dc:creator><![CDATA[Subhash Saravanan]]></dc:creator>
            <pubDate>Sat, 01 Feb 2025 23:53:58 GMT</pubDate>
            <atom:updated>2025-02-05T02:53:07.164Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Knowledge Distillation: Bridging the Gap Between Large Models and Practical Applications</strong></h3><p>Large language models (LLMs) have revolutionized AI with their ability to handle tasks like text generation, coding, and complex reasoning. However, their massive computational demands often make deployment impractical in resource-constrained environments.</p><p>Knowledge distillation addresses this challenge by transferring the knowledge of a large, sophisticated model (the <em>teacher</em>) to a smaller, more efficient counterpart (the <em>student</em>). While distilled models are powerful tools, they are not perfect replicas of their teachers.</p><p>This article explores how knowledge distillation works, why student models differ from their teachers, and the implications for real-world AI deployment.</p><h3>What Is Knowledge Distillation?</h3><p>Knowledge distillation is a technique that compresses the knowledge of a complex teacher model into a smaller student model. The goal is to create lightweight models capable of running on devices with limited computational resources, such as smartphones or edge hardware. Here’s how it works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*GTX4QjSg63sNGGInMh5XJA.png" /></figure><p><strong>Soft Targets: Learning from Probabilities:</strong><br>Instead of training the student model using only correct answers (hard labels), the teacher provides <em>soft targets</em> — probability distributions over all possible outputs.</p><p>For example, when asked, <em>“What is the capital of France?”</em>, the teacher might output:</p><ul><li>Paris: 99%</li><li>Lyon: 0.5%</li><li>Marseille: 0.4%</li><li>Other cities: 0.1%</li></ul><p>These probabilities reveal not just the correct answer but also the teacher’s confidence in alternative options. By learning from these nuanced distributions, the student captures subtle patterns and relationships in the data.</p><p><strong>Temperature Scaling: Smoothing the Outputs</strong><br>To make the teacher’s soft targets more informative, a technique called <em>temperature scaling</em> adjusts the “temperature” parameter in the model’s output function:</p><ul><li><strong>Low temperature</strong>: Outputs are sharp and confident (e.g., 99% for “Paris”).</li><li><strong>High temperature</strong>: Outputs are softened, spreading probability mass across plausible options (e.g., 80% for “Paris”, 10% for “Lyon”).</li></ul><p>Softened outputs help the student learn the teacher’s reasoning about less obvious answers, improving its ability to generalize.</p><p><strong>Two-Step Training Process</strong><br>The student model is trained in two phases:</p><ol><li><strong>Mimicking the Teacher</strong>: The student replicates the teacher’s softened outputs to internalize its reasoning patterns.</li><li><strong>Fine-Tuning on Real Data</strong>: The student refines its performance using labeled data, optimizing for specific tasks.</li></ol><p>This approach balances efficiency with effectiveness, though the student inevitably sacrifices some capabilities of the teacher.</p><h3>Why Distilled Models Aren’t Teacher Clones</h3><p>While distilled models inherit knowledge from their teachers, they are not miniature duplicates. Key differences include:</p><p><strong>Structural Differences</strong><br>Teacher models are often massive, with billions of parameters and deep architectures that capture intricate patterns. Student models, by contrast, are designed for efficiency:</p><ul><li><strong>Teacher</strong>: Hundreds of billions of parameters, trained with advanced methods like reinforcement learning.</li><li><strong>Student</strong>: Typically 1–70 billion parameters, trained with supervised learning on distilled outputs.</li></ul><p>This structural gap forces the student to approximate the teacher’s reasoning, often relying on shortcuts rather than replicating full logic.</p><p><strong>Loss of Nuance and Depth</strong><br>Compression during distillation inevitably discards details:</p><ul><li><strong>Simplified Reasoning</strong>: A student might learn <em>“12 x 5 = 60”</em> without grasping the arithmetic logic behind multiplication.</li><li><strong>Missed Edge Cases</strong>: Rare or abstract patterns mastered by the teacher may be overlooked.</li></ul><p>As a result, distilled models struggle with tasks requiring deep creativity or abstract reasoning, such as writing literature or solving novel problems.</p><p><strong>Task-Specific Optimization</strong><br>Distilled models are often optimized for specific use cases:</p><ul><li><strong>Specialization</strong>: A model fine-tuned for sentiment analysis may fail at code generation.</li><li><strong>Omitted Capabilities</strong>: To prioritize speed and size, certain functionalities of the teacher are excluded.</li></ul><p>This specialization enhances performance in target domains but reduces versatility compared to the generalist teacher.</p><h3>Why This Matters</h3><p><strong>Setting Realistic Expectations</strong><br>Distilled models excel in efficiency but lack their teachers’ depth. Recognizing this ensures they are deployed where speed and resource constraints outweigh the need for advanced reasoning.</p><p><strong>Choosing the Right Tool for the Job</strong></p><ul><li><strong>Teacher Models</strong>: Better suited for tasks demanding creativity, deep analysis, or handling ambiguity.</li><li><strong>Distilled Models</strong>: Ideal for mobile apps, edge devices, or real-time systems.</li></ul><p><strong>Avoiding Overconfidence</strong><br>In high-stakes fields like healthcare or law, understanding the limitations of distilled models is critical to avoiding errors. They should augment — not replace — human expertise or more robust systems.</p><h3>Conclusion: Mentorship, Not Cloning</h3><p>Knowledge distillation enables powerful AI to reach resource-limited environments by transferring expertise from large teachers to compact students. However, the student is not a clone. It is a specialized tool designed to approximate — not replicate — the teacher’s strengths in specific contexts.</p><p>By leveraging distilled models where they shine and relying on larger models where necessary, we can democratize AI’s benefits while respecting its limitations. The goal is not to replace teachers but to extend their impact, ensuring AI serves as many users and use cases as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d3d46dd8a9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text Chunking for RAG: A Complete Guide]]></title>
            <link>https://medium.com/@subhashve4/text-chunking-for-rag-a-complete-guide-fbb1e1cb6254?source=rss-75fa810df3b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbb1e1cb6254</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llm-as-a-judge]]></category>
            <dc:creator><![CDATA[Subhash Saravanan]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 19:32:20 GMT</pubDate>
            <atom:updated>2025-02-01T21:20:50.488Z</atom:updated>
            <content:encoded><![CDATA[<p>How It Works, Why It Matters, and Methods Explained</p><h3>Why Chunking Matters</h3><p>Imagine trying to find a recipe in a giant cookbook with no chapters or page numbers. <strong>Chunking</strong> solves this by breaking long text into smaller, meaningful pieces.</p><p>For AI tools like chatbots (RAG systems), chunking ensures they retrieve the <em>right context</em> to answer accurately. Bad chunking causes:</p><ul><li><strong>Confused AI</strong>: Answers based on irrelevant snippets.</li><li><strong>Slow results</strong>: Searching through giant text blocks.</li></ul><h3>The Sample Text</h3><p>I’ll use the same text to show how different chunking methods work:</p><p>“RAG systems improve AI responses. They first retrieve relevant data. Then, they generate answers using that context. Effective chunking is key to accuracy.”</p><h3>1. Fixed-Size Chunking</h3><p>Splits text into equal parts (e.g., every 50 characters).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29wzBNJK5_J4GlOSca4tJw.png" /></figure><p><strong>Pros</strong>:</p><ul><li><strong>Fast and simple</strong>: Easy to implement with no complex logic.</li><li><strong>Predictable</strong>: Uniform chunk sizes simplify downstream processing.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Breaks context</strong>: Splits sentences or ideas mid-flow.</li><li><strong>Robotic</strong>: Ignores natural text boundaries (e.g., paragraphs).</li></ul><p><strong>Best For:</strong> Rapid prototyping or processing uniform text like logs, where speed trumps nuance.</p><p><strong>Avoid If</strong>: Your content relies on context (e.g., narratives, technical explanations). Fixed splits risk fragmenting key ideas.</p><h3>2. Sentence-Aware Chunking</h3><p>Splits text at sentence boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWe56yJfoMEI7H2ol3ZuWw.png" /></figure><p><strong>Pros</strong>:</p><ul><li><strong>Natural splits</strong>: Respects sentence boundaries.</li><li><strong>Better context</strong>: Preserves complete thoughts.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Narrow focus</strong>: Single sentences may lack broader context.</li><li><strong>Variable sizes</strong>: Long sentences create oversized chunks.</li></ul><p><strong>Best For:</strong> Articles, news stories, or any text with clear sentence boundaries. It mimics how humans read, preserving complete thoughts.</p><p><strong>Avoid If:</strong> Your documents are technical or thematic (e.g., research papers). Single sentences often lack the broader context needed for deep analysis.</p><h3>3. Recursive Chunking</h3><p>Splits text hierarchically (e.g., headings → subheadings).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*AVGuADkkl7IPWgca7o5u7w.png" /></figure><p><strong>Pros</strong>:</p><ul><li><strong>Versatile:</strong> Handles various content structures.</li><li><strong>Context Preservation: </strong>Maintains logical flow of context in the documents</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Overlooks Complex Structures</strong>: Does not chunk similar information together</li><li><strong>Increased Complexity:</strong> Recursive nature can add computational overhead</li></ul><p><strong>Best For:</strong> Balancing structure and flexibility. It splits documents hierarchically (headings → paragraphs → sentences), making it a Swiss Army knife for mixed-content RAG pipelines.</p><p><strong>Avoid If:</strong> You’re working with purely unstructured text (e.g., social media posts). Its strength lies in leveraging existing document organization.</p><h3>4. Semantic Chunking</h3><p>Groups text by meaning or topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erv_E4G1werjlbw0Qgcj5w.png" /></figure><p><strong>Pros</strong>:</p><ul><li><strong>Meaningful groups</strong>: Clusters related ideas/themes.</li><li><strong>Context-ric</strong>h: Retains full narrative flow.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Slower</strong>: Requires NLP models and clustering.</li><li><strong>Resource-heavy</strong>: Needs computational power for embeddings.</li></ul><p><strong>Best For: </strong>Technical manuals, legal contracts, or research papers where themes matter. It groups related ideas, mimicking how experts parse information.</p><p><strong>Avoid If:</strong> You’re resource constrained. Generating embeddings and clustering require computational power.</p><h3>5. Agentic Chunking</h3><p>AI splits text dynamically based on the task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*p3exCPLn4z5WtNHazij-iw.png" /></figure><p><strong>Pros:</strong></p><ul><li><strong>Task-optimized</strong>: Dynamically adjusts chunks for specific goals.</li><li><strong>Self-improving</strong>: Uses feedback loops to refine chunking.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Costly</strong>: Requires LLM API calls or fine-tuning.</li><li><strong>Time-consuming</strong>: Iterative feedback adds latency.</li></ul><p><strong>Best For:</strong> High-stakes domains like healthcare or law, where chunking must adapt to specialized tasks (e.g., extracting symptoms or clauses).</p><p><strong>Avoid If:</strong> You’re on a budget. Continuous LLM feedback loops drive up costs and latency.</p><h3>Agentic Hybrid Chunking System</h3><p>A dynamic, self-optimizing chunking framework that combines the strengths of all methods while mitigating their weaknesses. Designed for any document type, it adapts to structure, content, and task requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*q5WWIdUoFVMnKWXdD9GATA.png" /></figure><h3>Example:</h3><p><strong>Input</strong>: A research paper (structured) with a mix of equations, paragraphs, and bullet points.</p><ol><li><strong>Document-Based</strong>: Split by sections (Abstract, Methods, Results).</li><li><strong>Recursive</strong>: Break long “Methods” into paragraphs → equations.</li><li><strong>Semantic</strong>: Cluster equations with their descriptions.</li><li><strong>Agentic Judge</strong>: Flags fragmented equation explanations → merges chunks.</li></ol><p><strong>Output</strong>: Task-optimized chunks with equations + context.</p><h3>Conclusion</h3><p>Chunking is a foundational technique for improving the efficiency and accuracy of AI systems, particularly in Retrieval-Augmented Generation (RAG) pipelines. By breaking down large texts into smaller, meaningful pieces, chunking ensures that AI tools like chatbots can retrieve and process the right context to generate accurate and relevant responses. However, not all chunking methods are equal, and the choice of method depends on the nature of the content and the specific use case.</p><ul><li><strong>Fixed-Size Chunking</strong> offers simplicity and speed but risks fragmenting key ideas, making it best suited for uniform text like logs or rapid prototyping.</li><li><strong>Sentence-Aware Chunking</strong> respects natural language boundaries, preserving complete thoughts, but may lack broader context, making it ideal for articles or news stories.</li><li><strong>Recursive Chunking</strong> provides a balanced approach by leveraging document structure, but it can struggle with unstructured text and adds computational complexity.</li><li><strong>Semantic Chunking</strong> excels in grouping related ideas, making it perfect for technical or thematic content, though it requires significant computational resources.</li><li><strong>Agentic Chunking</strong> dynamically adapts to specific tasks, offering high precision in specialized domains, but it comes with higher costs and latency.</li></ul><p>The <strong>Agentic Hybrid Chunking System</strong> combines the strengths of all methods into a dynamic, self-optimizing framework. It adapts to document structure, content, and task requirements, ensuring optimal performance across diverse use cases.</p><p>In summary, effective chunking is not a one-size-fits-all solution. By understanding the strengths and limitations of each method, you can choose — or combine — approaches that best align with your goals, whether you’re processing research papers, legal documents, or social media posts. As AI continues to evolve, so too will the strategies for chunking, enabling even more sophisticated and context-aware systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbb1e1cb6254" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>