#20148·ragflow

[Feature Request]: Retrieval test should explain why chunks were dropped (query-level diagnosis)

Author: Bruce-YiiCreated Sep 23, 2026Updated Sep 28, 2026

Self Checks

  • I have searched for existing issues [search for existing issues](search for existing issues), including closed ones.
  • I confirm that I am using English to submit this report (Language Policy).
  • Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Is your feature request related to a problem?

Retrieval failures are opaque. When a query returns a thin or wrong result set, the user cannot tell which stage is responsible, and the retrieval test gives no explanation for what was excluded. Specifically:

  • Chunks whose score falls below similarity_threshold are silently dropped: they never appear in the POST /api/v1/retrieval response, and there is no record of which candidates were dropped or why.
  • There is no funnel: the user cannot see how many candidates were retrieved, how many survived the threshold, and how many were returned.
  • Per-chunk passing scores (similarity / vector_similarity / term_similarity) are already returned today, but the other half of the picture — what was excluded and why — is missing.

This matches the recurring "why can't chat find my content?" theme, and the project FAQ already acknowledges that attributing a bad answer to parsing vs. chunking vs. retrieval vs. generation is a core difficulty.

Describe the feature you'd like

An opt-in diagnosis payload on the retrieval test endpoint:

  • POST /api/v1/retrieval with debug: true returns, in addition to the current response:

    • funnel: candidates -> after_threshold -> returned
    • the similarity_threshold and vector_similarity_weight actually applied
    • dropped_total and dropped[]: candidates removed by the similarity threshold, each with chunk_id, similarity, term_similarity, vector_similarity, and reason
  • Default responses (no debug) stay byte-for-byte unchanged; this is read-only and alters no retrieval decision, ordering, filtering, or scoring.

Describe implementation you've considered

A minimal, opt-in implementation: a pure helper in rag/nlp/search.py that reshapes already-computed values into the diagnosis object, produced only when Dealer.retrieval(debug=True) is requested, and threaded through the retrieval-test route. The dropped list is bounded so a large candidate set cannot inflate the response.

A PR is open for review: #20147.

Documentation, adoption, use case

Use case: a knowledge-base operator runs a query in Retrieval Testing, sees too few results, and needs to know whether the threshold vector_similarity_weight or the query itself is the cause before filing a support issue. Diagnosis at the point of failure turns a black box into a debuggable surface.

Additional information

This is single-query diagnosis and is complementary to (not a duplicate of) the golden-set regression framework discussed in #15033 / #15035: that surface evaluates a dataset of cases, this one explains one query. Happy to align the shape with whatever the maintainers prefer (separate endpoint, existing trace concept, or folded into the evaluation work).