Skip to content

fix: soften ask_summary refusal for partially relevant knowledge - #17121

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
euvre:fix/ask-summary-prompt-partial-relevance
Jul 20, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
euvre:fix/ask-summary-prompt-partial-relevance

Conversation

@euvre

@euvre euvre commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

The ask_summary prompt (shared by the Python and Go backends) instructed the model to reply with the exact English string Sorry, 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 question rule, so non-English questions can get an English refusal.

This PR adjusts the prompt so that the model:

  • points out the mismatch and still summarizes the closest relevant content when the knowledge is partially relevant, instead of refusing;
  • refuses only when the knowledge is completely irrelevant, and always in the language of the user's question.

euvre added 2 commits July 20, 2026 17:27
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.
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 20, 2026
@euvre euvre added the ci Continue Integration label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The prompt now handles partially and completely irrelevant knowledge differently, while localized model settings text standardizes “URL” capitalization and punctuation across supported languages.

Changes

Prompt and locale updates

Layer / File(s) Summary
Knowledge relevance response guidance
rag/prompts/ask_summary.md
Partial relevance now calls out mismatches and summarizes the closest content; completely irrelevant knowledge receives a polite response in the user’s language.
Base URL localization
web/src/locales/*.ts
Model settings translations standardize “URL” capitalization and remove trailing exclamation marks; the Indonesian knowledge graph description is reformatted without changing its meaning.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: 🐞 bug

Suggested reviewers: cike8899

Poem

I nibbled the prompts till the answers grew clear,
And polished each URL for the settings frontier.
No stray exclamation hopped through the queue,
While languages bloomed in a calmer hue.
Thump-thump! said the rabbit: “The wording is new!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main prompt behavior change for partially relevant knowledge.
Description check ✅ Passed The description matches the required Summary template and includes the problem, context, and intended behavior changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@euvre
euvre requested a review from wangq8 July 20, 2026 11:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 392b249 and 728acae.

📒 Files selected for processing (14)
  • rag/prompts/ask_summary.md
  • web/src/locales/ar.ts
  • web/src/locales/bg.ts
  • web/src/locales/de.ts
  • web/src/locales/en.ts
  • web/src/locales/es.ts
  • web/src/locales/fr.ts
  • web/src/locales/id.ts
  • web/src/locales/it.ts
  • web/src/locales/ja.ts
  • web/src/locales/pt-br.ts
  • web/src/locales/ru.ts
  • web/src/locales/tr.ts
  • web/src/locales/vi.ts

Comment on lines +5 to +6
- 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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 -S

Repository: 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 -v160

Repository: 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 -S

Repository: 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 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@wangq8
wangq8 merged commit b769c3e into infiniflow:main Jul 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants