Retrieval-Augmented Generation (RAG)

Retrieval-Augmented Generation (RAG)





Introduction

Retrieval-Augmented Generation (RAG) is a method/approach that basically enhances LLMs (Large Language Models). It extracts relevant information from external sources such as databases, APIs, Documents etc. before providing any response.






Uses of RAG





LLMs are limited to training data only and there are high chances that it may provide outdated or incorrect information. Well, worry not, RAG is there for rescue. 
RAG solves this by extracting the most recent and relevant data at query time, leading to more accurate, fact-based responses to the user. RAG improves LLMs by integrating external knowledge retrieval.

Let us see how RAG works

  • Retrieve: When a user asks a question, the system fetches relevant documents or data.

  • Augment: The retrieved data is added as context for the LLM.

  • Generate: The LLM then generates a response using both its pre-trained knowledge and the retrieved context.


  • Example:

    Without RAG: 🤖 The president of Nepal is Bidya Devi Bhandari.
    With RAG: 🤖The president of Nepal is Ram Chandra Poudel.

    Note: Stay tune for example with codes

    Comments

    Popular posts from this blog

    ML concepts (Regression, Classification, Clustering)

    Pyspark Transformation and Actions