RAG explained: handing AI a reference book
How do chatbots answer from your company's documents? Here's how RAG, a pattern widely used in AI products, works.
9 minAs of Oct 2026
By the end of this guide
- Explain why an LLM doesn't know your internal documents or recent information.
- Understand how RAG works: question, document search, then answer.
- Judge whether RAG or fine-tuning fits your situation.
Who this is for
- Anyone considering a chatbot over internal documents
- Anyone who keeps seeing RAG in AI product plans
What you need
- Reading "What is an LLM?" first will help.
Key ideas
The limit: it only knows what it was trained on
An LLM only knows what was in its training data. It can't know your company's leave policy or the price list you changed yesterday.
Hand it the reference material with the question
RAG, or retrieval-augmented generation, finds relevant documents when a question comes in and passes them to the LLM along with the question.
It's like an open-book exam. Because the answer comes from specific documents, you can show them as sources and check the answer.
How an internal-docs chatbot handles one question (example) Step What happens Example 1 Take the question "How far ahead can I book a meeting room?" 2 Find relevant documents Finds the "Booking rooms" section of the facilities guide 3 Send question and documents together Passes that section's text and the question to the LLM 4 Answer with sources "You can book up to two weeks ahead" + a link to the source Finding the right documents is half the job
To find relevant documents, systems usually turn text into numbers that capture meaning — a technique called embedding — so documents with similar meaning match even when the words differ.
Retrieve the wrong documents and you get the wrong answer. Most of a RAG system's quality is decided at this step.
Check it
- Open the source documents shown with an answer and check that the answer matches what they say.
- If the wrong documents keep showing up as sources, fix how documents are organized or searched before tuning the answers.
How it differs from fine-tuning
Fine-tuning trains the model itself further; RAG leaves the model alone and changes the reference material. For information that changes often, RAG is much easier to maintain.
RAG and fine-tuning at a glance Compare RAG Fine-tuning What changes The reference documents The model itself When information changes Swap the documents Train it again Showing sources Can show the documents it used Hard to show where an answer came from Good for Policies and product facts that change often Learning a consistent tone or format
Common mistakes
- Expecting good results from dumping in every file without organizing them
- Reading the answer without checking the source documents
References
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks — arXiv (Lewis et al., 2020)
- What is RAG? Retrieval-Augmented Generation AI Explained — AWS
- What is Retrieval-Augmented Generation (RAG)? — Google Cloud
- Retrieval augmented generation (RAG) and indexes in Microsoft Foundry — Microsoft Learn