Repository navigation
fix: soften ask_summary refusal for partially relevant knowledge - #17121
Conversation
The ask_summary prompt instructed the model to reply with the exact English string 'Sorry, no relevant information provided.' whenever it judged the knowledge irrelevant. For borderline queries (e.g. a phrase that partially matches knowledge content), reasoning models followed the instruction verbatim and refused, even overriding the 'answer in the user's language' rule. The prompt now asks the model to point out the mismatch and still summarize the closest relevant content, and to refuse only when the knowledge is completely irrelevant, always in the user's language.
📝 WalkthroughWalkthroughThe prompt now handles partially and completely irrelevant knowledge differently, while localized model settings text standardizes “URL” capitalization and punctuation across supported languages. ChangesPrompt and locale updates
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/prompts/ask_summary.md`:
- Around line 5-6: The empty-retrieval fallback in the ask service currently
returns a hardcoded English message before ask_summary can apply language
handling. Update the no-retrieved-chunks branch in the ask service to localize
the fallback using the user’s question language, or route that response through
the ask_summary prompt while preserving the existing no-relevant-information
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a264bc59-5cd3-466a-ba33-b3979f74af86
📒 Files selected for processing (14)
rag/prompts/ask_summary.mdweb/src/locales/ar.tsweb/src/locales/bg.tsweb/src/locales/de.tsweb/src/locales/en.tsweb/src/locales/es.tsweb/src/locales/fr.tsweb/src/locales/id.tsweb/src/locales/it.tsweb/src/locales/ja.tsweb/src/locales/pt-br.tsweb/src/locales/ru.tsweb/src/locales/tr.tsweb/src/locales/vi.ts
| - If the knowledge is only partially relevant, or the question may refer to something mentioned in the knowledge (e.g. a name, date, or phrase), briefly point out the mismatch and still summarize the closest relevant content instead of refusing. | ||
| - Only if the information from knowledge is completely irrelevant to user's question, politely say that no relevant information was found, and ALWAYS say it in the language of user's question. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## ask_summary.md\n'
nl -ba rag/prompts/ask_summary.md | sed -n '1,80p'
printf '\n## ask_service.go excerpt\n'
nl -ba internal/service/ask_service.go | sed -n '140,220p'
printf '\n## prompt usage search\n'
rg -n "ask_summary|no relevant information provided|no chunks|relevant information" internal rag -SRepository: infiniflow/ragflow
Length of output: 215
🏁 Script executed:
#!/bin/bash
set -euo pipefail
nl -ba internal/service/ask_service.go | sed -n '150,190p'
echo
nl -ba rag/prompts/ask_summary.md | sed -n '1,40p'
echo
rg -n "Sorry, no relevant information provided|ask_summary|no chunks|relevant information provided" -S .Repository: infiniflow/ragflow
Length of output: 196
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '160,180p' internal/service/ask_service.go | nl -ba -v160Repository: infiniflow/ragflow
Length of output: 196
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## internal/service/ask_service.go (around 150-190)\n'
sed -n '150,190p' internal/service/ask_service.go | cat -n
printf '\n## rag/prompts/ask_summary.md (around 1-20)\n'
sed -n '1,20p' rag/prompts/ask_summary.md | cat -n
printf '\n## search for fallback and prompt usage\n'
rg -n "Sorry, no relevant information provided|ask_summary|no chunks|relevant information provided" internal rag -SRepository: infiniflow/ragflow
Length of output: 6523
Make the empty-retrieval fallback honor the user language.
internal/service/ask_service.go:168-171 returns hardcoded English "Sorry, no relevant information provided." before ask_summary runs, so requests with no retrieved chunks never follow the prompt’s language rule. Localize that branch or route it through the prompt path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/prompts/ask_summary.md` around lines 5 - 6, The empty-retrieval fallback
in the ask service currently returns a hardcoded English message before
ask_summary can apply language handling. Update the no-retrieved-chunks branch
in the ask service to localize the fallback using the user’s question language,
or route that response through the ask_summary prompt while preserving the
existing no-relevant-information behavior.
wangq8
left a comment
There was a problem hiding this comment.
Review: PR #17121 — Soften ask_summary refusal for partially relevant knowledge
What it does
Revises the ask_summary.md prompt to instruct the model to:
- Still summarize the closest relevant content when knowledge is partially relevant, rather than hard-refusing.
- Only refuse when knowledge is completely irrelevant, and always in the user's language.
Removes trailing exclamation marks from validation messages across 13 locale files for consistency.
Analysis
Correctness: The prompt change is sound in principle. The original hard refusal was too rigid for reasoning models that follow instructions verbatim, often refusing on borderline queries where a helpful summary exists. The new wording gives the model more flexibility.
Prompt effectiveness caveat: This is an instructional change — its real-world behavior depends heavily on the target model's instruction-following characteristics. For strict models the "point out the mismatch and still summarize" instruction may still be followed literally; for reasoning models it should improve behavior. No regression risk since the worst case is the model continues to refuse (same as before).
Locale changes: Removing trailing exclamation marks from validation messages is consistent with the style work in #17120. Low risk.
Verdict
LGTM — net positive change, low risk, well-motivated. The prompt softens an overly rigid behavior without removing the safety valve for truly irrelevant content.
Summary
The
ask_summaryprompt (shared by the Python and Go backends) instructed the model to reply with the exact English stringSorry, no relevant information provided.whenever it judged the retrieved knowledge irrelevant to the user's question.In practice, for borderline queries whose phrasing partially matches knowledge content (e.g. a grade-level query that textually overlaps an era name in the retrieved document), reasoning models follow the instruction verbatim and hard-refuse, even though a helpful summary of the closest relevant content exists. The hardcoded English refusal string also overrides the
Answer in language of user's questionrule, so non-English questions can get an English refusal.This PR adjusts the prompt so that the model: