Who this guide is for
- Customer support leads answering the same product and policy questions every day.
- Operations and HR managers whose staff cannot find answers buried in manuals, wikis and shared drives.
- Founders and product teams adding an assistant to their product that must answer from their own data.
Key topicsRAG chatbotRAG chatbot for businesschatbot trained on company documentsretrieval-augmented generationRAG chatbot cost
What is a RAG chatbot?
RAG stands for retrieval-augmented generation. A RAG chatbot does not rely only on what a language model learned in training. When someone asks a question, it first searches your own content, such as help articles, policies, contracts or product manuals, picks the most relevant passages and passes them to the model with the question. The model then writes an answer from those passages.
The approach was described in a 2020 research paper by Lewis and colleagues at Facebook AI Research, and it is now the standard way to build an assistant that answers from company knowledge. Because the answer comes from retrieved text, the chatbot can cite its source and you can update its knowledge by updating the documents, without retraining a model.
- Answers questions from your documents, not from general internet knowledge.
- Shows the source page or file for each answer, so people can check it.
- Picks up new or changed documents as soon as they are re-indexed.
- Can respect access rules, so staff only get answers from documents they may see.
How does a RAG chatbot work?
There are two stages. Indexing runs ahead of time: documents are collected, cleaned, split into short passages and converted into embeddings, numeric representations of meaning, which are stored in a vector database such as pgvector, Pinecone or Qdrant. Answering runs on every question: the question is converted the same way, the closest passages are retrieved, often combined with keyword search, and the best ones are sent to the model with instructions to answer only from them.
Most of the quality comes from the unglamorous parts: how documents are split, whether tables and headings survive extraction, whether old versions are removed, and how retrieved passages are ranked. A strong model cannot fix retrieval that brings back the wrong passage.
- Ingest: connect sources such as Google Drive, SharePoint, Notion, a help centre or a database.
- Prepare: extract text, split it into passages and attach metadata such as title, date and access group.
- Index: create embeddings and store them in a vector database.
- Retrieve: find the best passages for each question with vector and keyword search.
- Answer: the model writes a short answer from those passages and cites them, or says it does not know.
When is a RAG chatbot the right choice?
RAG fits when the answers already exist in your content and the problem is finding them. Typical uses are customer support on product and policy questions, an internal assistant for HR, IT and operations procedures, sales teams looking up specifications and pricing rules, and professionals searching contracts, case files or research.
It is the wrong tool when the task is a calculation, a live lookup in a system or an action such as booking or refunding. Those need an integration or an agent that calls your systems. Many production assistants combine both: RAG for knowledge questions and tool calls for account-specific ones. If you are deciding between RAG and training a model on your data, our guide to RAG vs fine-tuning covers that choice.
How much does a RAG chatbot cost?
Cost has three parts. The build covers connecting sources, document preparation, retrieval tuning, the chat interface, access control and an evaluation set. Usage covers model calls for each answer and embedding calls when documents change; embeddings are cheap, so generation calls usually dominate. Hosting covers the vector database, the application and monitoring.
The biggest cost drivers are not the model. They are the number and messiness of sources, scanned PDFs and tables that need special extraction, per-user permissions, the languages you support and how much accuracy matters. A support bot on a tidy help centre is a much smaller project than an assistant over ten years of mixed files with role-based access.
- Build: source connectors, document processing, retrieval, interface, access control and testing.
- Usage: model tokens per answer plus embeddings for new or changed documents.
- Hosting: vector database, application server and logging.
- Running: reviewing answers, fixing gaps in documents and re-testing after changes.
How do you keep a RAG chatbot accurate?
Treat accuracy as something you measure, not something you hope for. Before launch, collect real questions with the correct answer and the document it should come from. Check two things separately: did retrieval find the right passage, and did the model answer correctly from it? Re-run the same test whenever documents, prompts or models change.
Instruct the model to answer only from the retrieved passages, to cite them and to say plainly when the documents do not contain the answer. Keep documents current and remove outdated versions, because retrieval will happily surface an old policy. A 2024 British Columbia tribunal decision, Moffatt v. Air Canada, held the airline responsible for wrong fare information its website chatbot gave, so answers that customers rely on need the same care as any other published information.
Security and privacy for a document chatbot
A chatbot can expose anything it can retrieve. Apply the same permissions as the source systems, so a question from a sales rep never retrieves HR files. Decide which documents are in scope, where embeddings and logs are stored, how long conversations are kept and which model provider processes the data under which terms.
Prompt injection is the main new risk: text inside a document or a user message that tries to override the instructions. The OWASP Top 10 for Large Language Model Applications lists it first. Limit what the chatbot can do beyond answering, never let retrieved text trigger actions on its own, and log questions and sources for review.
How to launch a RAG chatbot step by step
Start with one audience and one body of content, for example customers asking about returns and delivery, or staff asking about HR policy. Build the test set first, launch to a small group, and review the questions it could not answer: those usually point to missing or unclear documents rather than a model problem.
Our Company Knowledge Assistant blueprint follows this pattern with Next.js, FastAPI, pgvector and the OpenAI API: answers cite the source document, access follows the company's groups, and every question is logged for review. Widen the scope to more sources and users only when the measured accuracy holds.
- Pick one use case, one audience and the documents that answer it.
- Write 50 to 100 real questions with expected answers and sources.
- Build, test against that set and fix retrieval before tuning prompts.
- Pilot with a small group, review failures weekly, then expand.
Frequently asked questions
What is the difference between a RAG chatbot and ChatGPT?
ChatGPT on its own answers from what its model learned in training. A RAG chatbot first retrieves passages from your documents and answers from them, so it can answer questions about your business and cite where each answer came from.
Can a RAG chatbot answer from PDFs, Word files and websites?
Yes. Most text sources can be indexed, including PDFs, Word and Google documents, help centres, wikis and databases. Scanned PDFs need OCR, and tables and forms need careful extraction so their meaning survives.
Does a RAG chatbot still hallucinate?
It can, but far less when retrieval is good and the model is told to answer only from the retrieved passages and to say when it does not know. Measure it with a test set of real questions and review answers after launch.
How long does it take to build a RAG chatbot?
A focused chatbot on one well-organised source can reach a pilot in about three to six weeks. Several sources, per-user permissions, scanned files or multiple languages add time because each needs processing and testing.
Is my data used to train the model?
Not if you choose the right terms. Business API plans from major model providers state that customer data is not used for training by default, and you can host the vector database yourself. Check the provider's current data policy before launch.
Scope your RAG chatbot before you build
We review your documents, users and access rules, build a test set from real questions, then design a chatbot that answers with sources you can check.
Sources and further reading
Official documentation and original research supporting this guide. Product behavior and guidance can change; check the linked source for current details.
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020) (opens in a new tab)
- OWASP Top 10 for Large Language Model Applications (opens in a new tab)
- Moffatt v. Air Canada, 2024 BCCRT 149 (opens in a new tab)
- pgvector: open-source vector similarity search for Postgres (opens in a new tab)
- NIST AI Risk Management Framework (opens in a new tab)