Retrieval Augmented Generation (RAG)

RAG lets a language model look things up in your data before it answers. How the architecture works and where it breaks down in practice.

What RAG solves

A language model sounds eloquent and still has no idea about your business. It knows neither your price list nor your internal support policies, and what it doesn't know, it often makes up. RAG lets the model look things up first.

Nothing gets trained in the process. Your data stays in your database, and the system only hands the model the matching text excerpt in the prompt for this one request. If a price changes, you swap the document instead of the model.

The process has three steps. The user asks a question. The system searches your documents for the matching paragraph. Then it passes the passage it found to the model along with the question, plus an instruction to use exactly this information. The critical point is the search: if it finds the wrong passage, the answer will be wrong, no matter how good the model is.

The pipeline behind it

It starts with chunking, breaking your documents into sensible bite-sized pieces. Next comes vectorization, and that's the real trick. An embedding model turns each chunk into a long series of numbers that represents its meaning rather than its wording. Two passages that mean the same thing end up close to each other in that number space.

That's what makes semantic search possible. For a question about "car", the system also finds the chunk that says "automobile". These number series are stored in a vector database, and when a request comes in, the question gets converted into an embedding too.

The search usually returns three to ten hits, sorted by relevance. They go straight into the prompt, together with the question and an instruction like "Answer exclusively based on the following excerpts". Every chunk takes up space in the context window, and too many hits water down the answer just as too few leave it incomplete.

RAG or fine-tuning

This is where companies like to burn budget on the question of whether they shouldn't just train the model on their own data. Most of the time the answer is no.

Fine-tuning is like studying for an exam: you change the model permanently. That's expensive and slow, and the knowledge is outdated as soon as your data changes. It works well for a style, badly for facts. RAG is more like a cheat sheet. The model stays clueless about your data, but it knows where the cheat sheet is.

Where RAG fails

Three spots break most often in practice. If the vector search returns a passage that's similar in topic but wrong in content, the model adopts the error with the same confidence as a correct answer. If the source document contains nonsense, even the cleanest architecture delivers nonsense. And if a paragraph gets cut in the wrong place during chunking, it loses its context.

So before you invest in expensive licenses, it's worth looking at your own documents. Structured, current and cleanly split sources decide more about answer quality than your choice of vector database.

Two further developments are worth a look. GraphRAG understands connections between pieces of content through a knowledge graph instead of just listing similar documents. Agentic RAG notices on its own when the first search isn't enough and keeps researching by itself, similar to how an AI agent plans several steps. How much weight a retrieved chunk keeps in the end belongs to context engineering.

Back to the AI and Automation Glossary.

FAQ

Do I have to retrain my model for RAG?
No, and that's exactly the point. The data stays in your database, and the model only gets it handed into the prompt as a text excerpt at answer time. If a price or a rule changes, you swap the document, not the model. Retraining would be unnecessarily expensive and slow for this.
Does RAG prevent hallucinations completely?
No. RAG lowers the risk considerably, because the model has to base its answer on the facts it's given instead of making things up freely. But if the search returns the wrong passage, or none at all, the model can still be off or fill the gaps with fantasy. RAG is a pair of reading glasses, not proof.
Do I absolutely need a vector database for RAG?
Not for simple keyword search, but yes for semantic search. A vector database also finds passages that mean the same thing but use different words, like "automobile" when the question asks about "car". Without one, RAG stays a simple search for exact terms, and in practice that misses far too often.
Portrait of Eric Hinzpeter

Eric Hinzpeter

Eric Hinzpeter, Senior B2B Content Strategist. He builds AI agents and marketing automation for production use and writes up what comes out of it here.

About meLinkedIn (new tab)