Skip to content

Glossary

What is retrieval-augmented generation (RAG)?

Retrieval-augmented generation, or RAG, makes AI answer from your own content: it first searches your documents for the relevant passages, then has the model write the answer from them and cite them.

Written and reviewed by Solorai

In short

A language model on its own answers from what it learned in training, which does not include your policies, contracts or tickets. RAG adds a search step: the system finds the passages that match the question and gives them to the model with the question, so the answer reflects your current content and can show its sources.

The term comes from a 2020 paper by Patrick Lewis and colleagues at Facebook AI Research, University College London and New York University, presented at NeurIPS 2020.

How RAG works

A RAG system has two parts.

Before anyone asks: indexing

Documents are collected from where they live, such as a document store, a wiki or a ticket system. They are split into chunks, usually no more than a few hundred tokens each. Each chunk is turned into an embedding, a list of numbers that captures its meaning, and stored in a search index, often next to a keyword index.

When someone asks: retrieval and generation

The question is searched against the index. The best-matching passages are retrieved, often re-ranked by a second model, and placed in the prompt with the question and instructions such as “answer only from these passages and cite them”. The model writes the answer, and the application shows the sources next to it.

RAG architecture options

OptionHow it worksWhere it fits
Vector searchFinds passages close in meaning to the question, using embeddingsQuestions worded differently from the documents. It can miss exact terms such as codes and names
Hybrid searchRuns keyword search (BM25) and vector search together and merges the resultsA strong default for company content, which mixes prose with codes, names and numbers
Re-rankingA second model reorders the top results by relevanceLarge collections where the first search returns many near misses
Contextual retrievalAdds a short description of its document to each chunk before indexingChunks that lose their meaning out of context, such as a clause or a table row
Long contextPuts whole documents into the model’s context window instead of searchingSmall, stable sets of documents. It costs more per question

In Anthropic’s tests, contextual embeddings combined with BM25 keyword search and re-ranking cut the rate at which the right passage was missing from the top 20 results by 67%. Azure AI Search, for example, runs keyword and vector queries in parallel and merges them with Reciprocal Rank Fusion, a common way to build hybrid search.

Before building an index, check what your AI platform already offers. Claude, for example, can work with connected sources such as Google Drive or Microsoft 365 through connectors, which is often enough for a first step.

Limits of RAG and how to manage them

  • Missed passages. Splitting documents can cut a passage off from the context that gives it meaning, and embeddings can miss exact matches that keyword search finds. Hybrid search and contextual retrieval reduce both problems.
  • Stale content. An index is a copy. When documents change, they and their embeddings have to be updated, ideally automatically and in the background.
  • Permissions. The index must respect who may see what, so that a person only retrieves passages they are allowed to read.
  • Answers that go beyond the sources. RAG reduces invented answers but does not eliminate them. Instructions to answer only from the passages, citations people can check and a plain “I don’t know” when nothing relevant is found keep answers honest.
  • Too much context. Models can lose information placed in the middle of a long prompt, so fewer, better passages often beat more of them.

The way to know whether a RAG system works is to test it: a set of real questions with known answers and sources, measured for both retrieval and answer quality, before and after every change.

RAG, fine-tuning and long context

ApproachWhat it changesUse it for
RAGWhat the model can see when it answersKnowledge that changes, is large or needs citations
Fine-tuningHow the model behaves, through extra trainingA consistent style, format or task, not facts that change
Long contextHow much the model reads in one requestA few documents at a time, such as one contract or one report

They combine well: a model can be tuned for a format, use RAG for knowledge and read a whole document when one is attached.

Where companies use RAG

  • Policies and HR: answers on leave, expenses or security rules, with a link to the policy.
  • Customer support: replies drafted from the knowledge base and past tickets, for a person to send.
  • Legal and compliance: research across contracts, clauses and regulations, with every passage cited.
  • Technical documentation: answers for engineers and field teams from manuals and specifications.
  • Sales: product facts and text from past proposals, for a specific opportunity.

Sources

FAQ

Questions about RAG

What does RAG stand for in AI?

Retrieval-augmented generation: the system retrieves relevant passages from your content, and the model generates its answer from them and cites the sources.

What is the difference between RAG and fine-tuning?

RAG changes what the model can see when it answers, so it suits knowledge that changes and needs citations. Fine-tuning changes how the model behaves through extra training, so it suits a consistent style or format.

Does RAG stop AI hallucinations?

It reduces them but does not eliminate them. Answering only from retrieved passages, showing citations and saying when nothing relevant was found make the remaining errors easy to spot.

Do we need a vector database for RAG?

Not always. Hybrid search can run on search engines that combine keyword and vector search, and for a first step the connectors of an AI platform may be enough.

Is RAG still needed with long context windows?

For large or changing collections, yes. Long context suits a few documents at a time. RAG keeps costs down, respects permissions and points to sources, and models can miss information buried in the middle of a long prompt.

Make AI answer from your own documents. Start with a 30-minute briefing.

Tell us which content and questions you have in mind. We will reply with a clear next step.