Skip to content

fix: test_hallucination_detection missing qualitative marker and tight tolerance #809

Closed

Description

@planetf1

Problem

test_hallucination_detection in test/stdlib/components/intrinsic/test_rag.py:152 has two issues:

  1. Missing @pytest.mark.qualitative — every other LLM-output-quality test in the file is marked qualitative, but this one isn't. It runs in fast test loops where it shouldn't.

  2. Tolerance too tight — asserts pytest.approx(r, abs=3e-2) on a generative model score. Observed drift of 0.036 causes spurious failures (reported in fix: evict Ollama models between test modules to prevent memory starvation #804).

Fix

  • Add @pytest.mark.qualitative decorator
  • Widen tolerance from abs=3e-2 to abs=5e-2

Related

Activity

  1. added theissue type on Apr 9, 2026
  2. added
    bug
    on Apr 9, 2026
  3. self-assigned this
    on Apr 9, 2026
  4. planetf1 commented on Apr 9, 2026

    @planetf1
    ContributorAuthor

    Investigation

    • @pytest.mark.qualitative was already present on test_hallucination_detection — no marker change needed
    • Tolerance widened from abs=3e-2 → abs=5e-2 on both assertions (lines 161, 166)

    Justification for 5e-2

    • Score is a weighted expected value over token logprobs (not a raw LLM string or embedding distance)
    • Even at temperature=0.0, logprobs shift slightly across runs (inference non-determinism: batching, quantization, kernel ordering)
    • Observed drift of 0.036 on a score of ~0.728 is ~5% relative — categorical signal (hallucinated vs not) remains stable
    • 5e-2 catches real regressions (e.g. score flipping from 0.7→0.2) while absorbing normal logprob jitter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugtesting

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions