The Decoder / One term

What is RAG?

RAG, retrieval augmented generation, means looking up the relevant pages from your own documents first and handing only those to the AI model with your question, so the answer comes from your material.

By Mstimaj Numbers checked 30 September 2026 Updated 30 September 2026 Level Technical

Sign in to save your place and mark this done. Free, no card.

An open filing cabinet with three glowing folders pulled halfway out, next to a small reading lamp

RAG is an open book exam for an AI model. Instead of asking the model to remember, you store your documents in a searchable index, and when a question comes in, the system finds the few passages that match, pastes them in front of the question, and asks the model to answer from them. The model never learns your documents. It reads the relevant bits fresh each time, which is cheaper and easier to update than training.

Key facts

  • 3parts of every RAG system: an index of your text, a search step, the model
  • ~150,000words in a 200,000 token context window, Anthropic's own figure; the largest current windows hold about 555,000
  • ~90,000words in a 300 page book, so a shelf of manuals still overflows even the biggest window
  • 0training runs required: you update RAG by replacing files, not by retraining a model
  • Word counts from Anthropic's models page (200k tokens is about 150k words; 1M is about 555k); 300 pages at 300 words per page; Microsoft Learn definition of RAG; checked 30 September 2026

How do I give AI access to my own documents?

There are three ways, and RAG is the middle one. The first is to paste the document into the chat. It works for one file at a time and it costs tokens on every message. The second is fine tuning, which changes the model itself; it is slow, expensive, and the model still cannot quote your file accurately. The third is RAG: index the files once, search them on every question, hand the model the matches. Most products that say chat with your documents, including the projects and knowledge features in the big chat apps, are RAG under the hood.

For a small business the practical version is a folder of PDFs and text files, an indexing tool, and a chat window. The model reads three or four relevant passages per question, not the whole folder.

Three ways to get your documents into an AI model
Method How it works Updates when files change? Can quote the source? Cost
Paste into chat Whole file in every message Yes, by pasting again Yes Tokens on every message
RAG Index once, search per question Yes, re-index the file Yes Indexing plus normal usage
Fine tuning Retrain the model on your data No, retrain again No, it guesses Training run plus hosting

RAG vs fine tuning: which one do I need?

RAG when the answer lives in documents that change: prices, policies, product manuals, last month’s notes. Fine tuning when you want the model to behave differently: a house style, a format it must always follow, a specialised vocabulary. People reach for fine tuning to teach facts and are disappointed, because a fine tuned model still guesses. RAG puts the actual page in front of it, so the answer can be checked against a source.

The costs point the same way. RAG runs on the standard models at standard prices and updates the moment you drop in a new file. Fine tuning needs a curated dataset, a training run, and a repeat of both every time the facts move.

What fits in one context window WHAT FITS IN ONE CONTEXT WINDOW 200k token window ~150,000 words 1M token window ~555,000 words One 300 page book ~90,000 words Ten product manuals ~600,000 words
Even a 1 million token window, about 555,000 words on Claude's current tokenizer, fills up with ten manuals. RAG fetches only the pages that matter.

Why does the model still get things wrong with RAG?

Two reasons, and both are search problems rather than model problems. The search can miss: the passage that answers the question uses different words, so it is not retrieved, and the model answers from what it was given, which is the wrong page. Or the search returns too much, the important line is buried, and the model skims past it. Good RAG is mostly good indexing: sensible chunk sizes, clean text, and a search that understands meaning rather than exact words. The model is the easy part.

Is my data safe in a RAG system?

As safe as the place the index lives. If the index and the model both run on your own machine, the documents never leave it. If you use a cloud product, the passages retrieved for each question are sent to the vendor’s model with the question, so the vendor’s data policy applies to those passages. Read the training toggle before you upload a client file. The retrieval step itself adds no new risk; it only decides which pages travel.

Filed under Level: Technical

Ask what did not make sense

Comments go through our own form and are read before they appear. Links are not allowed; describe it in words.

Comments are read before they appear.

The newsletter

Get the next term.

One email when something goes up. The argument, the film and the term, nothing else. One click to leave.

Have a question now? Ask Mstimaj, she knows the archive.