Doubt about the topk and threshold usage in rerank stage settings #1844

Closed
opened 2026-02-21 17:38:36 -05:00 by yindo · 0 comments
Owner

Originally created by @zfanswer on GitHub (Apr 7, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.5.10

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

image enable the rerank model, and set threshold value and topk value, debug the recall behavior.

✔️ Expected Behavior

topk and threshold value should only affect rerank stage, like the doc describes.
(sorry, I didn't find this explaination in English doc...)
image
the last line words says, the topk and threshold value will only affect the rerank stage.
(there is another doubt, somehow, I assume that dify has a mechanism that recall a limited item set from vectordb and send them to rerank stage)
so the RAG with rerank steps will be like:
sim search and get a bunch of doc chunks ==> somehow? to get n (n>k) chunks ==> rerank stage ==> filtered by the treshold
==> get top-k from reordered and filtered chunk list ==> got final reference

Actual Behavior

image
from the code, seems the recall logic use topk and threshold both in the first retrival and rerank stage.
so current RAG with rerank steps are:
sim search ==> filtered by threshold and get top-k chunks ==> rerank stage to get reodered chunk list ==> again, filtered by threshold and get top-k chunks ==> got final reference
I think reranking chunks within the top-k chunks got from the first retrival stage is kind of meaningless, if user always tend to use very small top-k value like 2, 3... there is no meaning for reranking with in this kind of small chunk set.
what do you think?

Originally created by @zfanswer on GitHub (Apr 7, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.5.10 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce <img width="729" alt="image" src="https://github.com/langgenius/dify/assets/1787565/e84f29ee-c266-42ee-a509-ac8e524220ca"> enable the rerank model, and set threshold value and topk value, debug the recall behavior. ### ✔️ Expected Behavior topk and threshold value should only affect rerank stage, like the doc describes. (sorry, I didn't find this explaination in English doc...) <img width="858" alt="image" src="https://github.com/langgenius/dify/assets/1787565/11415c78-fd18-4da7-ac07-fd29abad382f"> the last line words says, the topk and threshold value will only affect the rerank stage. (there is another doubt, somehow, I assume that dify has a mechanism that recall a limited item set from vectordb and send them to rerank stage) so the RAG with rerank steps will be like: sim search and get a bunch of doc chunks ==> somehow? to get n (n>k) chunks ==> rerank stage ==> filtered by the treshold ==> get top-k from reordered and filtered chunk list ==> got final reference ### ❌ Actual Behavior ![image](https://github.com/langgenius/dify/assets/1787565/63431bd6-6831-418b-b3b7-85bc076b1cb6) from the code, seems the recall logic use topk and threshold both in the first retrival and rerank stage. so current RAG with rerank steps are: sim search ==> filtered by threshold and get top-k chunks ==> rerank stage to get reodered chunk list ==> again, filtered by threshold and get top-k chunks ==> got final reference I think reranking chunks within the top-k chunks got from the first retrival stage is kind of meaningless, if user always tend to use very small top-k value like 2, 3... there is no meaning for reranking with in this kind of small chunk set. what do you think?
yindo added the 🙋‍♂️ question label 2026-02-21 17:38:36 -05:00
yindo closed this issue 2026-02-21 17:38:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1844