AI Engineering · · 6 min

Evaluating RAG: beyond cosine similarity

How to evaluate retrieval-augmented generation properly: separate retrieval and generation metrics, build golden sets, measure faithfulness and catch regressions before users do.

RAG is two systems, so evaluate two systems

A RAG pipeline retrieves passages and then generates an answer from them. When an answer is wrong, the cause is either that the right passage was never retrieved, or that the model ignored or distorted it. Blended metrics hide which one happened.

Retrieval metrics

Build a golden set of questions, each labelled with the passages that contain the answer. Then track:

  • Recall@k — is a correct passage in the top k results?
  • MRR — how high does the first correct passage rank?
  • Coverage of 'no answer' questions — does retrieval return low-confidence results when the corpus genuinely lacks the answer?

Generation metrics

Faithfulness checks that every claim in the answer is supported by the retrieved context. Answer relevance checks that the answer addresses the question. Refusal accuracy checks that the system says it does not know when the context is insufficient — often the most valuable behaviour in regulated industries.

Why cosine similarity is not enough

Embedding similarity between an answer and a reference rewards answers that sound alike, not answers that are correct. Two answers differing by a single negation or number can score almost identically. Use it as a cheap signal, never as the gate.

Catching regressions

Run the full harness in CI whenever chunking, embeddings, rerankers, prompts or models change. Re-index changes are the silent killer: a new chunking strategy can lift one metric and quietly drop recall on tables or long documents.

Working on something similar?

Talee's engineers design, build and operate systems like this for regulated industries. The first call is free.

Talk to an engineer
FAQ

Questions about this topic

03 · Questions

01

What is a good recall@k for RAG?

+

It depends on the domain, but teams usually target high recall at k=5–10 on their golden set before tuning generation, because the model cannot use a passage it never sees.

02

What is faithfulness in RAG?

+

Faithfulness measures whether every statement in the generated answer is supported by the retrieved context, rather than invented by the model.

03

How often should RAG be re-evaluated?

+

On every change to chunking, embeddings, retrieval, prompts or model, and on a schedule as the underlying document corpus changes.

Related reading