RAG — Retrieval-augmented generation

Retrieval-augmented generation, or RAG, is the technique of finding relevant information in your own sources and handing it to a language model so it writes the answer with that. The model does not memorise the content: it looks it up at answer time.

What is retrieval-augmented generation?

Retrieval-augmented generation, or RAG, is the technique of finding relevant information in your own sources and handing it to a language model so it writes the answer with that. The model does not memorise the content: it looks it up at answer time.

Also: RAG

RAG is not training a model

This is the most common confusion. Training modifies the model with your data, costs a lot and freezes the knowledge at training time. RAG leaves the model untouched and passes it the relevant documents with every question. That is why, with RAG, fixing an article today changes the answer today.

Why it matters

What changes in a SaaS

It is what lets an AI system talk about your product without making it up. It is also what makes your documentation the ceiling: the model cannot answer better than what is written, and if the wrong passage is retrieved the answer will be flawless and wrong.

Primer plano de una placa de circuito

Retrieval-augmented generation in detail

  • How it works, in four steps

    The documentation is split into passages; each passage becomes a vector representing its meaning; when a question arrives, the vectors closest to it are found; and those passages go to the model along with the question.

  • Why it searches by meaning, not words

    Because customers do not use your words. If your article says "retention policy" and the customer writes "how long do you keep my data", exact matching finds nothing. Vector search does, because it compares meanings.

  • Where it fails

    In retrieval, nearly always, not in the writing. If the wrong passage comes back, the model writes a convincing answer based on it. That is why most of the work improving one of these systems is improving what gets retrieved, not swapping the model.

  • What RAG does not solve

    Data that lives in no document: which plan this customer is on, how much quota is left, whether the last payment went through. That is not retrieved from documentation, it is looked up in your system. It is the difference between a documentation chatbot and an agent.

Questions about retrieval-augmented generation

What does RAG stand for?

Retrieval-Augmented Generation: finding relevant information in your own sources and passing it to the model so it writes with it.

Is RAG the same as fine-tuning a model on my data?

No. Fine-tuning changes the model and freezes what it knows; RAG leaves it untouched and looks documents up on every question. With RAG, updating an article changes the answer immediately.

Why does my RAG system answer incorrectly?

Almost always because it retrieves the wrong passage, not because the model writes badly. Looking at what was retrieved for the failed questions usually explains the whole problem.

Related terms

A term on its own is only half understood. These come up in the same conversation.

Try it without dropping what you use