Advanced RAG

Before moving forward, lets revise RAG quickly,

RAG is Retrieval-Augmented Generation , its basically Retrieving (Fetching) Relevant information from some External data source and providing it as a context to LLMs, Augement ( Increasing) the model’s base Knowledge to Generate Improved Output response by LLMs .

which works on 3 step process, Indexing → Retrieval → Generation

If u want to read in detail, i have explained in simple words, you can read it here

Why Advanced RAG ?

  • Till now with RAG, we were able to fetch small data , and use it to Augment our model knowledge, but in real Life, or Production level use-case, reality is we have to “ interact with vast collections of information ( Sparse Data ) ” , for that We need OPTIMIZATION in response generated by model

  • To increase Accuracy of responses , there is a direct relation you will see => To Increase Context being provided to Model before generation , now this Increasing Context doesn’t mean, literally increasing it, since we have Context Window concept it is limited, but to provide model with Increased Related Context to make him give more Accurate responses.

  • User Prompts are the only thing in LLMs , we don’t have control over, so we can’t do anything about them, but what we can do is we can optimize them after receiving them.

  • ISSUES with USER Prompts : Because there is difference between, What user intends to ask LLM ? and What user is actually asking ? - So its our responsibility as developers to provide most accurate response possible , it can be very Abstract , too much Detail , Ambiguous , Garbage - anything, and if we don’t optimize, its default nature of LLM, to provide same output as your prompt is , GARBAGE IN GARBAGE OUT…

  • For Advancing, we have three options:

    QUERY TRANSFORMATION , ROUTING , QUERY CONSTRUCTION

  • for now, we will just focus at QUERY TRANSFORMATION PART,

Query Transformation / Translation:

Meaning : Changing User Prompt

Objective : Improving User Prompt by providing more accurate context to LLM

We will be discussing, these techniques one by one, in upcoming articles, check out!

Advanced RAG Article Series

0
Subscribe to my newsletter

Read articles from Nakul Srivastava directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nakul Srivastava
Nakul Srivastava

I'm a passionate web developer who loves building beautiful, functional, and efficient web applications. I focus on crafting seamless user experiences using modern frontend technologies.