adk eval --num_runs can pass hallucinations_v1 even when every run left it unscored
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
🔴 Required Information
Describe the Bug:
hallucinations_v1 returns NOT_EVALUATED (score None) for a run when the judge can't label one of the responses. That came in with 59b0dd63c, so an unlabelled response can't quietly drop out of the average.
With --num_runs > 1 that gets lost again. _get_metric_run_result still passes the run's per-invocation scores to mean_over_invocations, which skips the None and averages the rest. So across runs the metric is scored only on the responses the judge managed to label, and it can pass.
I noticed this while reading the aggregator, then checked it with the real evaluator and a stubbed judge (script below).
This is only on main for now (59b0dd63c isn't in 2.14.1). Judge failures do happen: in a 3-run adk eval of my own agent on main, one run logged Sentence validator returned 0 blocks for 1 sentences; this response will not be scored. That case has one turn per run, so it came out fine. You need a multi-turn case with one unscored turn to hit this.
Steps to Reproduce:
- main at c74df83c0,
uv sync --all-extras. - Run the script below. No network needed: the judge is stubbed to label the first response and fail on the second.
import asyncio
from unittest import mock
from google.adk.evaluation._eval_case_result_multi_run_aggregator import aggregate_eval_case_results
from google.adk.evaluation.eval_case import Invocation
from google.adk.evaluation.eval_metrics import EvalMetric
from google.adk.evaluation.eval_metrics import EvalMetricResult
from google.adk.evaluation.eval_metrics import EvalMetricResultPerInvocation
from google.adk.evaluation.eval_metrics import HallucinationsCriterion
from google.adk.evaluation.eval_metrics import JudgeModelOptions
from google.adk.evaluation.eval_result import EvalCaseResult
from google.genai import types
with mock.patch("google.adk.evaluation.hallucinations_v1.LLMRegistry"):
from google.adk.evaluation.hallucinations_v1 import HallucinationsV1Evaluator
metric = EvalMetric(
metric_name="hallucinations_v1",
threshold=0.5,
criterion=HallucinationsCriterion(
threshold=0.5,
judge_model_options=JudgeModelOptions(judge_model="gemini-2.5-flash"),
),
)
evaluator = HallucinationsV1Evaluator(metric)
async def judge(nl_response, context):
if nl_response.startswith("Paris"):
return 1.0, "[]"
return None, "unparsable judge output"
evaluator._evaluate_nl_response = judge
def invocation(text):
return Invocation(
user_content=types.Content(parts=[types.Part(text="q")]),
final_response=types.Content(parts=[types.Part(text=text)]),
)
async def run(index):
invocations = [
invocation("Paris is the capital of France."),
invocation("The Eiffel Tower is 900 m tall."),
]
result = await evaluator.evaluate_invocations(invocations)
# Built the way LocalEvalService builds a run's result.
return EvalCaseResult(
eval_set_id="set",
eval_id="case",
final_eval_status=result.overall_eval_status,
overall_eval_metric_results=[
EvalMetricResult(
score=result.overall_score,
eval_status=result.overall_eval_status,
**metric.model_dump(),
)
],
eval_metric_result_per_invocation=[
EvalMetricResultPerInvocation(
actual_invocation=actual,
eval_metric_results=[
EvalMetricResult(
score=r.score,
eval_status=r.eval_status,
**metric.model_dump(),
)
],
)
for actual, r in zip(invocations, result.per_invocation_results)
],
session_id=f"s{index}",
repetition_index=index,
)
async def main():
runs = [await run(i) for i in range(3)]
for n in (1, 3):
case = aggregate_eval_case_results(runs[:n])[0]
m = case.overall_eval_metric_results[0]
print(f"{n} run(s): score={m.score} {m.eval_status.name}, case {case.final_eval_status.name}")
asyncio.run(main())
Expected Behavior:
Three runs that are each unscored should be unscored overall, same as one run:
1 run(s): score=None NOT_EVALUATED, case NOT_EVALUATED
3 run(s): score=None NOT_EVALUATED, case NOT_EVALUATED
Observed Behavior:
1 run(s): score=None NOT_EVALUATED, case NOT_EVALUATED
3 run(s): score=1.0 PASSED, case PASSED
The judge never checked the second response (which is false), and the case passes.
Environment Details:
- ADK Library Version: main @ c74df83c0
- Desktop OS: Windows 10
- Python Version: 3.11.9
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (stubbed judge)
🟡 Optional Information
Regression:
Not in a release yet, see above. #8122 (retrying unscored judge calls) makes this rarer, but once the retries run out the aggregator still does the same thing.
Proposed fix:
In _get_metric_run_result, skip a run's invocation scores when its overall result is NOT_EVALUATED with no score. mean_of_runs and min_over_runs already leave that run out (its overall score is None), so all three score methods would agree. Scored runs still count, so one unscored run among scored ones is just left out. If you'd rather have any unscored run make the whole metric unscored, that's an easy change too.
I have this with a regression test in test_eval_case_result_multi_run_aggregator.py, and the eval unit tests pass. Happy to open a PR if that sounds right.
- Ngôn ngữ chính
- Python
- Star
- 22.3k
- Fork
- 4.4k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google/adk-python#8360 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
google/adk-python#8359 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Can pin to litellm version be changed?Có thể đã có người làm @llalitkumarrr đã nhận 10 ngày trước. Đang mởmodels
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
google/adk-python#8129 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
OpenAPI tools ignore operation- and path-level server overridesCó thể đã có người làm @sanketpatil06 đã nhận 14 ngày trước. Đang mởtools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google/adk-python#8064 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Two docstrings in openapi_tool document parameters the signatures do not acceptCó thể đã có người làm @surajksharma07 đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
google/adk-python#8024 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của google/adk-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vllm-project/vllm#70030 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TigreGotico/tugaphone#408 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
gke-labs/kube-agents#7308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
chore
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
lugassawan/swe-workbench#841 ·