Learn how to evaluate the generation quality of your RAG pipeline.
By Dr. Ashish Bamania
Published: 2026-11-12
URL: https://www.intoai.pub/p/how-to-evaluate-rag-generation
🥳 We just hit 36K views on the Into AI YouTube channel in the last 3 weeks! If you haven’t yet, please subscribe for interesting and super-valuable videos all week. 🎥

While RAG is a core part of most AI systems today, many engineers are new to evaluating it well.
Here is what each term in Retrieval-Augmented Generation (RAG) means:
- Retrieval: obtaining relevant information from a knowledge base/ private datasets
- Augmentation: adding the retrieved information to the LLM’s context window
- Generation: the LLM generating a response based on the given query and relevant information added to the context window
In the last lesson on RAG evaluation, we discussed how RAG pipelines fail and learned how to evaluate RAG retrieval failures and context dilution.
In this lesson, we will learn how to evaluate RAG generation. Let’s begin!
Evaluating RAG generation
Generation failure occurs when relevant information is retrieved, but an LLM still fails to use it or makes up false information (hallucination).
Various metrics help evaluate generation and detect generation failures. Let’s discuss them one by one.
1. Faithfulness/ Groundedness
This is a measure of whether every claim in the generated answer is supported by the retrieved context.
Faithfulness can be measured at the claim level or at the answer level.
At the claim level, it is the fraction of claims in an answer that the retrieved context supports.
The formula to calculate it is as follows:
The following steps can be used to calculate it:
- An LLM breaks the generated answer down into individual claims. The prompt for doing this could look like the following:
Please break down the following answer into factual claims with each claim
containing only one fact.
Question: {question}
Answer: {answer}
Return the list of claims in JSON:
{"claims": [
"claim_1",
"claim_2",
...
]}
- Another LLM used as a judge is given these claims along with the retrieved context and prompted to check whether each claim is supported by the context. The prompt for doing this could look like the following:
Context: {context}
Claims: {claims}
For each claim, check whether it can be directly inferred
from the given context. Answer "yes" or "no" with the reason in one line.
The output should be returned in JSON which looks like:
[{"claim": ..., "reason": ..., "supported": "yes" or "no"}]
- Based on the output from Step 2 (we name the output
results), one calculates the faithfulness score as follows:
faithfulness_score = sum(result["supported"] == "yes" for result in results) / len(results)
Another, simpler way to calculate Faithfulness is to use a single prompt with an LLM as a judge. This is calculated at the answer level as the fraction of answers judged faithful.
Context: {context}
Answer: {answer}
Is every statement in the answer supported by the context?
Answer with a "yes" or "no", and explain the reason in one short sentence.
Each answer is labeled “yes” (faithful) or “no” (not faithful). Averaging these labels over the test set gives the percentage of faithful answers.
The claim-level score is finer-grained and flags exactly which claims are unsupported, making it useful for debugging and comparing models. The answer-level rate is coarser and simpler to calculate, making it useful for production monitoring.
In a RAG system, an LLM can still use the knowledge stored in its parameters to answer a user query. This might produce a correct answer, but it will still score low on faithfulness if the information used to answer the query is missing from the retrieved context.
Consider this user query: “Who was the first person to go into space, and which country was he from?”.
Let’s say the generated answer is: “Yuri Gagarin was the first person to go into space, and he was from the Soviet Union.”
On checking the retrieved context, we find that the only information retrieved from the given knowledge base was: “Yuri Gagarin was the first person in space and he achieved this on April 12, 1961.”
This means that the answer about the country he belonged to came from the LLM’s parametric knowledge, not the retrieved context.
We calculate claim-level faithfulness for this example as follows.
- Break down the answer into individual claims
- Claim 1: Yuri Gagarin was the first person to go into space.
- Claim 2: He was from the Soviet Union.
- Check whether each claim is supported by the retrieved context
- Claim 1 is supported by the context, while Claim 2 isn’t. The faithfulness score is calculated as follows.
