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

BUG QuestionAnswerScorer counts a wrong option as correct when the answer appears inside a longer word or number

未关闭
#3,158 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@barkha1research-ai 已经在做这个了。

开始于 2026年10月12日。

  • #3159 来自 @barkha1research-ai —— 未关闭

评估

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

调研方向

Start by reading QuestionAnswerScorer and the AnswerMatches matching logic; reproduce the reported case with the provided scorer snippet. Check the scorer tests for substring matching and add coverage for answers embedded in longer words or numbers. Done means the correct option still scores True while the wrong option containing it scores False; pull request #3159 is already open for this issue.

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

描述

Bug: triage
Describe the bug

QuestionAnswerScorer checks its patterns with a plain substring test (text.lower() in response.lower()), so the correct answer also matches when it is only part of a longer word or number. A response that picks a wrong option is then scored as correct.

For example, with the correct answer 1, the response Option 2: 1000 scores True because 1000 contains 1. The same happens with 10000 inside 1000000, Vitamin B inside Vitamin B12, and the label pattern 1: inside 11:.

I ran the scorer over the WMDP test set (3,668 questions, the dataset used in the benchmark docs), answering each wrong option in the benchmark's Option {index}: {choice} format. 183 wrong answers, across 135 questions, are scored as correct.

Steps/Code to Reproduce
import asyncio

from pyrit.models import AnswerMatches, ContentScorable, ScoringExpectation
from pyrit.score import QuestionAnswerScorer
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    scorer = QuestionAnswerScorer()
    expectation = ScoringExpectation(
        conditions=[
            AnswerMatches(
                correct_answer="1",
                correct_answer_label="1",
            )
        ]
    )

    for response in ["Option 1: 1", "Option 2: 1000"]:
        scores = await scorer.score_async(
            scorable=ContentScorable(value=response),
            expectation=expectation,
        )
        print(f"{response!r}: {scores[0].get_value()}")


asyncio.run(main())
Expected Results
'Option 1: 1': True
'Option 2: 1000': False
Actual Results
'Option 1: 1': True
'Option 2: 1000': True
Versions
  • PyRIT version: installed from main (93bf08e4) in editable mode
  • Python version: 3.12

I have a fix that only matches the answer when it is not part of a longer word, and would like to open a PR for it.

主要语言
Python
星标
4.6k
派生
944
平均合并
2 天 20 小时
30 天内合并 PR
309

环境准备

在 Codespaces 中打开

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

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

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

microsoft/PyRIT 的其他 Issue

查看 microsoft/PyRIT 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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