Skip to content

Retrieval-augmented generation (RAG)

AI glossary

Retrieval-augmented generation (RAG)

Also called: RAG, retrieval-augmented generation

Retrieval-augmented generation, or RAG, is a pattern that became a default enterprise design after 2020: fetch relevant passages first, then ask a language model to answer using that material. The model still writes the sentence. The retrieval step is what supplies the facts you want it to stay close to.

Diagram of a retrieval-augmented generation flow from documents to an answer
A retrieval-augmented generation flow, from an indexed corpus to a grounded answer.

The usual pipeline

You split documents into chunks, embed those chunks, and store the vectors in an index. At question time you embed the question, retrieve the closest chunks, and place them in the prompt with a clear instruction: answer from this evidence, and say when the evidence is missing.

Many production systems add keyword search alongside vectors (hybrid search), then a reranker, then citations so a person can open the exact passage. None of those extras is required for a first prototype, but they are how teams raise precision once the demo leaves the lab.

What RAG is not

RAG is not a guarantee of truth. If the index is stale, the chunking cuts a rule in half, or the model ignores the passage, you can still get a wrong answer. RAG also is not fine-tuning. Fine-tuning changes weights. RAG changes what the model can see in a single request.

When to use something else

If the answer lives in a structured system, a tool call or a database query may be cleaner than embedding the whole warehouse. If the job is style or format, a small fine-tune or a strict schema may beat a pile of retrieved prose. RAG shines when you have a corpus of documents that already contain the answer.

A concrete example

Example A staff handbook chatbot retrieves the leave policy, then the model answers “How many sick days do I get?” from that page.

FAQs about Retrieval-augmented generation (RAG)

Does RAG stop hallucinations completely?

No. It reduces unsupported answers when the right passage is retrieved and the prompt insists on using it. You should still measure faithfulness and, for high-stakes work, keep a human check.

How big should my chunks be?

There is no single number. Many teams start around a few hundred tokens with a little overlap, then test. Too small and you lose the rule. Too large and the model gets a noisy page.

Do I need a vector database on day one?

For a few dozen documents, even a simple in-memory index can work. A vector database matters once the corpus grows, or you need filters, updates, and reliable nearest-neighbour search.

Where can I read the original RAG paper?

Lewis and co-authors published Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks in 2020. It is on arXiv, and most current vendor guides describe later, more practical versions of the same idea.

Back to the full AI glossary