fix: improve prompt robustness for local models during indexing (closes #1321)#1336
Open
botbikamordehai2-sketch wants to merge 2 commits into
Open
Conversation
jamesbraza
reviewed
Jun 8, 2026
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." |
Member
There was a problem hiding this comment.
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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