Should the top_k in the retrieval stage be greater than the top_n in the reranking stage? For example, top_k=10, top_n=3 #4012

Closed
opened 2026-02-21 18:04:24 -05:00 by yindo · 3 comments
Owner

Originally created by @zzzmc on GitHub (Jun 7, 2024).

Originally assigned to: @JohnJyong, @VincePotato on GitHub.

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).
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing?

I am using the embedding and rerank models, but the top_k parameter of dify is only valid for the final rerank stage(the retrieval and rerank stages are set to the same top_k). Should the top_k in the retrieval stage be greater than the top_n in the reranking stage? For example, top_k=10, top_n=3

2. Describe the feature you'd like to see

On the web interface, users can not only set top_k, but also set top_n if they choose rerank model.top_k parameter can be set in embedding stage and top_n parameter can be set in rerank stage for better results in Two-Stage Retrieval

3. How will this feature improve your workflow or experience?

The setting of the Two-Stage Retrieval is more flexible, and the final search results should be improved

4. Additional context or comments

Related isuue or discussions: https://github.com/langgenius/dify/discussions/3772#discussion-6552887 https://github.com/langgenius/dify/discussions/3171#discussion-6478239

5. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @zzzmc on GitHub (Jun 7, 2024). Originally assigned to: @JohnJyong, @VincePotato on GitHub. ### 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] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? I am using the embedding and rerank models, but the top_k parameter of dify is only valid for the final rerank stage(the retrieval and rerank stages are set to the same top_k). Should the top_k in the retrieval stage be greater than the top_n in the reranking stage? For example, top_k=10, top_n=3 ### 2. Describe the feature you'd like to see On the web interface, users can not only set top_k, but also set top_n if they choose rerank model.top_k parameter can be set in embedding stage and top_n parameter can be set in rerank stage for better results in Two-Stage Retrieval ### 3. How will this feature improve your workflow or experience? The setting of the Two-Stage Retrieval is more flexible, and the final search results should be improved ### 4. Additional context or comments Related isuue or discussions: https://github.com/langgenius/dify/discussions/3772#discussion-6552887 https://github.com/langgenius/dify/discussions/3171#discussion-6478239 ### 5. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo closed this issue 2026-02-21 18:04:24 -05:00
Author
Owner

@JohnJyong commented on GitHub (Jul 1, 2024):

will be considered, thanks for your suggestion

@JohnJyong commented on GitHub (Jul 1, 2024): will be considered, thanks for your suggestion
Author
Owner

@JohnJyong commented on GitHub (Jul 1, 2024):

@VincePotato

@JohnJyong commented on GitHub (Jul 1, 2024): @VincePotato
Author
Owner

@VincePotato commented on GitHub (Jul 1, 2024):

We are planing to set separate TopK for the Retrieval and Rerank stages. Really appreciate your suggestion!

@VincePotato commented on GitHub (Jul 1, 2024): We are planing to set separate TopK for the Retrieval and Rerank stages. Really appreciate your suggestion!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4012