Retrieval-augmented generation, usually shortened to RAG, is the method most business chatbots use to answer from a company’s own content. Instead of relying only on what a language model learned in training, the system first retrieves passages related to the question and then asks the model to write a reply based on them. The term comes from a 2020 research paper by Patrick Lewis and colleagues at Facebook AI Research, and the approach has since become standard practice.
How RAG Works, Step by Step
- Prepare the content: pages from your chatbot knowledge base are split into smaller passages and indexed so they can be searched by meaning.
- Retrieve: when a question arrives, the system finds the passages most similar to it.
- Augment: those passages are added to the prompt alongside the visitor’s message and the bot’s instructions.
- Generate: the large language model (LLM) writes an answer using the supplied text.
Why RAG Beats Retraining a Model
The alternative is retraining or fine-tuning a model on your data, which is slow, expensive, and has to be repeated whenever something changes. With RAG, updating an answer is as simple as editing the page and refreshing the index. Answers are also easier to check, because you can see which passages the model was given. For a small business that changes prices seasonally or adds services every few months, that difference matters.
Where RAG Can Still Go Wrong
RAG reduces invented answers, but it does not remove them. Three weak points cause most problems.
- Bad retrieval: the search returns the wrong passage, so the model answers a different question.
- Missing content: the site never covers the topic, and the model fills the gap.
- Stale content: the index still holds last year’s prices.
Clear pages, regular re-indexing, and a polite fallback when nothing matches handle most of these. How AI Chatbot works shows how it answers from the WordPress pages you select.
