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