<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://himanshu-arora.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://himanshu-arora.com/" rel="alternate" type="text/html" /><updated>2026-09-26T22:10:02+00:00</updated><id>https://himanshu-arora.com/feed.xml</id><title type="html">Himanshu Arora</title><subtitle>Software engineer exploring large language models, machine learning systems, and the craft of building useful technology.
</subtitle><author><name>Himanshu Arora</name></author><entry><title type="html">Cache-Augmented Generation (CAG)</title><link href="https://himanshu-arora.com/llm/2025/01/06/cache-rag.html" rel="alternate" type="text/html" title="Cache-Augmented Generation (CAG)" /><published>2025-01-06T00:00:00+00:00</published><updated>2025-01-06T00:00:00+00:00</updated><id>https://himanshu-arora.com/llm/2025/01/06/cache-rag</id><content type="html" xml:base="https://himanshu-arora.com/llm/2025/01/06/cache-rag.html"><![CDATA[<p>The landscape of <strong>Large Language Models (LLMs)</strong> is continually evolving, with innovative techniques emerging regularly to boost their effectiveness. One technique rapidly gaining popularity is <strong>Retrieval-Augmented Generation (RAG)</strong>. RAG significantly expands an LLM’s capabilities by allowing it to access and incorporate external knowledge beyond its limited context window. However, RAG faces a critical challenge—latency due to the time-consuming process of retrieving information from external sources. This is precisely the bottleneck that <strong>Cache-Augmented RAG (CAG)</strong> [1] aims to address.</p>

<h2 id="understanding-the-retrieval-bottleneck">Understanding the Retrieval Bottleneck</h2>

<p>To better understand the problem, imagine asking an LLM to answer a complex question based on a scientific paper. With traditional RAG, the model must:</p>

<ol>
  <li><strong>Understand your query.</strong></li>
  <li><strong>Search through potentially massive external knowledge bases.</strong></li>
  <li><strong>Retrieve relevant information.</strong></li>
  <li><strong>Generate an answer based on the retrieved data.</strong></li>
</ol>

<p>Steps 2 and 3—searching and retrieving—often involve significant latency, especially when dealing with extensive or complicated databases. Such delays adversely affect the responsiveness and practicality of LLM-based applications.</p>

<h2 id="introducing-cache-augmented-generation-as-a-solution">Introducing Cache-Augmented Generation as a Solution</h2>

<p>Cache-Augmented Generation (CAG) elegantly addresses retrieval latency by proactively loading relevant information directly into the LLM’s extended context. By caching relevant data beforehand, it avoids repetitive searches entirely. Imagine equipping your LLM with immediate access to the knowledge it needs, instead of forcing it to search for answers each time a query arises.</p>

<h2 id="how-cache-augmented-rag-works">How Cache-Augmented RAG Works</h2>

<p>CAG follows a streamlined and efficient process:</p>

<ul>
  <li><strong>Query Embedding:</strong> Transform the user’s query into a vector representation (embedding), serving as the cache <strong>key</strong>.</li>
  <li><strong>Cache Lookup:</strong> Search the cache for similar query embeddings already processed.</li>
  <li><strong>Retrieve and Reuse:</strong> If a matching embedding is found, quickly retrieve the associated cached <strong>value</strong> (previously obtained knowledge). If no match exists, perform the standard retrieval, then store the new query-result pair in the cache for future use.</li>
</ul>

<h2 id="advantages-of-cache-augmented-rag">Advantages of Cache-Augmented RAG</h2>

<ul>
  <li><strong>Accelerated Response Times:</strong> Minimizes retrieval latency, ensuring faster query handling.</li>
  <li><strong>Reduced Infrastructure Costs:</strong> Decreases repeated retrieval requests, lowering computational overhead and resource usage.</li>
  <li><strong>Enhanced User Experience:</strong> Quick responses create a smoother, more responsive interaction, significantly improving user satisfaction.</li>
</ul>

<h2 id="final-thoughts">Final Thoughts</h2>

