Dev.to AI πŸ€– Ai πŸ‘ 2 πŸ“– 4 min read

Your RAG Eval Can Pass With the LLM Switched Off: How to Test It

In a test, a CI gate for a RAG app reported zero hallucinations and passed. The LLM was switched off. The tool was openagent-eval 0.4.10, an open-source evaluation tool that the owner of this account maintains. Version

In a test, a CI gate for a RAG app reported zero hallucinations and passed. The LLM was switched off.

The tool was openagent-eval 0.4.10, an open-source evaluation tool that the owner of this account maintains. Version 0.4.11 fixes the problem, but other eval setups can have it too. Here are two small tests that catch it, with the output from both versions.

Why a broken setup can pass

Two things went wrong:

  1. No answer looks like a perfect answer. Hallucination is a "lower is better" score. An empty answer makes no false claims, so it scores 0, which is the best possible result.
  2. Word matching is not fact checking. Without an AI model to check claims, the tool compared words. "Refunds are available" and "Refunds are not available" share almost every word.

Neither problem causes an error. You just get a green check.

Test 1: Switch off the LLM

A useful gate has to pass when the app works and fail when it doesn't. Testing only one of those proves very little.

Install the tool in a new virtual environment:

pip install openagent-eval==0.4.11

Save one question as data.json:

[
  {
    "question": "Are refunds available after 30 days?",
    "ground_truth": "Refunds are not available after 30 days.",
    "ground_truth_contexts": ["Refunds are not available after 30 days."]
  }
]

Save this as dead-llm.yaml. It points at a port where no LLM is running:

dataset:
  path: data.json
llm:
  provider: ollama
  model: llama3
  base_url: http://127.0.0.1:9
retriever:
  provider: mock
metrics:
  retrieval: []
  generation: [hallucination]
  performance: []
  cost: []

Then save this as check-gate.sh and run it with bash check-gate.sh:

set -e

# 1. A working setup must pass.
sed 's/provider: ollama/provider: mock/' dead-llm.yaml > working.yaml
oaeval test working.yaml -t hallucination:lte:0.2

# 2. A setup with no LLM must fail.
if oaeval test dead-llm.yaml -t hallucination:lte:0.2; then
  echo "The gate passed without an LLM"
  exit 1
fi
echo "The gate works"

The first step uses a built-in fake LLM, so you don't need an API key.

Version Working setup LLM switched off Result
0.4.10 passes passes The gate passed without an LLM
0.4.11 passes fails The gate works

In 0.4.11 the hallucination score is still 0 when there is no answer. What changed is that the command now exits with an error if any question fails to get an answer. GitHub Actions uses the exit code to decide whether a check failed, so a good score can no longer hide a missing answer.

Test 2: Give the metric answers you know are wrong

Faithfulness measures whether the retrieved text supports the answer. Ragas, for example, splits an answer into claims and checks each one.

You can test any faithfulness metric with a few answers you have already judged yourself. Save this as canary.py:

from openagent_eval.metrics.generation.faithfulness import Faithfulness


def score(answer: str, context: str) -> float:
    """Replace this with a call to your own evaluator."""
    return Faithfulness().evaluate(answer=answer, contexts=[context]).score


NO_REFUNDS = "Refunds are not available after 30 days."
REFUNDS = "Refunds are allowed within 30 days."

CASES = [
    # name, context, answer, should it pass?
    ("exact copy", NO_REFUNDS, "Refunds are not available after 30 days.", True),
    ("negation removed", NO_REFUNDS, "Refunds are available after 30 days.", False),
    ("wrong number", NO_REFUNDS, "Refunds are not available after 90 days.", False),
    ("opposite word", REFUNDS, "Refunds are refused within 30 days.", False),
    ("correct paraphrase", REFUNDS, "You can get your money back for the first 30 days.", True),
]

for name, context, answer, should_pass in CASES:
    value = score(answer, context)
    verdict = "ok" if (value >= 0.8) == should_pass else "WRONG"
    print(f"{name:<20}{value:.2f}  {verdict}")

The pass mark is 0.8. These are the scores, with wrong verdicts in bold:

Answer Should pass? 0.4.10 0.4.11 0.4.11 with NLI
Exact copy yes 1.00 1.00 1.00
Negation removed no 1.00 0.00 0.00
Wrong number no 0.86 0.00 0.00
Opposite word no 0.83 0.83 0.00
Correct paraphrase yes 0.18 0.18 1.00
Correct verdicts 1 of 5 3 of 5 5 of 5

The first two columns compare words. Version 0.4.11 adds checks for negation and numbers, but it still misses an opposite word and rejects a correct paraphrase. It now prints a warning when it falls back to comparing words.

The last column uses a natural language inference (NLI) model, which judges whether one sentence follows from another. It needs a larger install, because it downloads PyTorch and a model:

pip install 'openagent-eval[nli]==0.4.11'

What these tests don't prove

Five hand-written sentences are a smoke test, not a benchmark. NLI won't always win either. In a test on 900 real RAG answers, simple word overlap did at least as well as a small NLI model.

Use examples from your own app, especially wrong answers that users have reported.

Add this to your own eval setup

These steps work with any tool:

  • Fail the run when an answer is missing. Don't rely on the score to show it.
  • Pair every "lower is better" metric with a "higher is better" one, such as answer relevancy. An empty answer should not do well on both.
  • Keep a few known-wrong answers in CI. If one starts passing, your metric is broken.
  • Check which method produced the score. Some tools, including this one, switch to a simpler method when a package or API key is missing.

If you already use openagent-eval

Two changes in 0.4.11 can turn a passing CI run red:

  • oaeval run and oaeval test now stop with an error when the LLM can't be created, for example when the API key is missing.
  • oaeval test now fails when any question gets no answer because of an error. --no-fail-on-error turns this off.

The release notes list everything else.

AI disclosure: fully autonomous. This article was written by Claude, an AI model, at the request of openagent-eval's maintainer. Claude also ran the tests, on Windows with Python 3.11, and the scores above come from those runs.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.