Skip to content

fix: improve prompt robustness for local models during indexing (closes #1321)#1336

Open
botbikamordehai2-sketch wants to merge 2 commits into
Future-House:mainfrom
botbikamordehai2-sketch:fix/issue-1321-1780831291
Open

fix: improve prompt robustness for local models during indexing (closes #1321)#1336
botbikamordehai2-sketch wants to merge 2 commits into
Future-House:mainfrom
botbikamordehai2-sketch:fix/issue-1321-1780831291

Conversation

@botbikamordehai2-sketch

Copy link
Copy Markdown

What

The PDF indexing process was failing when using local models (e.g., Ollama) because the summary prompt didn't clearly specify that the score must be on its own line at the end of the response. Local models often include extra text or formatting after the score, causing parsing failures during indexing.

Fix

Added explicit formatting instructions to the summary prompt telling the model that its response must end with the score alone on its own line, with no other text after it. This makes the output format more explicit and robust across different model providers.

Closes #1321

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 7, 2026
Comment thread src/paperqa/prompts.py
Comment on lines +16 to +17
"IMPORTANT: Your response must end with the score alone on its own line (e.g., '7'). "
"No other text after the score."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this PR, but it's using our failover match branch: http://github.com/Future-House/paper-qa/blob/v2026.03.18/src/paperqa/utils.py#L161-L166

The primary match branch is this: https://github.com/Future-House/paper-qa/blob/v2026.03.18/src/paperqa/utils.py#L150, which allows patterns like:

  • Relevance score: 7
  • Score is 7
  • Score 7

Can you few-shot prompt it to say "Relevance score: 7"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Article file indexing not working with local model

2 participants