<p>Cache-Augmented RAG represents a robust, straightforward approach to optimizing retrieval-augmented workflows. Leveraging caching as a key-value store effectively reduces latency, cuts infrastructure costs, and vastly improves user experience. As LLM applications continue to scale, integrating caching strategies like CAG will become crucial for efficient and responsive systems.</p>

<hr />

<p>[1] Don’t Do RAG: When Cache-Augmented Generation is All You Need for Knowledge Tasks</p>]]></content><author><name>Himanshu Arora</name></author><category term="llm" /><summary type="html"><![CDATA[The landscape of Large Language Models (LLMs) is continually evolving, with innovative techniques emerging regularly to boost their effectiveness. One technique rapidly gaining popularity is Retrieval-Augmented Generation (RAG). RAG significantly expands an LLM’s capabilities by allowing it to access and incorporate external knowledge beyond its limited context window. However, RAG faces a critical challenge—latency due to the time-consuming process of retrieving information from external sources. This is precisely the bottleneck that Cache-Augmented RAG (CAG) [1] aims to address.]]></summary></entry><entry><title type="html">ICL: In-Context Learning for Classification (Part 2)</title><link href="https://himanshu-arora.com/llm/2024/12/23/icl-part2.html" rel="alternate" type="text/html" title="ICL: In-Context Learning for Classification (Part 2)" /><published>2024-12-23T00:00:00+00:00</published><updated>2024-12-23T00:00:00+00:00</updated><id>https://himanshu-arora.com/llm/2024/12/23/icl-part2</id><content type="html" xml:base="https://himanshu-arora.com/llm/2024/12/23/icl-part2.html"><![CDATA[<p>In our previous post, we discussed the foundational principles of <strong>In-Context Learning (ICL)</strong> and its ability to significantly enhance the performance of <strong>Large Language Models (LLMs)</strong>. In this article, we delve deeper into the specific applications of ICL in text classification, highlighting key research developments, practical implications, and future opportunities.</p>

<h2 id="exploring-key-research-on-icl-for-text-classification">Exploring Key Research on ICL for Text Classification</h2>

<h3 id="the-importance-of-demonstrations-in-icl">The Importance of Demonstrations in ICL</h3>

<p>Min et al. (2022) extensively studied how demonstration quality and quantity influence ICL, particularly in sentiment classification and natural language inference tasks. Their crucial findings include:</p>

<ul>
  <li>Increasing the number of demonstrations significantly improved performance, though gains plateaued around 16 examples.</li>
  <li>Randomly chosen demonstrations proved surprisingly effective.</li>
  <li>Strategic demonstration selection methods, such as K-nearest neighbors (KNN), notably enhanced performance.</li>
  <li>Evidence suggests ICL implicitly learns a similarity-based classification function from demonstrations.</li>
</ul>

<h3 id="selective-annotation-for-few-shot-text-classification">Selective Annotation for Few-Shot Text Classification</h3>

<p>Suzgun et al. (2022) introduced a novel method called “selective annotation,” leveraging LLMs to identify and select the most informative examples for annotation. Their insights revealed:</p>

<ul>
  <li>Selective annotation consistently outperformed random sampling, particularly when labeled data were scarce.</li>
  <li>Utilizing LLM-driven selective annotation optimizes annotation efforts, maximizing model performance even with limited labels.</li>
</ul>

<h3 id="calibration-to-enhance-few-shot-learning-performance">Calibration to Enhance Few-Shot Learning Performance</h3>

<p>Zhao et al. (2023) proposed a calibration approach to increase the reliability of LLMs in few-shot text classification scenarios. Their research highlighted:</p>

<ul>
  <li>Calibrating LLM predictions notably improved few-shot classification performance, especially with minimal labeled examples.</li>
  <li>Calibration effectively reduced prediction overconfidence, resulting in more accurate uncertainty estimates.</li>
</ul>

<h2 id="current-challenges-of-icl-in-text-classification">Current Challenges of ICL in Text Classification</h2>

<p>Despite its promising results, ICL presents several challenges:</p>

<ul>
  <li><strong>Bias and Fairness:</strong> ICL can inherit and amplify biases present in pre-training datasets, potentially causing unfair classifications.</li>
  <li><strong>Explainability:</strong> Interpreting and understanding classification decisions made via ICL remains challenging.</li>
  <li><strong>Robustness:</strong> Generalization to diverse text types or domains is still a critical issue.</li>
