What Is Retrieval-Augmented Generation (RAG)? A Plain-English Guide
Retrieval-augmented generation lets AI models answer using your own documents instead of memory alone. Here is how RAG works, when to use it and where it fails.
- Published
- Updated
- 5 min read

Key takeaways
- RAG retrieves relevant documents first, then has the language model answer using them.
- It keeps answers current and grounded in your own data without retraining the model.
- Most RAG quality problems come from retrieval and source data, not from the language model.
On this page
- The short definition
- Why RAG matters
- How a RAG pipeline works, step by step
- 1. Prepare the documents
- 2. Create embeddings
- 3. Store and index
- 4. Retrieve at question time
- 5. Re-rank (optional but valuable)
- 6. Generate the answer
- RAG vs fine-tuning vs long context
- Real-world uses
- Common reasons RAG projects underperform
- Getting started
- Conclusion
Large language models (LLMs) are impressive writers, but they have two well-known weaknesses: their knowledge stops at a training cut-off, and they sometimes state things that are not true with complete confidence. Retrieval-augmented generation (RAG) is the most widely used technique for addressing both problems. Instead of relying only on what the model memorised during training, a RAG system looks up relevant information first and hands it to the model along with the question.
This guide explains how RAG works, what it is good for, and the practical mistakes that cause RAG projects to disappoint.
The short definition
Retrieval-augmented generation is a pattern with two steps:
- Retrieve: search a collection of documents for passages relevant to the user's question.
- Generate: give those passages to a language model and ask it to answer using them.
The term comes from a 2020 research paper by Patrick Lewis and colleagues, which combined a neural retriever with a text generator and showed better results on knowledge-heavy tasks than a generator alone. Today "RAG" is used more loosely for any system that puts retrieved content into an LLM's prompt.
A short whiteboard explanation from an IBM Research scientist showing why LLMs need retrieval and how RAG adds sources to answers.
Why RAG matters
An LLM on its own answers from patterns learned during training. That causes three practical problems:
- Stale knowledge. The model does not know about anything that happened after its training data was collected.
- No private knowledge. It has never seen your company handbook, your product documentation or your support tickets.
- Unverifiable answers. Without a source, you cannot easily check whether an answer is correct.
RAG addresses all three. You can update the document collection whenever you like without retraining anything, you can include private material, and you can show users which passages an answer came from.
How a RAG pipeline works, step by step
1. Prepare the documents
Source material such as PDFs, web pages, wiki articles or database records is converted to plain text and split into chunks, typically a few hundred words each. Chunking matters: chunks that are too large dilute the relevant part, and chunks that are too small lose context.
2. Create embeddings
Each chunk is passed through an embedding model, which turns text into a list of numbers (a vector) that captures its meaning. Passages about similar topics end up with vectors that are close together, even if they use different words.
3. Store and index
The vectors are stored in an index that supports fast similarity search. This is the job of vector databases and of vector extensions for ordinary databases. Many systems also keep a traditional keyword index.
4. Retrieve at question time
When a user asks a question, the question is embedded with the same model, and the system finds the chunks whose vectors are most similar. Combining this with keyword search (often called hybrid search) helps with exact terms such as product codes, names and error messages, which pure semantic search can miss.
5. Re-rank (optional but valuable)
A second, more precise model can re-score the top results so that the best few passages go to the LLM. This step often improves answer quality more than switching to a bigger language model.
6. Generate the answer
The retrieved passages are inserted into the prompt with instructions such as "answer using only the sources below and cite them; if the answer is not in the sources, say so." The LLM writes the final response.
RAG vs fine-tuning vs long context
| Approach | What it changes | Best for | Main drawback |
|---|---|---|---|
| RAG | What the model sees at question time | Large or frequently changing knowledge, citations | Answer quality depends on retrieval quality |
| Fine-tuning | The model's weights | Consistent style, format or specialised behaviour | Costly to update, does not reliably add facts |
| Long context | Puts whole documents in the prompt | Small document sets, one-off analysis | Cost and latency grow with document size |
These approaches are not mutually exclusive. Many production systems use a fine-tuned or well-prompted model together with retrieval.
Real-world uses
- Customer support assistants that answer from help-centre articles and link to them.
- Internal knowledge search over policies, wikis and meeting notes.
- Developer tools that answer questions about a specific codebase or API documentation.
- Research assistants that summarise and compare documents while quoting their sources.
Common reasons RAG projects underperform
Most RAG failures are retrieval failures, not model failures. Watch for these:
- Poor source data. Outdated, duplicated or contradictory documents produce outdated, contradictory answers.
- Bad chunking. Splitting a table or a step-by-step procedure across chunks breaks its meaning.
- Semantic search only. Exact identifiers and rare terms are often better matched by keyword search, so consider hybrid retrieval.
- No evaluation. Build a small test set of real questions with known correct answers and measure whether the right passages are retrieved before tuning the prompt.
- Missing permissions. If documents have access controls, retrieval must respect them, or the assistant may reveal information to users who should not see it.
Getting started
For a first prototype, keep it simple: pick a small, high-quality document set, use an off-the-shelf embedding model, retrieve the top five or so chunks, and instruct the model to cite sources and admit when the answer is not present. Then collect real user questions and improve retrieval based on what fails. If you are new to working with AI assistants, our guide on writing better prompts covers the instruction-writing side.
Conclusion
Retrieval-augmented generation connects a language model to the information it needs at the moment it needs it. It is cheaper to keep current than fine-tuning, it works with private data, and it makes answers checkable through citations. Its quality, though, is capped by the quality of retrieval, so the most valuable work in any RAG project is cleaning the source data and measuring whether the right passages are being found.
Frequently asked questions
Is RAG the same as fine-tuning?
No. Fine-tuning changes a model's weights by training it on examples. RAG leaves the model unchanged and instead supplies relevant documents in the prompt at question time. RAG is usually the better fit for knowledge that changes often; fine-tuning is better for teaching a consistent style or format.
Does RAG stop AI hallucinations?
It reduces them but does not eliminate them. A model can still misread a retrieved passage, combine sources incorrectly or answer from memory when retrieval misses. Showing citations and testing retrieval quality are the main safeguards.
Do I need a vector database to build RAG?
Not necessarily. Vector databases are common because they make semantic search fast at scale, but small projects can use keyword search, a search engine you already run, or embeddings stored in a regular database.
Sources and further reading
Related articles

What Are AI Agents? How Agentic AI Works, With Examples and Risks
AI agents use language models to plan and act with tools until a goal is done. How they work, how they differ from chatbots, real examples and the risks.

Thousands March Against AI Data Centres in Edinburgh: Why Europe Is Pushing Back
About 6,000 people marched in Edinburgh against AI data centres. Why Scotland and Europe are pushing back, what campaigners want and what the EU is planning.

Gemini 4 Carbon Is Now Available: Google's Strongest AI Model, Price and Who Can Use It
Google released Gemini 4 Carbon on 10 November 2026. What the model is built for, who can use it, the API price rise on 30 November and what it means in the EU.