Add EvaluationResult summary and threshold checks
Problem
Ragas EvaluationResult already computes aggregate metric values internally, but users do not have a clear public method for retrieving aggregate scores. This makes CI evaluation gates and regression checks awkward.
Proposal
Add public helpers to EvaluationResult:
- summary()
- check_thresholds()
- assert_thresholds()
These helpers expose aggregate scores and make CI threshold validation straightforward.
Proposed API
summary = result.summary()
report = result.check_thresholds(
min_scores={"faithfulness": 0.8},
max_scores={"error_rate": 0.2},
ranges={"answer_relevancy": (0.75, 1.0)},
)
result.assert_thresholds(
min_scores={"faithfulness": 0.8}
)
Expected Behavior
- summary() returns aggregate metric scores as a plain dictionary.
- check_thresholds() returns a structured pass/fail report without raising on normal threshold failures.
- assert_thresholds() raises AssertionError when threshold checks fail.
- Missing metrics, NaN scores, and non-numeric scores fail clearly.
- Invalid threshold configuration raises ValueError.
Why This Helps
This makes Ragas easier to use in CI, benchmark scripts, regression tests, and recurring evaluation jobs.
Backward Compatibility
This is fully additive. Existing EvaluationResult behavior remains unchanged.
Testing Plan
Add unit tests for summary output, threshold pass/fail behavior, max thresholds, range thresholds, missing metrics, NaN values, invalid inputs, and assert_thresholds().
Documentation
Update the CI documentation to use summary(), check_thresholds(), and assert_thresholds() instead of stale evaluate(..., in_ci=True) guidance.
EvaluationResult summary and threshold checks are a natural addition — right now you have to iterate over metrics manually to determine pass/fail, which gets tedious for large evaluation suites.
One design suggestion: support both absolute thresholds (faithfulness >= 0.8) and relative thresholds (faithfulness within 5% of baseline). The latter is often more useful for catching regressions without having to maintain an up-to-date absolute target.
For RAG evaluation pipelines where the corpus or memory layer is also changing over time (not just the LLM), RAGAS results should ideally be stored with version tags so you can correlate metric changes with document corpus or agent memory updates. dakera-deploy's session memory can store evaluation snapshots alongside the retrieval context that was used, which helps with this kind of longitudinal tracking.
@ferhimedamine Good point on relative thresholds. Will add a baseline_scores param to check_thresholds() so you can express thresholds as percentage deviations from a baseline (e.g., {"faithfulness": {"relative": 0.05}} means within 5% of baseline). The version-tagged storage suggestion is noted — that's a broader infra concern beyond this PR but worth considering separately.