From 9f0765e47823066abb0b2a58efb1c2c8939ff786 Mon Sep 17 00:00:00 2001 From: mavericksea-ai Date: Fri, 9 Oct 2026 00:17:15 +0800 Subject: [PATCH 1/2] fix(tier3): derive accuracy scores from criterion verdicts Signed-off-by: mavericksea-ai --- CHANGELOG.md | 4 ++ .../tier3/eval_core/llm_judge.py | 7 +- .../tier3/harbor/templates/eval.py | 9 +-- tests/test_accuracy_arithmetic.py | 70 +++++++++++++++++++ 4 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 tests/test_accuracy_arithmetic.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b35b49e8..dc9de5576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed +- Derive accuracy scores from complete five-criterion verdicts in both judge + runtimes, so an inconsistent model-supplied total cannot distort Skill Lift. + Correct the Harbor prompt example to score five passing criteria as 1.0. + - Brought the published documentation in line with 0.5.0. It now covers how standard grading builds judge evidence and rebuilds trajectories from OpenCode and Codex logs, structured judge output and retries, the evidence diff --git a/src/skillevaluator/tier3/eval_core/llm_judge.py b/src/skillevaluator/tier3/eval_core/llm_judge.py index f3a4c3323..58e281518 100644 --- a/src/skillevaluator/tier3/eval_core/llm_judge.py +++ b/src/skillevaluator/tier3/eval_core/llm_judge.py @@ -809,11 +809,12 @@ def judge_accuracy( criteria = parsed.get("criteria") criteria_valid = _valid_accuracy_criteria(criteria) - score = _finite_score(parsed.get("score")) - if score is None: - assert criteria_valid + if criteria_valid: yes_count = sum(1 for v in criteria.values() if v is True) score = yes_count / 5.0 + else: + score = _finite_score(parsed.get("score")) + assert score is not None return { "score": round(score, 4), diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.py index 63f4ab746..c6582e868 100644 --- a/src/skillevaluator/tier3/harbor/templates/eval.py +++ b/src/skillevaluator/tier3/harbor/templates/eval.py @@ -8132,7 +8132,7 @@ def judge_accuracy(question, ground_truth, agent_text): Be lenient on exact wording but strict on factual correctness. Respond with ONLY a JSON object: -{{"criteria": {{"SKILL_IDENTIFIED": true, "ACTION_CORRECT": true, "FACTUALLY_ACCURATE": true, "TASK_ADDRESSED": true, "ACTIONABLE": true}}, "score": 0.8, "reason": "brief summary"}} +{{"criteria": {{"SKILL_IDENTIFIED": true, "ACTION_CORRECT": true, "FACTUALLY_ACCURATE": true, "TASK_ADDRESSED": true, "ACTIONABLE": true}}, "score": 1.0, "reason": "brief summary"}} USER QUESTION: {question} @@ -8158,10 +8158,11 @@ def judge_accuracy(question, ground_truth, agent_text): criteria = parsed.get("criteria") criteria_valid = _valid_accuracy_criteria(criteria) - score = _finite_score(parsed.get("score")) - if score is None: - assert criteria_valid + if criteria_valid: score = sum(1 for v in criteria.values() if v is True) / 5.0 + else: + score = _finite_score(parsed.get("score")) + assert score is not None return { "score": round(score, 4), "reason": _bounded_judge_text(parsed.get("reason", "")), diff --git a/tests/test_accuracy_arithmetic.py b/tests/test_accuracy_arithmetic.py new file mode 100644 index 000000000..6bb8f6f2d --- /dev/null +++ b/tests/test_accuracy_arithmetic.py @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Accuracy scores must implement the five-criterion rubric in both runtimes.""" + +from __future__ import annotations + +import json + +import pytest +from tests.conftest import load_harbor_eval_template + +from skillevaluator.tier3.eval_core import llm_judge +from skillevaluator.tier3.harbor.collector import _compute_lift + + +@pytest.fixture(params=["host", "harbor"]) +def accuracy_judge(request: pytest.FixtureRequest): + if request.param == "host": + return llm_judge + return load_harbor_eval_template("accuracy_arithmetic_template") + + +def _criteria(passed: int) -> dict[str, bool]: + return {key: index < passed for index, key in enumerate(sorted(llm_judge._ACCURACY_CRITERIA_KEYS))} + + +@pytest.mark.parametrize("passed", range(6)) +def test_accuracy_derives_score_from_complete_criteria(monkeypatch, accuracy_judge, passed): + payload = {"criteria": _criteria(passed), "score": 1 - passed / 5, "reason": "rubric verdicts"} + monkeypatch.setattr(accuracy_judge, "call_public_llm", lambda *_args, **_kwargs: (json.dumps(payload), None)) + + result = accuracy_judge.judge_accuracy("Summarize the CSV", "The total is 120", "The total is 120") + + assert result["score"] == pytest.approx(passed / 5) + assert result["criteria"] == payload["criteria"] + assert "error" not in result + + +@pytest.mark.parametrize( + "payload, expected", + [ + ({"criteria": _criteria(3), "score": 0.6}, 0.6), + ({"criteria": _criteria(3)}, 0.6), + ({"score": 0.6}, 0.6), + ], +) +def test_accuracy_preserves_consistent_and_legacy_payloads(monkeypatch, accuracy_judge, payload, expected): + monkeypatch.setattr(accuracy_judge, "call_public_llm", lambda *_args, **_kwargs: (json.dumps(payload), None)) + assert accuracy_judge.judge_accuracy("question", "reference", "answer")["score"] == expected + + +def test_accuracy_example_does_not_reverse_skill_lift(monkeypatch, accuracy_judge): + # The shipped Harbor prompt used all five true with a numeric score of 0.8. + payloads = iter( + [ + {"criteria": _criteria(5), "score": 0.8}, + {"criteria": _criteria(5), "score": 0.8}, + {"criteria": _criteria(4), "score": 0.8}, + {"criteria": _criteria(5), "score": 1.0}, + ] + ) + monkeypatch.setattr(accuracy_judge, "call_public_llm", lambda *_args, **_kwargs: (json.dumps(next(payloads)), None)) + scores = [accuracy_judge.judge_accuracy("question", "reference", "answer")["score"] for _ in range(4)] + lift = _compute_lift({"accuracy": sum(scores[:2]) / 2}, {"accuracy": sum(scores[2:]) / 2}) + + assert lift["accuracy"]["with_skill"] == 1.0 + assert lift["accuracy"]["without_skill"] == 0.9 + assert lift["accuracy"]["delta"] == 0.1 + assert lift["accuracy"]["direction"] == "up" From cabcfefa6e6259580a817cfed80e15468a3e95cd Mon Sep 17 00:00:00 2001 From: Narendran Raghavan Date: Thu, 15 Oct 2026 22:10:20 -0700 Subject: [PATCH 2/2] docs(tier3): describe criterion-derived accuracy scoring The Tier 3 guide said positive cases "retain their existing scoring contract", but this PR changes that contract: complete criterion verdicts now determine accuracy for every case, and the judge's numeric total is only a fallback for positive-case replies without criteria. State the applicable-criteria formula for both positive and negative cases. Pin the combined behaviour in both runtimes: negative cases score passing criteria out of the four applicable ones for every count, whatever the SKILL_IDENTIFIED verdict or model total, and record excluded_criteria/scoring_policy. A docs test guards the wording. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Narendran Raghavan --- docs/tier3-live-evaluation.mdx | 13 ++++++++----- tests/test_accuracy_arithmetic.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdx index d9acd954b..442d61315 100644 --- a/docs/tier3-live-evaluation.mdx +++ b/docs/tier3-live-evaluation.mdx @@ -551,11 +551,14 @@ grades each trial after the agent finishes. `security`, `skill_execution`, and `goal_accuracy`, and `behavior_check` are LLM judges that call the configured evaluator provider. `custom_only` runs none of them. -When `should_trigger` is false or no `expected_skill` is declared, accuracy -excludes `SKILL_IDENTIFIED` and calculates the score from the other four -criterion verdicts. The reward details record the excluded criterion and -`applicable-accuracy-criteria/v1` scoring policy. Missing criterion evidence is -an error. Positive cases retain their existing scoring contract. +Accuracy is calculated from the judge's criterion verdicts, not its numeric +total: passing applicable criteria divided by applicable criteria. Positive +cases score all five criteria; a positive-case reply with no criteria falls +back to the judge's numeric score. When `should_trigger` is false or no +`expected_skill` is declared, accuracy excludes `SKILL_IDENTIFIED` from both +counts and scores the other four criterion verdicts. The reward details record +the excluded criterion and `applicable-accuracy-criteria/v1` scoring policy. +Missing criterion evidence is an error for these cases. ### The graded trajectory diff --git a/tests/test_accuracy_arithmetic.py b/tests/test_accuracy_arithmetic.py index 6bb8f6f2d..76f26f8b2 100644 --- a/tests/test_accuracy_arithmetic.py +++ b/tests/test_accuracy_arithmetic.py @@ -1,11 +1,12 @@ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -"""Accuracy scores must implement the five-criterion rubric in both runtimes.""" +"""Accuracy scores must implement the applicable-criterion rubric in both runtimes.""" from __future__ import annotations import json +from pathlib import Path import pytest from tests.conftest import load_harbor_eval_template @@ -37,6 +38,33 @@ def test_accuracy_derives_score_from_complete_criteria(monkeypatch, accuracy_jud assert "error" not in result +@pytest.mark.parametrize("skill_verdict", [True, False]) +@pytest.mark.parametrize("passed", range(5)) +def test_negative_accuracy_scores_only_applicable_criteria(monkeypatch, accuracy_judge, passed, skill_verdict): + # Negative cases drop SKILL_IDENTIFIED from numerator and denominator; the model total stays ignored. + applicable = sorted(llm_judge._ACCURACY_CRITERIA_KEYS - {"SKILL_IDENTIFIED"}) + criteria = {key: index < passed for index, key in enumerate(applicable)} + criteria["SKILL_IDENTIFIED"] = skill_verdict + payload = {"criteria": criteria, "score": 0.1, "reason": "declined correctly"} + monkeypatch.setattr(accuracy_judge, "call_public_llm", lambda *_args, **_kwargs: (json.dumps(payload), None)) + + result = accuracy_judge.judge_accuracy("question", "reference", "answer", skill_identification_applicable=False) + + assert result["score"] == pytest.approx(passed / 4) + assert result["criteria"] == criteria + assert result["excluded_criteria"] == ["SKILL_IDENTIFIED"] + assert result["scoring_policy"] == "applicable-accuracy-criteria/v1" + + +def test_tier3_docs_describe_criterion_derived_accuracy(): + docs = (Path(__file__).resolve().parents[1] / "docs" / "tier3-live-evaluation.mdx").read_text(encoding="utf-8") + normalized = " ".join(docs.split()) + + assert "passing applicable criteria divided by applicable criteria" in normalized + assert "falls back to the judge's numeric score" in normalized + assert "existing scoring contract" not in normalized + + @pytest.mark.parametrize( "payload, expected", [