RAG explained: how AI answers from your data
RAG (retrieval-augmented generation) lets a language model look up matching text before it answers. How it works, what it is good for and where it falls short.
RAG stands for retrieval-augmented generation. A system first searches your own documents for passages that fit a question and hands them to a language model together with the question. The model then writes its answer from those passages instead of relying only on what it learned in training.
How does a RAG request work?
Before any question arrives, the documents are prepared: they are cut into short sections, and each section is turned into a numeric representation of its meaning, called an embedding. These representations are stored in an index so they can be searched quickly.
When a question comes in, this happens:
- The question is turned into an embedding as well.
- The index returns the sections whose meaning is closest to the question.
- The system builds one input from the instructions, the retrieved sections and the question.
- The language model writes the answer and can point to the sources it used.
The model itself is not changed. New content becomes available as soon as it is in the index, with no training run.
Why use RAG?
A language model does not know your price lists, manuals, contracts or internal procedures, and it knows nothing that happened after its training date. To answer questions about such material, you have to put the material in front of it. The model can only read a limited amount per request, so a whole archive does not fit. RAG solves this by picking only the few passages that matter for each question.
Typical uses are questions about a product manual, search across a knowledge base, or an assistant that works from a company's offers and documents. A practical benefit is traceability: the sources behind an answer can be shown and checked. Access rules can also be applied to the search, so people only get answers from documents they may see.
Where are the limits?
An answer is only as good as the passages found. If the wrong passage is retrieved or the right one is missed, the answer suffers. Quality therefore depends heavily on preparation: how documents are split, how current they are and how the search is done. Messy sources lead to messy answers.
The model can also still add details or summarize a source badly. RAG reduces hallucinations but does not remove them, so important statements still deserve a check against the source. Long documents raise a related question of how much fits into the model's context window.
Frequently asked questions
What is RAG?
RAG is a method in which a language model looks up matching text before it answers. The answer then rests on that text and not only on what the model learned in training.
Does RAG prevent wrong answers?
It makes them less likely but does not rule them out. The model can misread a source, and the search can return the wrong passages.
Does the model have to be retrained for RAG?
No. The model stays as it is. New content is added to the searchable collection.
Do I need a vector database for RAG?
Not necessarily. A vector index is the usual choice for searching by meaning, but for small collections an existing database with an extension, or a classic keyword search, is often enough.
Let us talk about your project
Write to kontakt@phronox.de or use the contact form.
Request a project Book a consultation