Executable programs and extensions

Local LLM·RAG quality evaluation: Verifying changed settings with DeepEval

Verify answer quality separately, even when inference gets faster

DeepEval evaluates local LLM1 and RAG2 configurations by comparing questions, expected answers, retrieved evidence, and actual responses. Keep a fixed question set, assess retrieval context and answer grounding separately, then compare speed and memory only among configurations that meet your quality bar.

We will use a RAG system searching an internal vacation-policy PDF as an example. Include questions answerable from one sentence, questions requiring an exception in a table, and questions with no answer in the document. That mix helps show whether a configuration change suits real work.

Use DeepEval scores for automated comparison, while checking correctness against the retrieved evidence and answer text. Recording time to first token3, generation time, and peak memory also helps you choose a smaller model or another quantization4 while preserving quality.

Requirements and key details
  • Record the expected answer and passage to retrieve for each question.
  • Contextual Recall evaluates retrieved context; Faithfulness evaluates grounding in that context.
  • Set Ollama as the evaluation model and run deepeval test run.
  • Save retrieval, time to first token, generation time, and peak memory alongside scores.

Choose 20 questions for a baseline run

Prepare 20 questions for a RAG system over the vacation-policy PDF, mixing straightforward questions, questions that require a table exception, and questions the document cannot answer. For each, record the expected answer and the passage that must be retrieved, or mark “no evidence in the document.” Use real work questions, but first check whether personal or confidential source text may be sent to the evaluation service.

Save the baseline results first, then change only one of the model, quantization, or chunk settings. Use the same questions and expected answers for both configurations so changes in the test set are not mistaken for model improvements. If the document or expected answers change, version the question set as well.

An evaluation list organizing different question types and their evidence
Mix straightforward and difficult questions in proportions that reflect real use.

Use separate metrics for retrieval and answers

Include the input question, expected answer, actual answer, and retrieved evidence in the evaluation data. ContextualRecallMetric checks whether the retrieved context contains what the expected answer needs. FaithfulnessMetric checks whether the response stays grounded in that context. AnswerRelevancyMetric checks whether it directly addresses the question. Since the metrics measure different things, review per-question scores and their explanations together.

Do not decide whether a policy was violated from RAG scores alone. The evaluation model is an aid that automatically compares sentence meaning. A person should inspect the retrieved passage and answer for required conditions such as “six months or more.” DeepEval's LLM-based metrics call a separate evaluation model, so running the application locally does not automatically make evaluation local too.

A person reviewing an automated score alongside the source and retrieved passage
When scores are close or a judgment is unclear, have a person inspect the source and rationale.

Connect an Ollama evaluator and reproduce the run

DeepEval can use Ollama as its evaluation model. Start the Ollama server and install DeepEval in a new Python virtual environment5. ollama pull deepseek-r1:1.5b downloads the example evaluator, and deepeval set-ollama --model=deepseek-r1:1.5b sets it as the default. To use a model you already have, use the name shown by ollama list.

Replace the sample answer and retrieved text in the test code with results from your actual RAG run. Install the packages and download the model in a networked preparation environment. Check your operating requirements because signing in or syncing evaluation records to an external service may send data off the device.

Save the following code as test_rag.py and run deepeval test run test_rag.py to verify that the Ollama evaluator connects. In an air-gapped environment where you cannot verify the evaluator connection, do not treat the run as confirmed. The code's 0.5 thresholds are examples; set organizational thresholds based on required questions and human review.

Install and configure the local judge model
python -m venv .venv
source .venv/bin/activate
pip install -U deepeval
ollama pull deepseek-r1:1.5b
deepeval set-ollama --model=deepseek-r1:1.5b
Download an Ollama model locally and set it as DeepEval's default evaluator. Replace the name if using a model already installed.
test_rag.py
from deepeval import assert_test
from deepeval.metrics import (
    AnswerRelevancyMetric,
    ContextualRecallMetric,
    FaithfulnessMetric,
)
from deepeval.test_case import LLMTestCase


def test_vacation_policy_answer():
    test_case = LLMTestCase(
        input="입사 6개월 차 직원도 여름휴가를 쓸 수 있나요?",
        actual_output="입사 후 6개월 이상이면 여름휴가를 신청할 수 있습니다.",
        expected_output="입사 후 6개월 이상이면 여름휴가를 신청할 수 있습니다.",
        retrieval_context=[
            "여름휴가는 입사 후 6개월 이상 근무한 직원이 신청할 수 있습니다."
        ],
    )
    assert_test(
        test_case,
        [
            ContextualRecallMetric(threshold=0.5),
            FaithfulnessMetric(threshold=0.5),
            AnswerRelevancyMetric(threshold=0.5),
        ],
    )
This illustrates the evaluation wiring. For a real run, fill actual_output and retrieval_context with RAG execution records. 0.5 is only a starting value, not a business pass threshold.

Set pass criteria, then compare speed and memory

For every run, record the answer model and quantization, chunk size, embedding model, evaluator name and version, time to first token, generation speed, retrieval time, and peak memory. Scores alone do not show real waiting time, while speed alone does not reveal whether important conditions were missed.

Do not choose from a single average score. First set an acceptable failure count or pass rate for mandatory questions, such as leave eligibility, then compare speed and memory among configurations that meet it. A configuration that presents “no evidence” as a supported answer may be excluded even with a high average score. If score differences are small or a judgment looks wrong, inspect the source, retrieved passage, and answer before testing the next setting.

An evaluation view comparing response speed and evidence grounding side by side
Among configurations that pass the quality bar, choose one that is faster and uses less memory.

Terminology notes

  1. Large language model — A model trained on large text datasets to learn language patterns and process or generate text in context.

    Back to the text
  2. Retrieval-Augmented Generation — A method that retrieves material relevant to a query, adds it to the model input, and generates an answer from that context.

    Back to the text
  3. Time to First Token — The time from sending a request until its first output token arrives.

    Back to the text
  4. Quantization — A way to represent model weights or values with fewer bits, reducing storage and memory use. The coarser representation can also affect accuracy.

    Back to the text
  5. Python virtual environment — An isolated space for installing Python packages per project, helping reduce package-version conflicts.

    Back to the text

Frequently asked questions

What should you check first in this article?
DeepEval evaluates local LLM and RAG configurations by comparing questions, expected answers, retrieved evidence, and actual responses. Keep a fixed question set, assess retrieval context and answer grounding separately, then compare speed and memory only among configurations that meet your quality bar.
When is it better not to choose this?
Do not decide whether a policy was violated from RAG scores alone. The evaluation model is an aid that automatically compares sentence meaning. A person should inspect the retrieved passage and answer for required conditions such as “six months or more.” DeepEval's LLM-based metrics call a separate evaluation model, so running the application locally does not automatically make evaluation local too.