Glossary term

Retrieval-augmented generation (RAG)

Retrieval-augmented generation, or RAG, is an AI pattern that fetches relevant documents from a knowledge source and passes them to a language model to ground its answer. Testing RAG means checking both the retrieval step and the generated answer, with metrics such as context precision and faithfulness.

How a RAG system works

  1. Documents are split into chunks and stored, usually as embeddings in a vector database.
  2. For each question, a retriever finds the most relevant chunks.
  3. The model writes an answer using those chunks as context.

What to test in a RAG app

  • Retrieval: did it fetch the right chunks? Metrics such as context precision and context recall measure this.
  • Grounding: does the answer stick to the retrieved text? That is faithfulness.
  • Relevance: does it answer the actual question? See answer relevancy.

Testing the two halves separately tells you whether to fix the search step or the prompt.

Read the full guide: What Is RAGAS — Testing RAG Pipelines Explained for QA Engineers

← All glossary terms

Scroll to Top