Start a project

What is RAG? Retrieval-augmented generation explained simply

RAG (retrieval-augmented generation) is a way of building AI features where the system first retrieves relevant passages from your own documents or database, then asks a language model to answer using only those passages. It lets a general model such as Claude, GPT or Gemini answer accurately about your products, policies or records without retraining it.

How does RAG work?

  • Prepare: split your documents into short passages and store each with an embedding, a list of numbers that captures its meaning.
  • Retrieve: turn the user's question into an embedding and find the passages closest to it, often combined with ordinary keyword search.
  • Generate: send the question and those passages to the model with an instruction to answer from them and cite them.
  • Check: show the sources with the answer, and log questions where nothing relevant was found.

RAG or fine-tuning?

Fine-tuning changes how a model writes; RAG changes what it knows at the moment of answering. For facts that change, such as prices, stock, policies or a customer's balance, RAG is almost always the right tool: update the document and the next answer is current. Fine-tuning suits a fixed style or format, and is rarely the first step.

Where RAG goes wrong

  • Passages cut in the wrong place, so the answer's key sentence is in the next chunk.
  • Old and new versions of a document both indexed, and the model picks the old one.
  • Questions that need numbers computed across many records. Those belong in a database query or a tool call, not in retrieved text.
  • No evaluation set, so nobody knows whether a change made answers better or worse.

When a tool call beats retrieval

"What does customer X owe?" is not a search problem. In ERES, our cloud ERP, the assistant calls a ledger tool that returns the computed balance. Use RAG for text and tools for live data; most useful assistants use both.

Questions people ask

What does RAG stand for in AI?
Retrieval-augmented generation: retrieving relevant passages from your own data and giving them to a language model so it answers from them rather than from memory.
Do I need a vector database for RAG?
Not always. Small collections work with embeddings stored in an ordinary database such as PostgreSQL or MongoDB Atlas. Dedicated vector databases help at larger scale.
Is RAG better than fine-tuning?
For facts that change, yes: update the source and the answers change. Fine-tuning is better for teaching a fixed style or output format.