Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

azure-ai-evaluation: PromptyEvaluatorBase falls back to the first digit anywhere in the judge's reply, and the threshold turns a stray digit into a wrong pass/fail (15 evaluators)

未关闭 适合新手
#49,153 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
ai, testing-qa

调研方向

该错误位于 sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py 的第196-198行。首先阅读 _do_eval 方法并理解正则表达式回退机制。编写一个测试,重现 issue 中列出的有问题的裁判回复。修复应改进正则表达式以找到预期的分数,而不是第一个数字。检查继承自 PromptyEvaluatorBase 的十五个评估器,确保修复适用于所有。运行现有测试以验证没有回归。

由索引模型根据 Issue 内容生成。

描述

Evaluation Service Attention

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py (HEAD 4993311), _do_eval:

  • line 188 — structured path: score = parsed_output.get("score", math.nan) ✓
  • lines 196-198 — fallback when the reply is not parseable JSON:
    match = re.search(r"\d", llm_output)
    if match:
        score = float(match.group())
    
  • lines 115-123 — the score is then compared to self._threshold (default 3) to produce the boolean result.

re.search(r"\d", …) returns the first digit anywhere in the text. The prompts ask for a bare integer, but nothing enforces it, and judge models routinely add reasoning before the number.

Measured

The fallback expression executed verbatim, with the threshold applied as at lines 115-123:

reply                                                                      first-digit score   >= 3 ?
'5'                                                                        5.0                 pass   (correct)
'The answer is grounded. 5'                                                5.0                 pass   (correct)
'The answer makes 3 claims, all supported by the context. Score: 5'        3.0                 pass   (score wrong: judge said 5)
'2 of the statements are unsupported, so this is not grounded: 1'          2.0                 fail   (score wrong: judge said 1)
'Score: 4 (one minor gap)'                                                 4.0                 pass   (correct)
'10 out of 10'                                                             1.0                 fail   (wrong: reads "10" as 1)
'0'                                                                        0.0                 fail   (out of range, no check)

Rows 3 and 4 are the point: the judge's verdict is correct, the recorded score is a number lifted from its explanation, and the pass/fail derived from it can differ from what the judge concluded. There is also no range check, so 0 and 7 are accepted on a 1–5 scale, and 10 becomes 1.

Stated plainly: I ran the fallback expression rather than importing the package; it is a two-line regex and the class wrapper does not alter it.

Who inherits this

grep -rl PromptyEvaluatorBase _evaluators/ — fifteen: coherence, fluency, groundedness, intent_resolution, relevance, response_completeness, retrieval, similarity, task_adherence, task_completion, tool_call_accuracy, tool_call_success, tool_input_accuracy, tool_output_utilization, tool_selection. One base class, one fix site.

Related

The deprecated promptflow-evals carried the identical re.search(r"\d") in five evaluators; this SDK inherited it into the base class and added the threshold on top, which is what turns a wrong number into a wrong verdict.

Suggested fix

In the fallback, prefer an anchored or labelled match before a bare digit: re.fullmatch(r"\s*(\d+)\s*", llm_output) (the whole reply is the number), then re.search(r"[Ss]core\s*[:=]?\s*(\d+)", llm_output), then the last number in the reply rather than the first; validate the result against the evaluator's declared range and return math.nan (which the aggregation already skips) with the raw reply in the reason field when it fails. One parametrized test with rows 3 and 4 above would pin it.

Happy to open the PR.

主要语言
Python
星标
5.6k
派生
3.4k
平均合并
1 天 18 小时
30 天内合并 PR
202

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/azure-sdk-for-python 的其他 Issue

查看 Azure/azure-sdk-for-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。