Skip to content

What is RAG (Retrieval-Augmented Generation)?

RAG combines search and generation: it retrieves external sources relevant to a question and passes them to a language model, which draws on them to answer.

RAG, or retrieval-augmented generation, is a technique that combines a search for external information with answer generation by a language model. When a question arrives, the system searches its available sources for passages considered relevant and adds them to the context, the text given to the model along with the request. The model bases its answer on that material but can still make mistakes or add information the sources do not contain. The original paper by Lewis and colleagues combined knowledge stored in the model with a separate searchable collection: in their text-generation experiments, the RAG models produced more factual text than a baseline without retrieval. That result does not guarantee that every answer is correct. Without retraining the model, RAG can use company documents that change, provided the search index is updated. By itself, RAG does not keep documents inside company systems or restrict access to authorized people.

See also: Hybrid search and rerankingHybrid search combines lexical and semantic results; reranking reorders the candidates by relevance before showing them or passing them to a language model.

How it works

In a common setup, documents are split into chunks and converted into numerical representations called embeddings, used to find text similar to the question. Similarity search is one method among several: hybrid search with reranking combines different signals and reorders results. The choice depends on the questions: an exact product code and a paraphrased description may call for different criteria.

Retrieving more passages does not guarantee better answers. In a study of open-domain questions and Wikipedia documents, moving from 20 to 50 documents improved the tested models' accuracy only marginally while giving the models more context to process. The result holds for those models on that task and sets no universal threshold. Measure both whether search finds the right passage and whether the answer uses it correctly.

When retrieval goes wrong

A search may find nothing, return an outdated version, or surface conflicting passages. A citation does not prove that its source backs every claim: open the source and check it against the answer. For requests requiring several successive searches, Agentic RAG decides dynamically how and how often to search, with more complexity to weigh against a single search.

An enterprise example

A procurement team wants to ask questions about renewal terms in contracts and attachments. The system searches only documents the person asking is authorized to access, shows the passage and version behind the answer, and flags insufficient evidence. A staff member checks the text before making a contractual decision. The example is illustrative: it does not guarantee that the model will always recognize missing or contradictory documents.

Why it matters for decision makers

An RFP should specify index refresh times, version management, tests on real questions, and behavior when no source is found. OWASP guidance recommends checking permissions at retrieval time, before content reaches the model, and removing derived chunks and cached answers when a source is deleted or its permissions are revoked. Malicious documents can also contain instructions aimed at the model. Citations and permissions are therefore properties to verify in the system you choose; calling it RAG guarantees neither.

Frequently asked questions

No. RAG searches documents and passes them to the model with the request; when the sources change, though, the index has to be updated too.

No. It can provide useful sources, but the model can still make mistakes or assert things the retrieved documents do not support.
  • Hybrid search and rerankingHybrid search combines lexical and semantic results; reranking reorders the candidates by relevance before showing them or passing them to a language model.
  • AI HallucinationsAI hallucinations are generated claims that are false or unsupported by their sources but presented as reliable; verify them before they inform decisions.
  • Agentic RAGAgentic RAG uses an AI agent to decide how to retrieve information and, if needed, search again based on the results before answering with cited sources.
  • Context engineeringContext engineering designs the information supplied to an AI model, selecting the instructions, documents, and history that each specific request needs.
  • CAG vs RAGTwo ways to give an LLM company knowledge: preload all of it into context (CAG) or fetch it on demand (RAG).

See it in the universe

If you need the AI in production, not in a demo, that is my job.

See AI integrations

Or write to me.