AI Topics

What is Retrieval-Augmented Generation (RAG)?

Generative AI and LLMs 2 min read
On this page
  1. Definition
  2. How it works
  3. Examples
  4. Related terms
  5. Common questions
Definition

Retrieval-Augmented Generation (RAG) is a method that lets a large language model look up relevant information in an external knowledge source, such as company documents or a database, and add it to the prompt before it writes an answer. The model then answers from that retrieved material instead of relying only on its training data.

RAG matters because a large language model (LLM) only knows its training data, which stops at a fixed point and rarely covers private company information. Retrieval adds current, specific facts at answer time, so answers can cite sources and contain fewer hallucinations (confident but false statements). RAG lowers that risk but does not remove it. 

Researchers at Facebook AI Research, University College London and New York University named the approach in the original RAG research paper, which paired a neural retriever with a text generator. The same pattern now runs behind many chatbots, virtual assistants and internal knowledge tools. 

How does RAG work?

  1. Prepare the knowledge baseThe system splits documents into small chunks, and an embedding model turns each chunk into a vector, a list of numbers that captures its meaning. The vectors are stored in a vector database so they can be searched by meaning.
  2. Retrieve relevant passagesWhen a user asks a question, the system converts the question into a vector and finds the stored chunks closest to it. This semantic search matches meaning, not just keywords.
  3. Augment the promptThe system adds the retrieved passages to the user's question in a single prompt. Instructions in the prompt tell the model to answer from those passages.
  4. Generate the answerThe LLM writes a response from the question and the retrieved passages, and it can cite the sources it used. Updating the knowledge base keeps answers current without retraining the model.

What are examples of RAG?

  • SupportCustomer support chatbotA customer asks how to reset a password, and the chatbot retrieves the matching help-centre article. It replies with the exact steps from that article instead of a generic answer.
  • KnowledgeInternal HR assistantAn employee asks how much annual leave they have left, and the assistant retrieves the leave policy and that employee's leave record. The answer reflects the organisation's own rules rather than general advice.
  • ResearchResearch and analysisAn analyst asks a question, and the system retrieves passages from reports, papers or internal records. The model summarises what it found and points to the documents it used.

Common questions about RAG

What is RAG in simple terms?

Retrieval-augmented generation (RAG) is a way of letting an AI model check trusted documents before it answers. The system finds the passages that match the question and adds them to the prompt, and the model writes its reply from them. This keeps answers specific, current and traceable to a source, without retraining the model.

What is the difference between RAG and fine-tuning?

Retrieval-augmented generation (RAG) gives a model new information at answer time, while fine-tuning changes the model itself by training it further on domain-specific data. RAG suits facts that change often or need a cited source. Fine-tuning suits shaping how a model responds in a specific domain, such as its format and terminology. The two can be used together.

Clutch Image
GoodFirms Image
Designrush Image
Reviews Image
Glassdoor Image