</ul>

<h2 id="promising-directions-for-future-research">Promising Directions for Future Research</h2>

<p>Several exciting areas hold promise for future advancements in ICL for text classification:</p>

<ol>
  <li><strong>Dynamic ICL:</strong> Automatically adapting demonstrations’ number and type based on input complexity and context.</li>
  <li><strong>ICL with External Knowledge Integration:</strong> Enhancing context with retrieved external knowledge to enrich model understanding.</li>
  <li><strong>Personalized ICL:</strong> Tailoring demonstration selection to individual user preferences or specific task requirements to enhance performance.</li>
</ol>

<h2 id="conclusion">Conclusion</h2>

<p>ICL is a transformative approach for text classification tasks, with ongoing research progressively overcoming current limitations. As the field advances, we anticipate ICL playing a critical role in diverse text classification applications, including sentiment analysis, topic detection, and intent recognition.</p>

<hr />

<h2 id="references">References</h2>

<ol>
  <li>Min et al., “Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?” (2022)</li>
  <li>Suzgun et al., “Selective Annotation Makes Language Models Better Few-Shot Learners” (2022)</li>
  <li>Zhao et al., “Calibrate Before Use: Improving Few-Shot Performance of Language Models” (2023)</li>
</ol>]]></content><author><name>Himanshu Arora</name></author><category term="llm" /><summary type="html"><![CDATA[In our previous post, we discussed the foundational principles of In-Context Learning (ICL) and its ability to significantly enhance the performance of Large Language Models (LLMs). In this article, we delve deeper into the specific applications of ICL in text classification, highlighting key research developments, practical implications, and future opportunities.]]></summary></entry><entry><title type="html">ICL: In-Context Learning (Part 1)</title><link href="https://himanshu-arora.com/llm/2024/12/21/icl-part1.html" rel="alternate" type="text/html" title="ICL: In-Context Learning (Part 1)" /><published>2024-12-21T00:00:00+00:00</published><updated>2024-12-21T00:00:00+00:00</updated><id>https://himanshu-arora.com/llm/2024/12/21/icl-part1</id><content type="html" xml:base="https://himanshu-arora.com/llm/2024/12/21/icl-part1.html"><![CDATA[<p>AI has exploded in the last two years, largely due to a massive leap in the capabilities of Language Models (LMs). We’ve seen models grow from 300 million parameters to hundreds, even thousands, of billions. AI giants like OpenAI, Anthropic, and Google are constantly pushing boundaries, releasing powerful models which have undergone pre-training on vast datasets of text and code.</p>

<p>Due to the powerful nature of the models, we can now use them for various tasks, with very minimal context. This is where In-Context Learning (ICL) comes in. It’s a very useful way we can use to interact with these Large Language Models (LLMs)/ Infact, You might have already used ICL when prompting these models in some way while guiding them towards your desired response. Unlike traditional fine-tuning, which involved extensive retraining, ICL lets us shape the model’s behavior by providing instructions and examples directly within the input prompt.</p>

<p>This is the first in a three-part blog series exploring In-Context Learning. We’ll deconstruct ICL in this post, look at its advancements in the second, and finally explore future research directions in the third.</p>

<h3 id="deconstructing-in-context-learning">Deconstructing In-Context Learning</h3>

<p>At its core, ICL exhibits characteristics of meta-learning [1], where the model appears to have implicitly acquired a learning algorithm during pre-training. This algorithm enables it to adapt to new tasks based on limited in-context examples or instructions. This differs significantly from conventional fine-tuning, where the model’s parameters are explicitly updated through gradient descent to minimize a task-specific loss. In ICL, the model leverages its internal representations to learn from the provided context without parameter updates.</p>

<p>In-context learning effectively hinges on the rich representations learned during pre-training, which encode not only linguistic knowledge but capture intricate relationships and patterns in the data. These learnings allow them to recognize task structures and generalize to unseen inputs when presented with a few demonstrations.</p>

