Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 18 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading