RAG Chatbot: What It Is and How to Build One Safely
A RAG chatbot is a chatbot that looks up passages from your own documents first, then asks a language model to write its answer from those passages. "RAG" stands for retrieval-augmented generation. The goal is an answer based on your current runbooks, policies or product notes instead of on whatever the model remembers from training. This guide explains how the pieces fit, gives a build checklist, and lists the points where these systems usually fail.
What does RAG mean?
Retrieval-augmented generation (RAG) is a method in which a system retrieves relevant information from a knowledge base and adds it to the user's question before the model answers. Anthropic describes it in its Contextual Retrieval write-up as a method that "retrieves relevant information from a knowledge base and appends it to the user's prompt."
The term comes from a 2020 research paper, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks by Patrick Lewis and colleagues. The authors describe RAG as models "which combine pre-trained parametric and non-parametric memory for language generation." In plain terms: the model's built-in knowledge (parametric memory) is combined with an outside store of documents it can search (non-parametric memory).
A few terms used below:
- Chunk. A short piece of a document, usually a few paragraphs, stored and searched on its own.
- Embedding. A list of numbers that represents the meaning of a chunk, so that similar meanings sit close together.
- Vector database. A store that holds embeddings and finds the closest ones to a question.
- Prompt. The text sent to the model, here the question plus the retrieved chunks.
How does a RAG chatbot work?
Anthropic's description of "traditional RAG" gives the standard sequence:
- Break the knowledge base into smaller text chunks, usually a few hundred tokens each.
- Use an embedding model to turn each chunk into a vector embedding that encodes its meaning.
- Store the embeddings in a vector database for similarity search.
- At question time, find the chunks closest in meaning to the question and add them to the prompt.
- The model writes the answer from the question and those chunks.
When is a RAG chatbot the right choice?
| Situation | RAG chatbot fits? |
|---|---|
| Answers must come from documents that change often | Yes. Update the documents and the answers follow, with no retraining |
| Staff need to find the right page in a large set of runbooks | Yes, if the answer links to its sources |
| The answer needs a calculation or a live system lookup | Not alone. Add a tool or a fixed rule for that step |
| The documents are out of date or contradict each other | Not yet. Clean them first |
| The bot would act on accounts, money or access | Only with human approval of each action |
A support team at a managed service provider (MSP), a company that runs IT services for other businesses, is a typical case. Technicians search runbooks while a customer waits. Our post on what an AI service desk can and cannot do for an MSP covers where this fits among other service desk tasks.
How do I build a RAG chatbot? A checklist
- Pick one narrow job. For example: "answer questions about our password-reset and onboarding runbooks." Do not start with "everything we know."
- Collect the source documents and remove stale ones. The chatbot can only be as accurate as the pages behind it.
- Split documents into chunks at natural breaks such as headings, so a chunk still makes sense alone.
- Create embeddings and load them into a vector store.
- Write the instruction to the model: answer only from the supplied passages, quote or name the source, and say "I could not find this" when the passages do not cover the question.
- Build a test set of real past questions with the document that should answer each. Run it after every change.
- Add a human step for anything that changes data or goes to a customer.
- Log every question, the chunks retrieved and the answer. You need this to find out why a wrong answer appeared.
Example (made up for illustration): a technician asks, "How do we reset a client's VPN token?" The system retrieves the VPN runbook section on token resets, the model writes the steps, and the answer ends with a link to that runbook page. If the runbook has no such section, the correct reply is "I could not find this," not a guess.
Why do RAG chatbots give wrong answers?
Most failures happen at retrieval, before the model writes anything. Anthropic names a core weakness of traditional RAG: such systems "often destroy context." Its example is a chunk reading "The company's revenue grew by 3% over the previous quarter," which does not say which company or which period, so it is hard to retrieve for the right question.
The practical fixes follow from that:
- Keep the title or section heading attached to each chunk.
- Test retrieval on its own. For each test question, check whether the right chunk comes back before you judge the answer.
- Anthropic reports that its Contextual Retrieval method, which adds a short explanation of context to each chunk, reduced the top-20-chunk retrieval failure rate by 49%, and by 67% when combined with reranking. That result comes from Anthropic's own tests, not from your documents. Treat it as a reason to try the method, not as a figure you will get on your own content.
How do I keep a RAG chatbot safe?
Putting documents into a prompt creates security questions that a plain chatbot does not have. The OWASP GenAI Security Project, which publishes guidance on AI application risks, covers two that matter here.
Untrusted text can carry instructions. OWASP says that "indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files." A retrieved web page, email or uploaded file may contain text written to change what the model does. Among OWASP's listed mitigations in its prompt injection entry: "separate and clearly denote untrusted content," restrict the model's access privileges "to the minimum necessary," and require human approval for high-risk actions.
The knowledge base itself is a risk. OWASP's entry on vector and embedding weaknesses says these weaknesses create "significant security risks" in RAG systems. Its mitigations include "fine-grained access controls and permission-aware vector and embedding stores," validation pipelines that accept data only from trusted sources, and "detailed immutable logs of retrieval activities."
For a small team this becomes four rules:
- Only index documents you trust and can name an owner for.
- If staff see different documents, make the chatbot respect the same permissions. Never let one shared index expose a client's private notes to another client's technician.
- Give the chatbot read-only access at first.
- Keep logs so you can trace any answer back to its sources.
What does a RAG chatbot not do?
It does not make the documents correct, and it does not reason about facts that are not in them. It can still produce a fluent answer from the wrong passage. It is a search step plus a writing step, and each needs testing. Fix the documents and measure retrieval before you judge the model.
Frequently asked questions
What is the difference between a RAG chatbot and a normal chatbot?
A normal chatbot answers from what the model learned in training. A RAG chatbot first searches your documents and answers from the passages it finds, which lets it use information that is private or recent.
Do I need to train or fine-tune a model for RAG?
No. RAG adds your documents at question time, so you update the documents instead of retraining the model. Fine-tuning is a separate technique that changes the model itself.
Can a RAG chatbot stop making things up?
It reduces the problem but does not remove it. Tell the model to answer only from the supplied passages, show the sources, and let it say it could not find an answer.
How do I know if my RAG chatbot is working?
Run a fixed set of real questions after every change. For each, record whether the right document was retrieved and whether the answer matched it. Track the failures over time.
Where to go from here
Write down the one question set your team asks most often and the five documents that should answer it. That is your first test set. If you want to talk through connecting a language model to documents you already hold, the services page lists LLM and RAG work and links to a way to schedule a consultation.
Sources
All pages were read on 31 October 2026.
- Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" (2020): https://arxiv.org/abs/2005.11401
- Anthropic, "Introducing Contextual Retrieval" (RAG definition, chunking steps, failure mode, reported results): https://www.anthropic.com/news/contextual-retrieval
- OWASP GenAI Security Project, LLM01 Prompt Injection: https://genai.owasp.org/llmrisk/llm01-prompt-injection/
- OWASP GenAI Security Project, LLM08:2025 Vector and Embedding Weaknesses: https://genai.owasp.org/llmrisk/llm082025-vector-and-embedding-weaknesses/