BUG QuestionAnswerScorer counts a wrong option as correct when the answer appears inside a longer word or number
Maintainers usually reply within 2 days
@barkha1research-ai is already working on this.
Since Oct 12, 2026.
- #3159 by @barkha1research-ai — open
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 944
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 309
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/PyRIT
-
BUG UnicodeReplacementConverter writes characters outside the BMP as invalid five-digit \u escapesPossibly taken @ShivamSharma43 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
BUG: label queries only return the final conversation of an attackPossibly taken @richlundeen claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microsoft/PyRIT#3095 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
-
BUG Configuration keeps runtime-status errors after polling recoversPossibly taken @joeyvictorino claimed this 2 days ago. OpenBug: triage GUI help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
microsoft/PyRIT#2868 · 4 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
BUG JailBreakV-28K loader reads a `transfer_attack_type` column that does not exist upstream and drops the real `from` / `transfer_from_llm` provenancePossibly taken @kushaltalati claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 35/100
microsoft/PyRIT#3161 · 1 comment ·
Maintainers usually reply within 2 days
-
feature-request
Difficulty 4/5 3-5 days Newbie friendliness 68/100
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
openwisp/openwisp-utils#777 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
google-research/weatherbenchX#310 ·
Maintainers usually reply within 3 days
-
`unload()` returns the trained `modules_to_save` copy instead of the original modulePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/peft#3955 ·
Maintainers usually reply within 1 day
-
author-page correction
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
acl-org/acl-anthology#10313 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AOSSIE-Org/Gitcord-GithubDiscordBot#147 · 1 comment ·
Maintainers usually reply within 1 day