BUG QuestionAnswerScorer counts a wrong option as correct when the answer appears inside a longer word or number
维护者通常 2 天内回复
评估
调研方向
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 内容生成。
描述
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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG UnicodeReplacementConverter writes characters outside the BMP as invalid five-digit \u escapes可能已有人在做 @ShivamSharma43 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
BUG: label queries only return the final conversation of an attack可能已有人在做 @richlundeen 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/PyRIT#3095 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG Configuration keeps runtime-status errors after polling recovers可能已有人在做 @joeyvictorino 于 2 天前认领。 未关闭Bug: triage GUI help wanted
难度 2/5 1-3 小时 新手友好度 86/100
microsoft/PyRIT#2868 · 4 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG JailBreakV-28K loader reads a `transfer_attack_type` column that does not exist upstream and drops the real `from` / `transfer_from_llm` provenance可能已有人在做 @kushaltalati 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 35/100
microsoft/PyRIT#3161 · 1 条评论 ·
维护者通常 2 天内回复
-
feature-request
难度 4/5 3-5 天 新手友好度 68/100
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
aws-samples/sample-per-model-bedrock#191 ·
维护者通常 1 天内回复
-
Docs viewer: inverted grey colormap, Phantom CT window -20 to 35 HU, smoothing up to 40 mm可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area: docs enhancement
难度 2/5 1-3 小时 新手友好度 64/100
PyTomography/PyTomography#331 ·
维护者通常 1 天内回复
-
effort: low prio: low ready
难度 2/5 1-3 小时 新手友好度 82/100
digitalfabrik/integreat-cms#4616 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
FuRongJun-1999/dsh-memory#226 · 1 条评论 ·
维护者通常 1 天内回复
-
bug difficulty:2 good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
MakazhanAlpamys/Soup#1865 ·
维护者通常 1 天内回复