From df30e527f417ebb091b3f8dddae6f1a92f6aa923 Mon Sep 17 00:00:00 2001 From: Marcos Oliveira Date: Thu, 3 Dec 2026 09:49:13 -0500 Subject: [PATCH] Regression check: raise the hallucination limit from 0.10 to 0.15 Hallucination Rate is judged on 10 samples, so one answer judged differently moves it by about 0.10. Two CI runs of identical code differed by 0.10 on ChromaDB MMR (0.031 vs 0.131), which failed the check with no real change. 0.15 still catches a rise of 1.5+ answers. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- src/config.py | 4 +++- tests/test_smoke.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 35cb63d..5a25b9c 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,7 @@ compares this against a saved baseline and exits non-zero if any metric regresse Groundedness, Coherence, RAGAS scores): fails if they drop more than `REGRESSION_RELATIVE_DROP_THRESHOLD` (default 10%) relative to baseline. - **Hallucination Rate**: fails if it increases by more than - `REGRESSION_HALLUCINATION_INCREASE_THRESHOLD` (default 0.10, absolute). + `REGRESSION_HALLUCINATION_INCREASE_THRESHOLD` (default 0.15, absolute). ```bash python main.py # writes outputs/latest_results.json diff --git a/src/config.py b/src/config.py index d1541b2..3483088 100644 --- a/src/config.py +++ b/src/config.py @@ -55,9 +55,11 @@ # Precision, Recall, nDCG, Answer Relevance, Groundedness, Coherence) and max # allowed absolute increase in "lower is better" metrics (Hallucination Rate) # before scripts/regression_check.py reports a regression and exits non-zero. +# The hallucination limit is 0.15: with 10 judged samples, one answer judged +# differently moves the rate by about 0.10 with no code change. REGRESSION_RELATIVE_DROP_THRESHOLD = float(os.environ.get("REGRESSION_RELATIVE_DROP_THRESHOLD", "0.10")) REGRESSION_HALLUCINATION_INCREASE_THRESHOLD = float( - os.environ.get("REGRESSION_HALLUCINATION_INCREASE_THRESHOLD", "0.10") + os.environ.get("REGRESSION_HALLUCINATION_INCREASE_THRESHOLD", "0.15") ) BASELINE_RESULTS_PATH = os.path.join(OUTPUT_DIR, "baseline.json") LATEST_RESULTS_PATH = os.path.join(OUTPUT_DIR, "latest_results.json") diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 3f8a471..84fd18d 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -142,3 +142,21 @@ def test_fraud_signal_keeps_reject(): def test_no_fraud_signal_keeps_approve(): result = multimodal_securelife.apply_decision_rules(_decision("APPROVE", False)) assert result["decision"] == "APPROVE" + + +def _hallucination_failures(baseline, latest): + from scripts.regression_check import _check_metric_group + + failures = [] + metric = "Hallucination Rate (0-1)" + _check_metric_group("P", "generation_metrics", {metric: baseline}, {metric: latest}, failures) + return failures + + +def test_hallucination_noise_from_10_samples_is_not_a_regression(): + # CI run 47032655563: same code, ChromaDB MMR moved 0.0234 -> 0.1310 (+0.1076). + assert _hallucination_failures(0.0234, 0.1310) == [] + + +def test_large_hallucination_increase_is_a_regression(): + assert len(_hallucination_failures(0.0234, 0.20)) == 1