Retrieval-Augmented Generation (RAG), Explained
Retrieval-augmented generation lets AI look up relevant documents before it answers. Learn how RAG works, why companies use it and where it falls short.

Retrieval-augmented generation (RAG) is a technique that lets an AI model look up relevant information from a chosen set of documents before it writes an answer. Instead of relying only on what it memorized during training, the model receives fresh, specific text as part of the prompt, which makes its answers more accurate, more current and easier to check.
If you have used a company chatbot that answers questions about its own policies, or an AI tool that "chats with your PDFs", you have almost certainly used RAG. This guide explains how it works step by step, why businesses rely on it, how it compares with fine-tuning, and where it can still go wrong.
What problem does RAG solve?
A large language model learns from a huge snapshot of text that stops at a training cut-off date. That creates three problems for anyone who wants to use it seriously.
- It does not know recent facts. Ask about last week's policy change and it may give last year's answer.
- It does not know your private data. It has never seen your company's HR handbook, product manuals or customer contracts.
- It may fill gaps by guessing. When unsure, models can produce confident but false answers, known as hallucinations.
Retraining a model every time a document changes would be slow and expensive. RAG takes a simpler route: keep the model as it is, and hand it the right reference material at the moment it answers. Think of it as the difference between a closed-book exam and an open-book one.
Where did RAG come from?
The term comes from a 2020 research paper by Patrick Lewis and colleagues at Facebook AI Research (now Meta AI), University College London and New York University. They combined a text generator with a retriever that searched a Wikipedia index, and showed that the pairing beat other approaches on several question-answering tests. They also noted a practical bonus: you can update what the system knows by swapping the documents, without retraining the model.
Since then, RAG has become one of the most common ways businesses put language models to work.
How does retrieval-augmented generation work?
A RAG system has two phases: preparing the knowledge, then answering questions.
Phase 1: Prepare the knowledge base
- Collect documents. Policies, manuals, wiki pages, support tickets, research papers or any text you want the AI to use.
- Split them into chunks. Long documents are cut into smaller passages, often a few paragraphs each, so the system can pull out just the relevant part.
- Create embeddings. Each chunk is converted into an embedding, a long list of numbers that captures its meaning. Passages about similar topics end up with similar numbers, even if they use different words.
- Store them. The embeddings go into a vector database, built to find the closest matches to a query quickly.
Phase 2: Answer a question
- The user asks something, such as "How many days of paternity leave do I get?"
- The question is turned into an embedding using the same method.
- The system retrieves the closest chunks, for example the paragraph from the HR policy that covers parental leave.
- The chunks are added to the prompt, along with an instruction such as "Answer using only the information below and cite the source."
- The model generates an answer grounded in those passages, often with links back to the original documents.
Many systems also mix in traditional keyword search, because meaning-based search can miss exact terms like product codes or legal clause numbers. Some add a "re-ranking" step that double-checks which retrieved passages are truly most relevant.
What is RAG used for?
- Customer support: chatbots that answer from up-to-date help articles and product documentation.
- Internal knowledge assistants: employees ask questions about company policies, processes and past projects.
- Legal and compliance: search across contracts or regulations and summarize relevant clauses with references.
- Healthcare and research: pull answers from clinical guidelines or scientific papers.
- AI search engines: tools that search the web, read results and write a cited summary use the same basic pattern.
- Personal tools: "chat with your documents" features in note apps and AI assistants.
Picture an insurance company in Bengaluru. Its agents field hundreds of questions a day about policy terms that change each quarter. A RAG assistant connected to the latest policy documents can answer with the exact clause and page number, and the company updates it simply by adding new documents.
RAG vs fine-tuning: which is better?
Fine-tuning means further training a model on your own examples so its behavior changes. RAG and fine-tuning solve different problems.
| RAG | Fine-tuning | |
|---|---|---|
| What it changes | What the model can see at answer time | How the model behaves |
| Best for | Facts, documents, frequently changing information | Tone, format, specialized tasks or jargon |
| Updating knowledge | Add or edit documents | Retrain the model |
| Shows sources | Yes, easily | No, knowledge is blended into the model |
| Cost to start | Usually lower | Usually higher |
A useful rule of thumb: use RAG when the problem is "the model does not know this", and fine-tuning when the problem is "the model does not act the way I want". Many production systems use both.
Does RAG still matter now that context windows are huge?
Leading models can now read hundreds of thousands of tokens at once, and some around a million. So why not paste every document into the prompt?
For small collections, that can work. But most organizations have far more text than any context window holds. Stuffing in huge amounts of text is also slower and more expensive per question, and models can overlook details buried in the middle of very long inputs. RAG keeps prompts focused on what matters. In practice, long context and RAG work together: retrieval picks the best material, and a larger window lets the model consider more of it.
What are the limitations of RAG?
Bad retrieval, bad answer. If the search step returns the wrong passage, the model will confidently answer from it. Most RAG failures are actually search failures.
Chunking is tricky. Split documents too small and you lose context. Too large and you add noise. Tables and scanned PDFs are especially hard to handle well.
Hallucinations are reduced, not removed. A model can still misread a passage, blend sources or add details that are not there. Showing citations helps people check.
Stale or conflicting documents. If the knowledge base contains an old policy alongside a new one, the system may pick the wrong one. Someone has to maintain the content.
Security and access. A RAG assistant must respect permissions. An intern should not be able to retrieve the board's salary spreadsheet just by asking the right question.
Why It Matters
If your company plans to put AI to work on its own documents, RAG is almost certainly the approach it will use, so it pays to understand where it breaks. The model gets the credit when things go well, but the real work is in the search step and in keeping the document library clean. An assistant that cites last year's policy with confidence is worse than no assistant at all.
That shifts some of the burden onto ordinary teams. Whoever owns the HR handbook, the product manual or the pricing sheet is now, in effect, maintaining the AI's knowledge. Old files left lying around become wrong answers, and loose access settings can expose information to people who should never see it.
For you as a user, the most useful habit is to click the citation. RAG's biggest advantage over a plain chatbot is that it can show its sources, and that only helps if someone looks. For businesses in India and the US weighing AI investments, RAG is also usually the cheaper and more practical starting point than training a custom model, which makes it a sensible first project rather than a final one.
Frequently asked questions
Is RAG the same as giving ChatGPT a file?
They are closely related. When you upload a long file, many assistants use a RAG-style process behind the scenes, splitting it into chunks and retrieving the relevant parts for each question. Business RAG systems do the same thing at much larger scale with many documents.
Do I need a vector database for RAG?
Not always. Small projects can store embeddings in memory or in an ordinary database with a vector extension. Dedicated vector databases help when you have millions of chunks or need fast, filtered search.
Does RAG stop AI hallucinations?
It reduces them by giving the model reliable source material, but it does not eliminate them. The model can still misinterpret what it retrieved, and if retrieval fails, it may fall back on guessing. Citations and human review remain important.
Can RAG work with images and tables?
Yes, increasingly. Multimodal models can embed and read images, charts and tables, and some systems convert tables into structured text first. Results are less consistent than with plain text, so complex documents need careful testing.
Researched and written by The AI Telegraph staff and checked against primary sources. See our editorial policy. Spotted an error? Tell us.

