Guide

FoundationsLast reviewed: July 2026

What Is RAG?

RAG stands for retrieval-augmented generation. In plain terms: the AI looks things up in your own documents before it answers. It is the standard way to make a model useful on private material — and it works nothing like the thing most people assume it is.

Editorial review

Reviewed byOpenSourcesAI EditorialLast updatedJune 2026SourcesOfficial docs, GitHub repositories, model cards, vendor documentation, and OpenSourcesAI editorial review.

AI tools, model releases, pricing, licenses, and platform terms can change quickly. Verify the official source before production or commercial use.

The short answer

A language model only knows what it absorbed during training. It has never seen your contracts, your notes, or last quarter’s report. RAG is the standard fix: before the model answers, the system searches your documents, finds the passages that look relevant, and puts them into the prompt alongside your question.

The model then answers having just read those passages — exactly as if you had pasted them in yourself. That is the entire mechanism. The word “retrieval” is the searching part, “augmented” means your question got extra material attached to it, and “generation” is the model writing the answer.

Nothing about the model changes. It does not learn, remember, or absorb your files. Ask it the same question with the database switched off and it will know nothing about them, because it never did. This is the point most explanations skip, and almost every later misunderstanding traces back to it.

What actually happens when you ask a question

Steps one to three happen once, when you set the system up. Steps four to seven happen every time you ask something.

Step six is where the magic turns out to be plumbing. There is no special model mode and no training. The prompt just got longer, and the extra text happened to contain the answer.

RAG is not fine-tuning

When people say “I want to train the AI on my documents”, they nearly always want RAG. Fine-tuning is a different operation that solves a different problem, and reaching for it first is an expensive detour.

RAGFine-tuning
What changesThe prompt, at question timeThe model’s weights, permanently
Adding a documentIndex it — secondsRetrain — hours of GPU time
Removing a documentDelete from the indexVery hard; often retrain from scratch
Can cite its sourceYes — it knows which chunks it usedNo
Good forFacts, documents, anything that changesStyle, tone, output format, domain behaviour

The rule of thumb: fine-tuning changes how a model says things, RAG changes what it knows. If your goal is “it should answer questions about our documentation”, that is entirely a RAG problem. The fine-tuning guide covers the cases where the other column really is the right answer.

When you do not need it

RAG adds two components to your stack and a new class of failure. It is worth skipping when:

Reach for it when the opposite is true:

What it costs you

The honest tradeoff, because most introductions stop at the happy path.

Frequently asked questions

Does RAG train the model on my documents?

No, and this is the single most common misunderstanding. The model is never modified. Your documents are stored in a separate searchable database, and at the moment you ask a question the relevant passages are pasted into the prompt alongside it. The model reads them the way it reads anything else you type. Delete the database and the model knows nothing about your files, because it never did.

Is RAG the same as uploading a PDF to a chat app?

That is a small version of the same idea. When a chat app lets you attach a document, it is doing retrieval on your behalf — chunking the file, finding the parts that match your question, and putting them in the prompt. A full RAG setup is that mechanism made durable and scaled up: thousands of documents, indexed once, searchable across every conversation rather than one.

Do I always need a vector database?

No. For a few dozen documents, plain keyword search or simply pasting the relevant file into the prompt often works better and is far less machinery. Vector databases earn their place when you have enough content that you cannot know in advance which document holds the answer, or when questions are phrased differently from the source text.

Why does it give wrong answers when the information is in my documents?

Almost always because retrieval failed, not because the model did. If the right passage never reached the prompt, the model is answering from general knowledge and has no way to know it is missing something. Check what was actually retrieved before blaming the model — the fix is usually chunking, the embedding model, or adding a reranker, not a bigger LLM.

Can RAG run entirely on my own machine?

Yes. The embedding model, the vector database, and the language model all have local options — a small embedding model such as BGE or E5, a database such as Qdrant or Chroma, and any model you already run through Ollama. Nothing has to leave your machine, which is usually the reason for doing this locally in the first place.

What is an embedding model, and is it different from the main model?

Yes, different job and much smaller. An embedding model converts a piece of text into a list of numbers that represents its meaning, so that similar passages end up with similar numbers and can be found by proximity. It does not generate text. Most are a few hundred megabytes and run comfortably on a CPU, so adding one rarely changes your hardware requirements.

Does RAG make a small model smarter?

It makes a small model better informed, not better at reasoning. Retrieval supplies facts the model did not have; it does not improve the model’s ability to follow complex instructions or reason through a multi-step problem. If answers are weak on general questions, the model is the layer to change.

Next step: build one

The local RAG stack guide walks through every layer with real commands — document preparation, embeddings, Qdrant, and testing whether retrieval is actually finding the right passages. If you are still weighing which vector database to start with, the comparison guide narrows it down first.