Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/google/adk/evaluation/_multi_run_aggregation_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def pass_at_k(runs: Sequence[RunResult], k: int) -> float | None:
decided, passed = _count_decided_and_passed(runs)
if decided < k:
return None
return 1.0 - math.comb(decided - passed, k) / math.comb(decided, k)
total = math.comb(decided, k)
return (total - math.comb(decided - passed, k)) / total


def pass_hat_k(runs: Sequence[RunResult], k: int) -> float | None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,30 @@ def test_pass_k_criteria_without_threshold_only_report():
assert aggregated.final_eval_status == EvalStatus.PASSED


def test_pass_at_one_meets_one_in_five_threshold() -> None:
runs = [
_judged_run(i, a=score)
for i, score in enumerate([1.0, 0.0, 0.0, 0.0, 0.0])
]
multi_run_config = MultiRunConfig(
cross_run_scoring=MultiRunCriterion(method="pass_rate", threshold=0.2),
cross_run_criteria=[
PassKMultiRunCriterion(method="pass_at_k", k=1, threshold=0.2)
],
)

(aggregated,) = aggregate_eval_case_results(
runs, multi_run_config=multi_run_config
)

(result,) = aggregated.cross_run_results
assert (result.value, result.status, aggregated.final_eval_status) == (
0.2,
EvalStatus.PASSED,
EvalStatus.PASSED,
)


def test_pass_hat_k_with_threshold_fails_the_case_below_it():
"""A pass^k criterion with a threshold judges the case like pass_rate."""
multi_run_config = MultiRunConfig(
Expand Down