DEV Community

Cover image for RAG MODEL
Vinoth Kumar
Vinoth Kumar

Posted on

RAG MODEL

RETRIEVAL-AUGEMENTED GENERATION: A way to make AI answers more reliable by combining searching for relevant information and then generating a response. Instead of guessing based only on old training data, it first finds useful data from external sources.

  • Fetches up-to-date data and reduces incorrect or made-up answers.
  • Works well with specialized data like medical or legal content.
  • No need to retrain the model every time new data comes.
  • Can use user-specific data to give more relevant responses.

COMPONENTS OF RAG:

  1. External Knowledge Source.
  2. Text Chunking and Preprocessing.
  3. Embedding Model.
  4. Vector Database.
  5. Query Encoder.
  6. Retriever.
  7. Prompt Augmentation Layer.
  8. LLM (Generator).
  9. Updater.

CREATING EXTERNAL DATA: External data from APIs, databases or documents is chunked, converted into embeddings and stored in a vector database to build a knowledge library.

RETRIEVING RELEVANT INFORMATION: User queries are converted into vectors and matched against stored embeddings to fetch the most relevant data ensuring accurate responses.

AUGMENTING LLM PROMPT: Retrieved content is added to the user’s query giving the LLM extra context to work with.

ANSWER GENERATION: LLM uses both the query and retrieved data to generate a factually accurate, context aware response.

KEEPING DATA UPDATED: External data and embeddings are refreshed regularly in real time or scheduled so the system always retrieves latest information.

Top comments (0)