A language model only knows what it saw in training. Retrieval-augmented generation, usually shortened to RAG, closes that gap without retraining: at question time the system searches a store of your documents, passes the most relevant passages to the model, and asks it to answer from them. It is the most common way businesses put an AI assistant over contracts, manuals, policies or support history.
How it works
A RAG system has two halves. The indexing half runs ahead of time: documents are split into passages (chunking), each passage is turned into an embedding, and the embeddings are stored in a vector database. The answering half runs per question: the question is embedded, the closest passages are retrieved, often re-ordered by a reranking model, and handed to the language model with an instruction to answer only from them and cite where each claim came from.
Most of the engineering effort goes into the indexing half. Messy PDFs, scanned pages, tables and documents that change every week decide whether retrieval finds the right passage. When a RAG system gives a wrong answer, the cause is more often a bad retrieval than a bad model.
What it means for cost
RAG builds price higher than a basic chatbot because the work is mostly data work: cleaning and splitting documents, choosing what to index, testing retrieval quality on real questions, and keeping the index fresh as documents change. Three things move a quote the most:
- Document mess. Clean text is cheap to index; scanned files, tables and mixed languages need OCR and custom parsing.
- Permissions. If different users may see different documents, retrieval has to respect access control, which adds real design and testing time.
- Proof of accuracy. A system that has to be trusted needs an evaluation set of real questions with known answers. See evals.
Running costs scale with the number of questions and the size of the passages sent to the model, so long contexts make every answer more expensive. The live figures for RAG builds are on the document search and RAG cost page.
When it is the wrong tool
RAG answers questions from text. It is a poor fit when the answer needs exact arithmetic over a database, which is a job for text-to-SQL, or when the model needs a new skill or tone rather than new facts, where fine-tuning can be the better choice.
Common questions
Is RAG the same as fine-tuning?
No. RAG gives the model new information at question time and leaves the model unchanged. Fine-tuning changes the model's weights to teach it a behaviour or style. Most business assistants over company documents use RAG, because documents change and retraining for each change is slow and costly.
Does RAG stop hallucinations?
It reduces them but does not remove them. Grounding answers in retrieved passages and asking for citations makes errors easier to spot, but a model can still misread a passage or answer when retrieval found nothing relevant. A good build tells the user when it has no source.