Retrieval-augmented generation (RAG) is a technique where an AI model or agent first searches a store of documents for information relevant to a request, then uses what it found to generate its response. It gives a large language model access to knowledge it was not trained on, such as a team's own documentation, bug reports or specifications.
Why it matters: Without a source of knowledge, every conversation with an AI agent starts like talking to someone on the first day of a new job. RAG lets an agent draw on the context a team has built up about an application, its quirks and its failure patterns. For testers, it also creates new things to test: whether the right documents were retrieved and whether the answer stays true to them.
In practice: Documents are split into chunks, converted into numerical representations called embeddings, and stored in a vector database. When a request comes in, the system searches that database by meaning and similarity, pulls back the closest matches, and passes them to the model alongside the prompt.
Examples:
- An agent given access to past bug reports writes new reports that follow the same template, even when the wording of the request is different.
- An internal assistant answers questions about a product's API by retrieving the relevant sections of its specification.
- A tester asks a RAG-based support bot a question whose answer sits in an outdated document, to see whether it repeats stale information.
Common pitfalls:
- Assuming the model's answer is correct because it cites retrieved documents, without checking those documents were the right ones.
- Feeding the knowledge store with outdated or contradictory material, which the agent then repeats with confidence.
Does RAG stop AI hallucinations? No. It reduces them by grounding answers in real documents, but a model can still misread, mix up or ignore the retrieved content, so outputs still need testing.
What is the difference between RAG and fine-tuning? RAG supplies extra knowledge at the time of each request, while fine-tuning changes the model itself through further training.