Retrieval-Augmented Generation (RAG)
Retrieval-Augmented Generation (RAG) is a technique where an AI model retrieves relevant documents at query time and uses them to ground its generated answer.
RAG is why current, well-structured web content matters for AI visibility: when an engine retrieves passages to answer a question, the sources it pulls are the ones it can cite. Content written answer-first and marked up clearly is easier to retrieve accurately.
RAG is one part of how modern AI systems work. For the bigger picture — how large language models are built and how retrieval fits in — read What Are Large Language Models (LLMs)?
How it works
Source documents are split into passages, and each passage is turned into an embedding and stored in a search index. When a question arrives, it is embedded the same way, the most relevant passages are retrieved, often combined with keyword search, and those passages are placed in the model's context with an instruction to answer from them and cite them.
The answer can only be as good as retrieval: if the right passage is not found, the model either says it does not know or, worse, fills the gap from its own training.
Example
A company can let staff ask questions of its internal policies. Asked "how many days of leave can I carry over?", the system retrieves the relevant section of the HR handbook and answers with a link to it, instead of relying on what a model might guess from policies at other companies.
In practice
If you want an assistant that answers from your documents, start by gathering and cleaning the sources: current price lists, policies, service descriptions and FAQs, with old versions removed. Contradictions between documents are the most common cause of wrong answers, so resolve them before building. Decide what the assistant should not answer, such as medical advice or anything requiring a person's judgement, and what it should do then, usually offer contact details or hand over to staff.
Ask the developer how they will measure quality. A good answer includes a test set of real questions with known correct answers, checked for whether the right passage was retrieved and whether the final answer was accurate and cited. Ask how documents are updated: a process where staff edit a file and the assistant reflects it the same day is far better than one that needs a developer. Check permissions too. If some documents are internal only, the system must filter them by user before retrieval, not rely on instructions telling the model to keep secrets, which it may not follow.
Why it matters for your business
RAG is how an assistant answers from your current facts, such as prices, opening hours, policies and product details, instead of guessing from general training. When a document changes, the next answer changes with it, with no retraining. That makes it the usual approach for a customer-facing chatbot or an internal help desk. The cost moves from the model to your content: answers are only as good as the documents behind them, so outdated or contradictory files produce outdated or contradictory answers. Someone has to own the source library. Done well, it gives answers grounded in sources staff can check, which is what makes it safe to put in front of customers.
Common mistakes
- Chunking documents so that a question's answer is split across two passages and neither is retrieved.
- Skipping evaluation, so nobody knows how often the right passage is actually found.
- Letting the model answer when retrieval found nothing relevant, instead of saying so.
Questions people ask
Is RAG better than fine-tuning?
For facts, yes. RAG gives the model current information from your documents at the moment it answers, and updating the documents updates the answers. Fine-tuning changes how a model writes and formats, not what it reliably knows. Many systems use RAG alone; a few combine both, with fine-tuning for style and RAG for facts.
How much content do I need to build a RAG system?
There is no minimum: even a few well-written documents, such as your services, prices and policies, can support a useful assistant. Quality matters more than volume. Clear, current, non-contradictory documents with one topic per section retrieve far better than large piles of old files, duplicates and drafts.
Does RAG stop AI hallucinations?
It reduces them but does not stop them. The model can still misread a retrieved passage, combine two sources wrongly, or fill in an answer when retrieval found nothing relevant. Instructing it to answer only from the sources, to cite them and to say when it does not know, then testing it on real questions, narrows the gap further.