{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/mistral-ai/2025-04-09-evaluating-rag-with-llm-as-a-judge/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "Large Language Models (LLMs) are rapidly becoming essential tools for creating widely-used applications. But making sure these models perform as expected is much easier said than done. Evaluating LLM systems isn't just about verifying the outputs are coherent, but also about making sure the answers are relevant and meet the necessary requirements.\n\n## The Rise of RAG Systems\n\nRetrieval-Augmented Generation (RAG) systems have become a popular way to boost LLM capabilities. By pairing an LLM with a data retrieval system, LLMs can generate responses that are not only coherent but also grounded in relevant and current information. This helps cut down on moments when the model sounds confident but may actually be hallucinating.\n\nHowever, evaluating whether these RAG systems are performant isn't straightforward. It's not just about whether the output generated by the LLMs sounds correct, it's also about verifying at the source if the retrieved information is relevant and accurate. Traditional methods often miss these nuances, making a comprehensive evaluation framework essential.\n\nTaking a step back, there are many domains that face this same problem where there may be a lack of clear quantitative metrics or evaluation data to measure performance against and the measures of success may be more qualitative and nuanced.\n\n### LLM As A Judge: Using LLMs to Evaluate Other LLMs\n\nIn scenarios in which evaluations must be run at scale and there is a lack of human evaluators, “LLM As A Judge” has become a popular solution to evaluate the answers of LLM systems.\n\nThe way an “LLM As A Judge” typically works is to create a “judge LLM” that given the answer of a “generator LLM” is instructed to grade that answer based on a given scale. This scale can be numerical (e.g a 1-10 or 0-3 scale), binary (e.g True or False) or qualitative (e.g “Excellent”, “Good”, “Okay”, “Bad”). This grade can then be averaged across all questions of an evaluation dataset for an overall weighted score.\n\nFor the instruction prompt of an “LLM as A Judge” you can create custom criteria for the LLM to evaluate answers on. For example you can create specific grading criteria checking if responses are accurate, relevant, and grounded. Mistral’s models can be effectively used for both the generator and judge component of LLM systems.\n\n![Blog   Evaluating Rag Judge LLM](https://mistral.ai/_astro/d0f68ba1-77f4-4d28-ad97-4c62b34e4787_2e0t9K.webp?dpl=6ad1d7b6946342e26a4d2b4f)\n\n### The RAG Triad: A More Holistic Evaluation Framework\n\nThe RAG Triad is a popular evaluation framework for evaluating RAG systems designed to check the reliability and contextual integrity of LLM responses from the data sources. It was introduced by [TruLens](https://www.trulens.org/getting_started/core_concepts/rag_triad/) and several similar frameworks created like [RAGAS](https://docs.ragas.io/en/latest/concepts/metrics/overview/) have been created in order to more qualitatively evaluate RAG systems.\n\nThe RAG Triad focuses on three key areas:\n\n1\\. **Context Relevance**: This metric checks if the retrieved documents align well with the user's query. It ensures that the information used to generate the response is relevant and appropriate, setting the stage for a coherent and useful answer.\n\n2\\. **Groundedness**: This metric verifies if the generated response is based accurately on the retrieved context. It ensures that the LLM's output is factual and reliable, reducing the risk of those pesky hallucinations.\n\n3\\. **Answer Relevance**: This metric assesses how well the final response addresses the user's original query. It ensures that the generated answer is helpful and on point, aligning with the user's intent and providing valuable insights.\n\nBy using the RAG Triad, evaluators can get a comprehensive view of the LLM's performance, spot potential issues, and ensure that the responses are accurate, reliable, and contextually sound. This framework helps build trustworthy interactions between humans, AI and knowledge bases.\n\n![Blog   Evaluating Rag Groundedness](https://mistral.ai/_astro/42c8c934-bcf2-4450-b33a-5b90079f4ec0_ZXYbeG.webp?dpl=6ad1d7b6946342e26a4d2b4f)\n\nThis is particularly useful in evaluating a RAG LLM system end-to-end as it includes assessing both the retrieval and generation steps. This helps evaluate not just the LLM answer, but also it’s correctness relative to the source data retrieved.\n\n### Structured Outputs: A Practical Solution\n\nCustom structured outputs is a recent feature launched in our API which allows you to control the output format of LLMs and give values in a structured machine readable way so you have greater reliability.\n\nMistral's models together with structured outputs offer a practical way to implement the RAG triad and combat common evaluation challenges. By setting a clear criteria and schema for values, structured outputs help you build a more reliable “LLM As A Judge” that can be used for evaluating LLM systems.\n\nStructured outputs sets a perfect framework to define new and reusable criteria and enforce a format that is then easily machine readable for evaluation.\n\n```python\nfrom pydantic import BaseModel, Field\n# Assuming Score is defined elsewhere, e.g.:# Score = int | float | Enum  # Replace with your actual Score type\nSCORE_DESCRIPTION = \"A numerical or categorical score representing the evaluation metric.\"\nclass ContextRelevance(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how the retrieved context aligns with the user's query. \"            \"Consider the relevance of the information to the query's intent and the appropriateness of the context \"            \"in providing a coherent and useful response.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass AnswerRelevance(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how well the generated answer addresses the user's original query. \"            \"Consider the helpfulness and on-point nature of the answer, aligning with the user's intent and providing valuable insights.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass Groundedness(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how faithful the generated answer is to the retrieved context. \"            \"Consider the factual accuracy and reliability of the answer, ensuring it is grounded in the retrieved information.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass RAGEvaluation(BaseModel):    context_relevance: ContextRelevance = Field(        ...,        description=\"Evaluation of the context relevance to the query, considering how well the retrieved context aligns with the user's intent.\"    )    answer_relevance: AnswerRelevance = Field(        ...,        description=\"Evaluation of the answer relevance to the query, assessing how well the generated answer addresses the user's original query.\"    )    groundedness: Groundedness = Field(        ...,        description=\"Evaluation of the groundedness of the generated answer, ensuring it is faithful to the retrieved context.\"    )\n```\n\n## Conclusion\n\nEvaluating LLM systems is crucial for developing reliable AI applications. The RAG Triad, along with Mistral's structured outputs, provides a robust framework for assessing LLM performance with LLM as a judge. By focusing on context relevance, groundedness, and answer relevance, we can ensure that LLM responses are more accurate and meaningful. This approach enhances the user experience and the reliability of AI-driven applications, creating a more trustworthy interaction with the AI system.\n\n### Full Code\n\nYou can find the full code for LLM As A Judge for RAG here: \\\n[https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb](https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb)\n\n### Contact Us\n\nInterested in more custom work with the Mistral AI team? [Contact us](https://mistral.ai/contact) for solution support\n",
  "authors": [],
  "captured_at": "2026-10-19T01:26:53.998049939+00:00",
  "category": "ai",
  "content_html": "<p>Large Language Models (LLMs) are rapidly becoming essential tools for creating widely-used applications. But making sure these models perform as expected is much easier said than done. Evaluating LLM systems isn't just about verifying the outputs are coherent, but also about making sure the answers are relevant and meet the necessary requirements.</p>\n<h2>The Rise of RAG Systems</h2>\n<p>Retrieval-Augmented Generation (RAG) systems have become a popular way to boost LLM capabilities. By pairing an LLM with a data retrieval system, LLMs can generate responses that are not only coherent but also grounded in relevant and current information. This helps cut down on moments when the model sounds confident but may actually be hallucinating.</p>\n<p>However, evaluating whether these RAG systems are performant isn't straightforward. It's not just about whether the output generated by the LLMs sounds correct, it's also about verifying at the source if the retrieved information is relevant and accurate. Traditional methods often miss these nuances, making a comprehensive evaluation framework essential.</p>\n<p>Taking a step back, there are many domains that face this same problem where there may be a lack of clear quantitative metrics or evaluation data to measure performance against and the measures of success may be more qualitative and nuanced.</p>\n<h3>LLM As A Judge: Using LLMs to Evaluate Other LLMs</h3>\n<p>In scenarios in which evaluations must be run at scale and there is a lack of human evaluators, “LLM As A Judge” has become a popular solution to evaluate the answers of LLM systems.</p>\n<p>The way an “LLM As A Judge” typically works is to create a “judge LLM” that given the answer of a “generator LLM” is instructed to grade that answer based on a given scale. This scale can be numerical (e.g a 1-10 or 0-3 scale), binary (e.g True or False) or qualitative (e.g “Excellent”, “Good”, “Okay”, “Bad”). This grade can then be averaged across all questions of an evaluation dataset for an overall weighted score.</p>\n<p>For the instruction prompt of an “LLM as A Judge” you can create custom criteria for the LLM to evaluate answers on. For example you can create specific grading criteria checking if responses are accurate, relevant, and grounded. Mistral’s models can be effectively used for both the generator and judge component of LLM systems.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://mistral.ai/_astro/d0f68ba1-77f4-4d28-ad97-4c62b34e4787_2e0t9K.webp?dpl=6ad1d7b6946342e26a4d2b4f\" alt=\"Blog   Evaluating Rag Judge LLM\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<h3>The RAG Triad: A More Holistic Evaluation Framework</h3>\n<p>The RAG Triad is a popular evaluation framework for evaluating RAG systems designed to check the reliability and contextual integrity of LLM responses from the data sources. It was introduced by <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://www.trulens.org/getting_started/core_concepts/rag_triad/\">TruLens</a> and several similar frameworks created like <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://docs.ragas.io/en/latest/concepts/metrics/overview/\">RAGAS</a> have been created in order to more qualitatively evaluate RAG systems.</p>\n<p>The RAG Triad focuses on three key areas:</p>\n<p>1. <strong>Context Relevance</strong>: This metric checks if the retrieved documents align well with the user's query. It ensures that the information used to generate the response is relevant and appropriate, setting the stage for a coherent and useful answer.</p>\n<p>2. <strong>Groundedness</strong>: This metric verifies if the generated response is based accurately on the retrieved context. It ensures that the LLM's output is factual and reliable, reducing the risk of those pesky hallucinations.</p>\n<p>3. <strong>Answer Relevance</strong>: This metric assesses how well the final response addresses the user's original query. It ensures that the generated answer is helpful and on point, aligning with the user's intent and providing valuable insights.</p>\n<p>By using the RAG Triad, evaluators can get a comprehensive view of the LLM's performance, spot potential issues, and ensure that the responses are accurate, reliable, and contextually sound. This framework helps build trustworthy interactions between humans, AI and knowledge bases.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://mistral.ai/_astro/42c8c934-bcf2-4450-b33a-5b90079f4ec0_ZXYbeG.webp?dpl=6ad1d7b6946342e26a4d2b4f\" alt=\"Blog   Evaluating Rag Groundedness\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>This is particularly useful in evaluating a RAG LLM system end-to-end as it includes assessing both the retrieval and generation steps. This helps evaluate not just the LLM answer, but also it’s correctness relative to the source data retrieved.</p>\n<h3>Structured Outputs: A Practical Solution</h3>\n<p>Custom structured outputs is a recent feature launched in our API which allows you to control the output format of LLMs and give values in a structured machine readable way so you have greater reliability.</p>\n<p>Mistral's models together with structured outputs offer a practical way to implement the RAG triad and combat common evaluation challenges. By setting a clear criteria and schema for values, structured outputs help you build a more reliable “LLM As A Judge” that can be used for evaluating LLM systems.</p>\n<p>Structured outputs sets a perfect framework to define new and reusable criteria and enforce a format that is then easily machine readable for evaluation.</p>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-from syntax-python\">from</span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-meta syntax-import-source syntax-python\"> <span class=\"syntax-meta syntax-import-path syntax-python\"><span class=\"syntax-meta syntax-import-name syntax-python\">pydantic</span></span> <span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span></span></span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"> <span class=\"syntax-meta syntax-generic-name syntax-python\">BaseModel</span><span class=\"syntax-punctuation syntax-separator syntax-import-list syntax-python\">,</span> <span class=\"syntax-meta syntax-generic-name syntax-python\">Field</span></span>\n<span class=\"syntax-comment syntax-line syntax-number-sign syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-comment syntax-python\">#</span> Assuming Score is defined elsewhere, e.g.:# Score = int | float | Enum  # Replace with your actual Score type\n</span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-other syntax-constant syntax-python\">SCORE_DESCRIPTION</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">A numerical or categorical score representing the evaluation metric.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>\n<span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-storage syntax-type syntax-class syntax-python\">class</span> <span class=\"syntax-entity syntax-name syntax-class syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">ContextRelevance</span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-begin syntax-python\">(</span></span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-entity syntax-other syntax-inherited-class syntax-python\">BaseModel</span><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-class syntax-begin syntax-python\">:</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">explanation</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-type syntax-python\">str</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-group syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-begin syntax-python\">(</span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Step-by-step reasoning explaining how the retrieved context aligns with the user&#39;s query. <span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Consider the relevance of the information to the query&#39;s intent and the appropriateness of the context <span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">in providing a coherent and useful response.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>        <span class=\"syntax-punctuation syntax-section syntax-group syntax-end syntax-python\">)</span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">score</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">Score</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-other syntax-constant syntax-python\">SCORE_DESCRIPTION</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n<span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-storage syntax-type syntax-class syntax-python\">class</span> <span class=\"syntax-entity syntax-name syntax-class syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">AnswerRelevance</span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-begin syntax-python\">(</span></span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-entity syntax-other syntax-inherited-class syntax-python\">BaseModel</span><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-class syntax-begin syntax-python\">:</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">explanation</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-type syntax-python\">str</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-group syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-begin syntax-python\">(</span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Step-by-step reasoning explaining how well the generated answer addresses the user&#39;s original query. <span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Consider the helpfulness and on-point nature of the answer, aligning with the user&#39;s intent and providing valuable insights.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>        <span class=\"syntax-punctuation syntax-section syntax-group syntax-end syntax-python\">)</span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">score</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">Score</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-other syntax-constant syntax-python\">SCORE_DESCRIPTION</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n<span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-storage syntax-type syntax-class syntax-python\">class</span> <span class=\"syntax-entity syntax-name syntax-class syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">Groundedness</span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-begin syntax-python\">(</span></span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-entity syntax-other syntax-inherited-class syntax-python\">BaseModel</span><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-class syntax-begin syntax-python\">:</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">explanation</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-type syntax-python\">str</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-group syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-begin syntax-python\">(</span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Step-by-step reasoning explaining how faithful the generated answer is to the retrieved context. <span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Consider the factual accuracy and reliability of the answer, ensuring it is grounded in the retrieved information.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>        <span class=\"syntax-punctuation syntax-section syntax-group syntax-end syntax-python\">)</span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">score</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">Score</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span> <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-other syntax-constant syntax-python\">SCORE_DESCRIPTION</span></span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n<span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-storage syntax-type syntax-class syntax-python\">class</span> <span class=\"syntax-entity syntax-name syntax-class syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">RAGEvaluation</span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-begin syntax-python\">(</span></span></span><span class=\"syntax-meta syntax-class syntax-inheritance syntax-python\"><span class=\"syntax-entity syntax-other syntax-inherited-class syntax-python\">BaseModel</span><span class=\"syntax-punctuation syntax-section syntax-inheritance syntax-end syntax-python\">)</span></span><span class=\"syntax-meta syntax-class syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-class syntax-begin syntax-python\">:</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">context_relevance</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">ContextRelevance</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Evaluation of the context relevance to the query, considering how well the retrieved context aligns with the user&#39;s intent.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">answer_relevance</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">AnswerRelevance</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Evaluation of the answer relevance to the query, assessing how well the generated answer addresses the user&#39;s original query.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>    <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">groundedness</span></span><span class=\"syntax-punctuation syntax-separator syntax-annotation syntax-variable syntax-python\">:</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">Groundedness</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">Field</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">        <span class=\"syntax-constant syntax-language syntax-python\">...</span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>        <span class=\"syntax-variable syntax-parameter syntax-python\">description</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Evaluation of the groundedness of the generated answer, ensuring it is faithful to the retrieved context.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>    </span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n</span></span></code></pre>\n<h2>Conclusion</h2>\n<p>Evaluating LLM systems is crucial for developing reliable AI applications. The RAG Triad, along with Mistral's structured outputs, provides a robust framework for assessing LLM performance with LLM as a judge. By focusing on context relevance, groundedness, and answer relevance, we can ensure that LLM responses are more accurate and meaningful. This approach enhances the user experience and the reliability of AI-driven applications, creating a more trustworthy interaction with the AI system.</p>\n<h3>Full Code</h3>\n<p>You can find the full code for LLM As A Judge for RAG here: <br />\n<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb\">https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb</a></p>\n<h3>Contact Us</h3>\n<p>Interested in more custom work with the Mistral AI team? <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://mistral.ai/contact\">Contact us</a> for solution support</p>\n",
  "content_markdown": "Large Language Models (LLMs) are rapidly becoming essential tools for creating widely-used applications. But making sure these models perform as expected is much easier said than done. Evaluating LLM systems isn't just about verifying the outputs are coherent, but also about making sure the answers are relevant and meet the necessary requirements.\n\n## The Rise of RAG Systems\n\nRetrieval-Augmented Generation (RAG) systems have become a popular way to boost LLM capabilities. By pairing an LLM with a data retrieval system, LLMs can generate responses that are not only coherent but also grounded in relevant and current information. This helps cut down on moments when the model sounds confident but may actually be hallucinating.\n\nHowever, evaluating whether these RAG systems are performant isn't straightforward. It's not just about whether the output generated by the LLMs sounds correct, it's also about verifying at the source if the retrieved information is relevant and accurate. Traditional methods often miss these nuances, making a comprehensive evaluation framework essential.\n\nTaking a step back, there are many domains that face this same problem where there may be a lack of clear quantitative metrics or evaluation data to measure performance against and the measures of success may be more qualitative and nuanced.\n\n### LLM As A Judge: Using LLMs to Evaluate Other LLMs\n\nIn scenarios in which evaluations must be run at scale and there is a lack of human evaluators, “LLM As A Judge” has become a popular solution to evaluate the answers of LLM systems.\n\nThe way an “LLM As A Judge” typically works is to create a “judge LLM” that given the answer of a “generator LLM” is instructed to grade that answer based on a given scale. This scale can be numerical (e.g a 1-10 or 0-3 scale), binary (e.g True or False) or qualitative (e.g “Excellent”, “Good”, “Okay”, “Bad”). This grade can then be averaged across all questions of an evaluation dataset for an overall weighted score.\n\nFor the instruction prompt of an “LLM as A Judge” you can create custom criteria for the LLM to evaluate answers on. For example you can create specific grading criteria checking if responses are accurate, relevant, and grounded. Mistral’s models can be effectively used for both the generator and judge component of LLM systems.\n\n![Blog   Evaluating Rag Judge LLM](https://mistral.ai/_astro/d0f68ba1-77f4-4d28-ad97-4c62b34e4787_2e0t9K.webp?dpl=6ad1d7b6946342e26a4d2b4f)\n\n### The RAG Triad: A More Holistic Evaluation Framework\n\nThe RAG Triad is a popular evaluation framework for evaluating RAG systems designed to check the reliability and contextual integrity of LLM responses from the data sources. It was introduced by [TruLens](https://www.trulens.org/getting_started/core_concepts/rag_triad/) and several similar frameworks created like [RAGAS](https://docs.ragas.io/en/latest/concepts/metrics/overview/) have been created in order to more qualitatively evaluate RAG systems.\n\nThe RAG Triad focuses on three key areas:\n\n1\\. **Context Relevance**: This metric checks if the retrieved documents align well with the user's query. It ensures that the information used to generate the response is relevant and appropriate, setting the stage for a coherent and useful answer.\n\n2\\. **Groundedness**: This metric verifies if the generated response is based accurately on the retrieved context. It ensures that the LLM's output is factual and reliable, reducing the risk of those pesky hallucinations.\n\n3\\. **Answer Relevance**: This metric assesses how well the final response addresses the user's original query. It ensures that the generated answer is helpful and on point, aligning with the user's intent and providing valuable insights.\n\nBy using the RAG Triad, evaluators can get a comprehensive view of the LLM's performance, spot potential issues, and ensure that the responses are accurate, reliable, and contextually sound. This framework helps build trustworthy interactions between humans, AI and knowledge bases.\n\n![Blog   Evaluating Rag Groundedness](https://mistral.ai/_astro/42c8c934-bcf2-4450-b33a-5b90079f4ec0_ZXYbeG.webp?dpl=6ad1d7b6946342e26a4d2b4f)\n\nThis is particularly useful in evaluating a RAG LLM system end-to-end as it includes assessing both the retrieval and generation steps. This helps evaluate not just the LLM answer, but also it’s correctness relative to the source data retrieved.\n\n### Structured Outputs: A Practical Solution\n\nCustom structured outputs is a recent feature launched in our API which allows you to control the output format of LLMs and give values in a structured machine readable way so you have greater reliability.\n\nMistral's models together with structured outputs offer a practical way to implement the RAG triad and combat common evaluation challenges. By setting a clear criteria and schema for values, structured outputs help you build a more reliable “LLM As A Judge” that can be used for evaluating LLM systems.\n\nStructured outputs sets a perfect framework to define new and reusable criteria and enforce a format that is then easily machine readable for evaluation.\n\n```python\nfrom pydantic import BaseModel, Field\n# Assuming Score is defined elsewhere, e.g.:# Score = int | float | Enum  # Replace with your actual Score type\nSCORE_DESCRIPTION = \"A numerical or categorical score representing the evaluation metric.\"\nclass ContextRelevance(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how the retrieved context aligns with the user's query. \"            \"Consider the relevance of the information to the query's intent and the appropriateness of the context \"            \"in providing a coherent and useful response.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass AnswerRelevance(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how well the generated answer addresses the user's original query. \"            \"Consider the helpfulness and on-point nature of the answer, aligning with the user's intent and providing valuable insights.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass Groundedness(BaseModel):    explanation: str = Field(        ...,        description=(            \"Step-by-step reasoning explaining how faithful the generated answer is to the retrieved context. \"            \"Consider the factual accuracy and reliability of the answer, ensuring it is grounded in the retrieved information.\"        )    )    score: Score = Field(..., description=SCORE_DESCRIPTION)\nclass RAGEvaluation(BaseModel):    context_relevance: ContextRelevance = Field(        ...,        description=\"Evaluation of the context relevance to the query, considering how well the retrieved context aligns with the user's intent.\"    )    answer_relevance: AnswerRelevance = Field(        ...,        description=\"Evaluation of the answer relevance to the query, assessing how well the generated answer addresses the user's original query.\"    )    groundedness: Groundedness = Field(        ...,        description=\"Evaluation of the groundedness of the generated answer, ensuring it is faithful to the retrieved context.\"    )\n```\n\n## Conclusion\n\nEvaluating LLM systems is crucial for developing reliable AI applications. The RAG Triad, along with Mistral's structured outputs, provides a robust framework for assessing LLM performance with LLM as a judge. By focusing on context relevance, groundedness, and answer relevance, we can ensure that LLM responses are more accurate and meaningful. This approach enhances the user experience and the reliability of AI-driven applications, creating a more trustworthy interaction with the AI system.\n\n### Full Code\n\nYou can find the full code for LLM As A Judge for RAG here: \\\n[https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb](https://github.com/mistralai/cookbook/blob/main/mistral/evaluation/RAG_evaluation.ipynb)\n\n### Contact Us\n\nInterested in more custom work with the Mistral AI team? [Contact us](https://mistral.ai/contact) for solution support\n",
  "dateCreated": "2026-10-19T01:26:53.998049939+00:00",
  "date_created": "2025-04-09T12:00:00+00:00",
  "date_modified": "2025-04-09T12:00:00+00:00",
  "date_published": "2025-04-09T12:00:00+00:00",
  "description": "Large Language Models (LLMs) are rapidly becoming essential tools for creating widely-used applications. But making sure these models perform as expected is much easier said than done. Evaluating LLM systems isn't just about verifying the…",
  "external_url": "https://mistral.ai/news/llm-as-rag-judge/",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/mistral-ai/2025/04/2025-04-09-evaluating-rag-with-llm-as-a-judge.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/mistral-ai/2025/04/2025-04-09-evaluating-rag-with-llm-as-a-judge.md"
  },
  "id": "urn:aggr:item:c6fcd0dfed7059c63e7a4468d2fd33b6b80133ad",
  "isBasedOn": {
    "@id": "https://mistral.ai/news/llm-as-rag-judge/"
  },
  "mainEntity": {
    "@id": "https://mistral.ai/news/llm-as-rag-judge/",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/mistral-ai/2025-04-09-evaluating-rag-with-llm-as-a-judge/#webpage"
    },
    "dateModified": "2025-04-09T12:00:00+00:00",
    "datePublished": "2025-04-09T12:00:00+00:00",
    "headline": "Evaluating RAG with LLM as a Judge",
    "timeRequired": "PT5M",
    "url": "https://mistral.ai/news/llm-as-rag-judge/",
    "wordCount": 1104
  },
  "name": "Archived snapshot: Evaluating RAG with LLM as a Judge",
  "preview": null,
  "reading_minutes": 5,
  "replicated_at": null,
  "source": "mistral-ai",
  "source_name": "Mistral Blog",
  "summary": null,
  "tags": [],
  "temporalCoverage": "2026-10-19T01:26:53.998049939+00:00",
  "title": "Evaluating RAG with LLM as a Judge",
  "url": "https://aggr.aymericbeaumet.com/items/mistral-ai/2025-04-09-evaluating-rag-with-llm-as-a-judge/",
  "word_count": 1104
}