<h3 id="types-of-context-more-than-just-showing-examples">Types of Context: More than Just Showing Examples</h3>

<p>ICL is more than just providing a few examples [2,3]. It’s about crafting the right kind of context to guide the LLM. Here are a few ways to do that:</p>

<h4 id="demonstration-context">Demonstration Context</h4>
<p>This is the most common form of ICL, often referred to as “few-shot learning.” We simply provide the LLM with a few examples of input-output pairs, with or without instructions. It’s very similar to how we learn solve patterns like <code class="language-plaintext highlighter-rouge">Toyota : Japan:: Tesla:? </code>.A straight forward through a prompt could be:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Translate the following English sentences into French:

English:  "This croissant is delicious! Where did you get it?"
French: "Ce croissant est délicieux ! Où l'avez-vous acheté ?"

English: I would like to order a coffee.
French:
</code></pre></div></div>

<h4 id="instructional-context">Instructional Context</h4>
<p>Instead of just showing examples, you can also instruct the language model.You provide explicit instructions or guidelines on how to perform the task. A lot of recent research has shown that providing reasoning steps through instructions, known as ‘chain-of-thought prompting’ [4, 5], can significantly enhance the reasoning abilities of LLMs.  For example, you might provide a set of rules for summarizing an article or generating a poem.</p>

<h4 id="priming-context">Priming Context</h4>
<p>This is like setting the mood. You provide text that is related to the task or domain, even if it doesn’t explicitly demonstrate the task. This can help “prime” the model to generate more relevant and coherent responses. For example, providing a news article about climate change before asking it to write an essay on the topic.</p>

<h4 id="hybrid-context">Hybrid Context</h4>
<p>Hybrid context can be a combination of different types of context, such as demonstrations and instructions, to provide a richer learning signal for the model. This could involve providing examples of product descriptions along with guidelines on what information to include.</p>

<h3 id="next-steps">Next Steps</h3>

<p>ICL has evolved a lot more than prompting strategies and is an active topic of research in Machine Learning. In the next blog post, we will look at some of how ICL can enhance zero-shot classification using LLMs.</p>

<p><strong>References:</strong></p>

<p>[1] Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., … &amp; Amodei, D. (2020). Language models are few-shot learners.</p>

<p>[2] Min, S., Lyu, X., Holtzman, A., Artetxe, M., Lewis, M., Hajishirzi, H., &amp; Zettlemoyer, L. (2022). Rethinking the role of demonstrations: What makes in-context learning work?</p>

<p>[3] Liu, P., Yuan, W., Fu, J., Jiang, Z., Hayashi, H., &amp; Neubig, G. (2023). Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing</p>

<p>[4] Wei, J., Wang, X., Schuurmans, D., Bosma, M., Chi, E., Le, Q. V., &amp; Zhou, D. (2022). Chain of thought prompting elicits reasoning in large language models.</p>

<p>[5] Kojima, T., Gu, S. S., Reid, M., Matsuo, Y., &amp; Iwasawa, Y. (2022). Large language models are zero-shot reasoners.</p>]]></content><author><name>Himanshu Arora</name></author><category term="llm" /><summary type="html"><![CDATA[AI has exploded in the last two years, largely due to a massive leap in the capabilities of Language Models (LMs). We’ve seen models grow from 300 million parameters to hundreds, even thousands, of billions. AI giants like OpenAI, Anthropic, and Google are constantly pushing boundaries, releasing powerful models which have undergone pre-training on vast datasets of text and code.]]></summary></entry><entry><title type="html">Welcome</title><link href="https://himanshu-arora.com/2024/12/10/welcome.html" rel="alternate" type="text/html" title="Welcome" /><published>2024-12-10T00:00:00+00:00</published><updated>2024-12-10T00:00:00+00:00</updated><id>https://himanshu-arora.com/2024/12/10/welcome</id><content type="html" xml:base="https://himanshu-arora.com/2024/12/10/welcome.html"><![CDATA[Welcome to my blog!

This is my first post to test the blog.]]></content><author><name>Himanshu Arora</name></author><summary type="html"><![CDATA[Welcome to my blog!]]></summary></entry></feed>