Deutsch

RAG (retrieval-augmented generation)

Checked 26 October 2026 · by A.Frick

In shortRAG (retrieval-augmented generation) first looks up relevant passages in your documents, then gives them to the model so it answers from them.

In plain words

A model knows only what it learned in training plus what you put into the prompt. RAG adds a search step in between. The idea comes from a 2020 research paper by Lewis and colleagues, which combined a language model with a searchable text store. Anthropic's glossary describes it this way: relevant information is retrieved at runtime and passed to the model together with the original question, so the model can draw on facts beyond its training data.

The usual steps:

  1. Split your documents into short chunks.
  2. Turn each chunk into an embedding and store it in an index.
  3. When a question arrives, find the chunks closest in meaning.
  4. Put the question and those chunks into the prompt.
  5. The model answers from them, ideally with a quote or page number.
1. Your question 2. Search your documents 3. Best passages (an index of your files) 4. Prompt: question + passages 5. Model 6. Answer from your sources
RAG: search first, then let the model answer from what was found.

Why it matters

Example

A firm indexes its 500-page staff handbook. An employee asks: "How many days of notice do I give for leave?" The system finds the three closest paragraphs and sends them with the question. The model answers in two sentences and names the section. If the rule is not in the handbook, a good setup says so instead of guessing.

Common misconceptions

Questions and answers

What does RAG stand for?

Retrieval-augmented generation: retrieve relevant text first, then let the model generate an answer from it.

RAG or fine-tuning: which one do I need?

Use RAG when the model must use facts that change or are private. Fine-tuning suits style, format or task behaviour. Many projects start with RAG.

Does RAG stop hallucinations?

It lowers the risk by grounding answers in text, but errors remain. Ask for quotes and check key facts.

Read next

  • Embedding

    An embedding is a list of numbers that represents the meaning of a text or image, so that similar items end up close together.

  • Context window

    The context window is the maximum amount of text, counted in tokens, that a model can read and write in one request.

  • Hallucination

    A hallucination is a fluent, confident AI answer that is false, invented or not backed by the sources it was given.

  • Fine-tuning

    Fine-tuning trains an existing model further on your own examples, so it follows a style, format or task more reliably.

  • Prompt injection

    Prompt injection is an attack where text a model reads, such as a web page or file, contains instructions that make it act against its user.

Sources

  1. Lewis et al. — Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
  2. Anthropic — Glossary
  3. OpenAI — Retrieval guide

Was this page helpful?

Ask a question, report an error or suggest a topic

Stored only to answer or improve this page. No newsletter, no sharing. Privacy