<?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 Raguig mohammed amine on Medium]]></title>
        <description><![CDATA[Stories by Raguig mohammed amine on Medium]]></description>
        <link>https://medium.com/@raguigmohammedamine?source=rss-6decb9727eec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ecYYFhJ91xoX7PG564JweQ.jpeg</url>
            <title>Stories by Raguig mohammed amine on Medium</title>
            <link>https://medium.com/@raguigmohammedamine?source=rss-6decb9727eec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:08:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raguigmohammedamine/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[SLMs: The Future of Agentic AI]]></title>
            <link>https://medium.com/@raguigmohammedamine/slms-the-future-of-agentic-ai-1f7f1f98e899?source=rss-6decb9727eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f7f1f98e899</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm-vs-slm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Raguig mohammed amine]]></dc:creator>
            <pubDate>Mon, 13 Oct 2025 12:55:29 GMT</pubDate>
            <atom:updated>2025-10-13T12:55:29.523Z</atom:updated>
            <content:encoded><![CDATA[<p>Agentic AI is rapidly tansforming the IT field. Today, half of large IT entreprise are using AI agents, and 21% started using them in the last year. The market value of agentic AI is valued at $5.2 billion, with projections expecting it to reach $200 billion by 2034.</p><p>Nowdays the core of most AI agents are Large Language Models (LLMs) like GPT-4 or Claude. These models handle the “Thinking” part by sending API requests to a cloud-hosted model and sends back the results. While LLMs excel at general reasoning and fluent conversation, most agentic tasks are repetitive, well-scoped, and non-conversational. Makin LLMs overkill.</p><h3>What Are SLMs?</h3><p>An SLM (Small Language Model) is a language model small enough to run on a consumer device like a laptop or desktop, responding fast enough to handle one user’s requests in real-time.</p><p>An SLM is a model that has under ~10 billion parameters, any model that doesn’t qualify as an SLM is considered as LLM.</p><h3>Why SLMs matter for agentic AI?</h3><p>Agentic AI often needs to perform tasks quickly and efficiently. This is where SLMs shine. Unlike LLMs, SLMs are designed to handle specific, structured tasks with minimal overhead. Here’s why they matter:</p><h4><em>Lower Latency</em></h4><p>SLMs are smaller, meaning they require fewer computations to generate responses. This translates into lower latency, which is critical for real-time agentic tasks.</p><p>Whether it’s summarizing a document, generating an API call, or extracting data, the user or system doesn’t have to wait for a heavy model to process the request.</p><h4>Less Memory and Compute Usage</h4><p>LLMs with hundreds of billions of parameters, demand high-end GPUs or cloud infrastructure to function efficiently. On the other hand, SLMs are compact enough to run on consumer hardware (laptops, desktops …), and consume less of energy.</p><h4>Lower Costs</h4><p>Running LLM for every agentic task is often overkill. SLMs drastically cut down both compute and operational costs:</p><ul><li>Less expensive hardware</li><li>Less cloud compute usage and storage</li><li>Fine-tuning and iteration are cheaper and faster</li></ul><h4>Adequate Performance for Structured Tasks</h4><p>Agentic AI tasks are often repetitive, narrow, well-scoped and dont need reasoning or creativity. SLMs are perfectly suited to handle these:</p><ul><li>Generating code</li><li>Extracting Structured data from documents</li><li>Summarizing content</li></ul><h3>SLMs vs LLMs</h3><p>SLMs have improved rapidly in recent years, that they became capable to replace LLMs for most agentic AI tasks. While bigger models generally perform better, the capabilities of modern SLMs are now much closer to older LLMs. A well-designed SLMs can exceed the performance of much larger models for structured agentic tasks.</p><p>Not all benchmark capabilities of LLMs are necessary for agentic AI taks. When researchers benchmark LLMs, they test them on a huge variety of taks, like:</p><ul><li>Math problems</li><li>Creative writing or storytelling</li><li>Summarization and translation</li><li>Code generation</li></ul><p>These benchmarks measure a model’s general intelligence or “overall ability”, but agentic AI rarely needs all of this. For these tasks a smaller SLM often matches or even exceeds LLM performance, while being faster and cheaper.</p><h4>Example:</h4><p>Microsoft’s Phi series demonstrates this:</p><ul><li><strong>Phi-2 (2.7B parameters)</strong> achieves commonsense reasoning and code generation scores on par with 30B models while running ~15× faster.</li><li><strong>Phi-3 Small (7B)</strong> reaches language understanding and code generation comparable to 70B models.</li></ul><h3>SLMs in Heterogeneous Agentic Systems</h3><p>Agentic systems naturally benefit from heterogeneous models, meaning they can use different models for different tasks rather than relying on a single LLM.</p><p>For example, a small SLM might handle document summarization, structured data extraction. An LLM can step in for complex reasoning, strategic planning or mulyi-step problem-solving.</p><p>This flexibility ensures that each task uses just the right amount of computational power without overloading the system with unnecessarily large models.</p><h4>Why Mix SLMs and LLMs?</h4><ul><li><strong>Efficiency:</strong> SLMs are cheaper and faster for repetitive, well-scoped tasks.</li><li><strong>Capability:</strong> LLMs provide the depth and general intelligence needed for tasks that require reasoning or creativity.</li><li><strong>Scalability:</strong> Heterogeneous systems can scale more effectively by assigning tasks to the most appropriate model.</li></ul><h3>Why LLMs Still Dominate Despite SLM Advantages?</h3><p>Even though SLMs are smaller, faster and cheaper per computation, LLMs often remain the default choice in practice, due to centralization, economies of scale and practical industry factors:</p><h4>1. Economies of Scale</h4><p>Large LLMs run on <strong>centralized cloud infrastructure</strong> optimized to handle millions of requests efficiently. Routing requests to a single, powerful model is simpler than managing a network of many specialized SLM endpoints. This centralization can make LLMs <strong>cheaper per token</strong> at scale, even if individual SLM computations cost less.</p><h4>2. Operational Complexity of SLMs</h4><p>While a small SLM is inexpensive to run on a single machine, deploying and maintaining many SLMs for various tasks adds overhead:</p><ul><li>Setup and maintenance costs</li><li>Specialized staff for model fine-tuning and infrastructure</li><li>Monitoring and orchestration across multiple endpoints</li></ul><p>In many cases, the total operational cost of SLMs can surpass the cost of using a centralized LLM.</p><h4>3. Barriers to Widespread SLM Adoption</h4><p>Companies have already spent huge amounts building cloud-based LLM pipelines. Naturally, they continue to rely on this infrastructure rather than experimenting with decentralized or on-device SLMs.</p><p>SLM development often follows the same benchmarks used for LLMs, which focus on general intelligence. These benchmarks don’t reflect the narrow, structured tasks that real-world agents perform. When evaluated on agentic utility, SLMs often outperform larger models.</p><p>SLMs get far less marketing attention than LLMs. Many practitioners don’t realize that small, task-specific models could be better suited for industrial agentic tasks.</p><h3>Conclusion</h3><p>SLMs are ready to replace LLMs for most agentic tasks. They are faster, cheaper, and easier to fine-tune, while maintaining strong performance for structured, repetitive work. The future of agentic AI isn’t just bigger , it’s smarter and more efficient, powered by the right-sized model for the right task.</p><p>SLMs aren’t just an alternative, they’re the next step in making agentic AI practical, scalable, and cost-effective.</p><h3>References:</h3><ol><li><a href="https://arxiv.org/pdf/2506.02153v1">https://arxiv.org/pdf/2506.02153v1</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f7f1f98e899" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attention in Transformers]]></title>
            <link>https://medium.com/@raguigmohammedamine/attention-in-transformers-1075a0046def?source=rss-6decb9727eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1075a0046def</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[transformers]]></category>
            <dc:creator><![CDATA[Raguig mohammed amine]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 12:53:04 GMT</pubDate>
            <atom:updated>2025-07-29T12:54:17.970Z</atom:updated>
            <content:encoded><![CDATA[<p>Before the Transformer architecture, many advanced models like <strong>RNN</strong>, <strong>LSTM</strong>, and <strong>GRNN </strong>were widely used for sequence tasks such as language translation and text generation. These models process data sequentially, step-by-step, which slows down training, especially for long sequences.</p><p>The <strong>Transformer </strong>model replaces this sequential processing with an <strong>attention mechanism</strong>, allowing for faster and more efficient training.</p><h3>The Building Blocks: Core Components of Transformers</h3><h3>1. Word Embedding:</h3><p>The first step in any Transformer is converting words (tokens) into <strong>numerical vectors</strong> that capture their meanings and relationships. This process, called word <strong>embedding</strong>, is like creating a mathematical representation of language.</p><p>Consider the words “boy” and “girl”. Their embeddings will be vectors positioned close to each other in the <strong>mathematical space</strong>, reflecting their semantic similarity. Words with related meanings cluster together, while unrelated words drift apart.</p><h3>2. Positional Encoding:</h3><p>Here’s where Transformers face their first challenge. Unlike RNNs that naturally understand sequence order, Transformers process all words <strong>simultaneously</strong>. But language is inherently sequential, word order matters.</p><p>Take this simple sentence:</p><blockquote>“The cat sat on the mat”</blockquote><p>Without positional encoding, the Transformer would see these words as an unordered collection, missing the crucial fact that “cat” comes before “sat” and “sat” comes before “on.”</p><p>Positional encoding solves this by adding unique mathematical signals to each word’s embedding. These signals act like timestamps, telling the model exactly where each word belongs in the sequence.</p><h3>3. Attention:</h3><p>This is where the magic happens. <strong>Attention </strong>allows the model to focus on relevant words when processing any given word in a sentence. It’s like having a spotlight that can dynamically shift to illuminate the most important parts of the input.</p><p>Consider this sentence:</p><blockquote>“The cat chased the mouse because it was hungry.”</blockquote><p>When processing the pronoun “it,” the attention mechanism analyzes the context and determines that “it” most likely refers to “cat” rather than “mouse.” This <strong>contextual understanding</strong> is what makes Transformers so powerful.</p><h3>How Self-Attention Actually Works</h3><p><strong>Self-Attention</strong> compares each word in the sentence with every other word (including itself) and calculates <strong>similarity </strong>scores. These scores determine how much attention the model should pay to other words when encoding a given word.</p><h3>The Mathematical Heart: The Attention Formula</h3><p>The entire attention mechanism can be captured in this elegant formula:</p><pre>Attention(Q, K, V) = Softmax(QK^T / √dk) × V</pre><p>Where:</p><ul><li><strong>Q</strong> (Query): What information is the current word looking for?</li><li><strong>K</strong> (Key): What information does each word offer?</li><li><strong>V</strong> (Value): The actual information each word contains</li><li><strong>dk</strong>: The dimension of key vectors (used for scaling)</li></ul><h3>A Practical Example: “Write a poem”</h3><p>Let’s walk through how attention works with the simple phrase “Write a poem”:</p><p><strong>Step 1: Word Embeddings</strong> Each word gets converted into numerical vectors that capture their meaning.</p><p><strong>Step 2: Positional Encoding</strong> We add position information so the model knows “Write” comes first, then “a”, then “poem”.</p><p><strong>Step 3: Create Q, K, V Matrices</strong> The encoded embeddings get multiplied by learned weight matrices to create our Query, Key, and Value matrices.</p><p>For example, if our encoded values are:</p><pre>[1.16  0.23]<br>[0.57  1.36]<br>[4.41 -2.16]</pre><p>And we multiply by query weights, we get our Q matrix with values like:</p><pre>[0.7621 -0.0477]<br>[1.1102  0.7871]<br>[1.1070 -2.1540]</pre><p><strong>Step 4: The Four-Stage Attention Calculation</strong></p><ol><li><strong>Calculate Q·K^T</strong>: We compute dot products between queries and keys, measuring how much each word should attend to every other word.</li><li><strong>Scale by √dk</strong>: We divide by the square root of the key dimension to prevent values from becoming too large, which helps with training stability.</li><li><strong>Apply Softmax</strong>: We apply the softmax function to each row of the scaled similarity matrix, turning the values into a probability distribution.</li><li><strong>Multiply by Values</strong>: Finally, we use these attention weights to create a weighted combination of the value vectors.</li></ol><p>The result? Each word now has a representation that’s informed by its relationship to every other word in the sequence.</p><h3>Why This Matters:</h3><p>The attention mechanism isn’t just a clever mathematical trick. It’s a fundamental breakthrough that solves several critical problems:</p><p><strong>Parallel Processing</strong>: Unlike RNNs that must process words one by one, attention allows Transformers to process entire sequences simultaneously, dramatically speeding up training.</p><p><strong>Long-Range Dependencies</strong>: Attention can directly connect any two words in a sequence, regardless of how far apart they are, solving the long-range dependency problem that plagued earlier models.</p><p><strong>Context Awareness</strong>: By weighing relationships between all words, the model develops a rich understanding of context that goes far beyond simple word-by-word processing.</p><h3>The Bigger Picture</h3><p>Understanding attention is crucial for anyone working with modern AI systems. This mechanism doesn’t just power language models. It’s the foundation for breakthrough applications in machine translation, text summarization, question answering, and even image processing.</p><p>The elegance of the attention mechanism lies in its simplicity: by learning to focus on what matters, Transformers can capture the complex patterns and relationships that make human language so rich.</p><p>For more detail:</p><p><a href="https://github.com/raguig/ai-paper-notes/blob/main/Attention%20in%20Transformers.md">https://github.com/raguig/ai-paper-notes/blob/main/Attention%20in%20Transformers.md</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1075a0046def" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>