Knowledge retrieval bug #20942

Closed
opened 2026-02-21 20:09:53 -05:00 by yindo · 2 comments
Owner

Originally created by @ssvicnent on GitHub (Dec 10, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.7.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

In version 1.7.2, when performing knowledge retrieval, the same question is retrieved multiple times, and the recalled chunks differ each time, causing the score for the same chunk to fluctuate.

✔️ Expected Behavior

fix bug

Actual Behavior

In version 1.7.2, when performing knowledge retrieval, the same question is retrieved multiple times, and the recalled chunks differ each time, causing the score for the same chunk to fluctuate.

Originally created by @ssvicnent on GitHub (Dec 10, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.7.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce In version 1.7.2, when performing knowledge retrieval, the same question is retrieved multiple times, and the recalled chunks differ each time, causing the score for the same chunk to fluctuate. ### ✔️ Expected Behavior fix bug ### ❌ Actual Behavior In version 1.7.2, when performing knowledge retrieval, the same question is retrieved multiple times, and the recalled chunks differ each time, causing the score for the same chunk to fluctuate.
yindo added the 🐞 bug🌚 invalid labels 2026-02-21 20:09:53 -05:00
yindo closed this issue 2026-02-21 20:09:53 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 10, 2025):

Hi @ssvicnent! I'm Dosu and I’m helping the dify team.

This issue is caused by non-deterministic behavior in the knowledge retrieval pipeline, mainly due to the use of multithreading and parallel processing in both the retrieval and scoring logic. The code aggregates results from multiple threads and only sorts them by score at the end, so thread scheduling and concurrent writes can lead to different chunk orders and fluctuating scores for the same query. There is no explicit randomization, so this is a concurrency artifact rather than intentional randomness. Reranking and post-processing steps can also contribute to score instability depending on the model used.

Recent fixes have been merged after version 1.7.2 that address retrieval consistency and related bugs, especially around parent-child chunk checks and session handling. Upgrading to a version that includes PRs #29396 and #29426 should improve retrieval consistency and may resolve the issue you’re seeing (details, details).

If upgrading isn’t possible right now, you can try reducing the number of retrieval threads or checking your vector search backend for any non-deterministic behavior. Collecting debug logs during retrieval may also help pinpoint where the results diverge.

If you need more detailed guidance on configuration or debugging, feel free to share your environment details or relevant logs.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 10, 2025): <!-- Greeting --> Hi @ssvicnent! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This issue is caused by non-deterministic behavior in the knowledge retrieval pipeline, mainly due to the use of multithreading and parallel processing in both the retrieval and scoring logic. The code aggregates results from multiple threads and only sorts them by score at the end, so thread scheduling and concurrent writes can lead to different chunk orders and fluctuating scores for the same query. There is no explicit randomization, so this is a concurrency artifact rather than intentional randomness. Reranking and post-processing steps can also contribute to score instability depending on the model used. Recent fixes have been merged after version 1.7.2 that address retrieval consistency and related bugs, especially around parent-child chunk checks and session handling. Upgrading to a version that includes PRs #29396 and #29426 should improve retrieval consistency and may resolve the issue you’re seeing ([details](https://github.com/langgenius/dify/pull/29396), [details](https://github.com/langgenius/dify/pull/29426)). If upgrading isn’t possible right now, you can try reducing the number of retrieval threads or checking your vector search backend for any non-deterministic behavior. Collecting debug logs during retrieval may also help pinpoint where the results diverge. If you need more detailed guidance on configuration or debugging, feel free to share your environment details or relevant logs. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a8ba39ce-4bab-443b-9e25-3f534084af19?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20issue%20is%20caused%20by%20non-deterministic%20behavior%20in%20the%20knowledge%20retrieval%20pipeline%2C%20mainly%20due%20to%20the%20use%20of%20multithreading%20and%20parallel%20processing%20in%20both%20the%20retrieval%20and%20scoring%20logic.%20The%20code%20aggregates%20results%20from%20multiple%20threads%20and%20only%20sorts%20them%20by%20score%20at%20the%20end%2C%20so%20thread%20scheduling%20and%20concurrent%20writes%20can%20lead%20to%20different%20chunk%20orders%20and%20fluctuating%20scores%20for%20the%20same%20query.%20There%20is%20no%20explicit%20randomization%2C%20so%20this%20is%20a%20concurrency%20artifact%20rather%20than%20intentional%20randomness.%20Reranking%20and%20post-processing%20steps%20can%20also%20contribute%20to%20score%20instability%20depending%20on%20the%20model%20used.%0A%0ARecent%20fixes%20have%20been%20merged%20after%20version%201.7.2%20that%20address%20retrieval%20consistency%20and%20related%20bugs%2C%20especially%20around%20parent-child%20chunk%20checks%20and%20session%20handling.%20Upgrading%20to%20a%20version%20that%20includes%20PRs%20%2329396%20and%20%2329426%20should%20improve%20retrieval%20consistency%20and%20may%20resolve%20the%20issue%20you%E2%80%99re%20seeing%20%28%5Bdetails%5D%28https%3A//github.com/langgenius/dify/pull/29396%29%2C%20%5Bdetails%5D%28https%3A//github.com/langgenius/dify/pull/29426%29%29.%0A%0AIf%20upgrading%20isn%E2%80%99t%20possible%20right%20now%2C%20you%20can%20try%20reducing%20the%20number%20of%20retrieval%20threads%20or%20checking%20your%20vector%20search%20backend%20for%20any%20non-deterministic%20behavior.%20Collecting%20debug%20logs%20during%20retrieval%20may%20also%20help%20pinpoint%20where%20the%20results%20diverge.%0A%0AIf%20you%20need%20more%20detailed%20guidance%20on%20configuration%20or%20debugging%2C%20feel%20free%20to%20share%20your%20environment%20details%20or%20relevant%20logs.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/29443)
Author
Owner
@crazywoola commented on GitHub (Dec 10, 2025): https://github.com/langgenius/dify/blob/dbecba710b6ea82c9427da53edff971c013a4afa/CONTRIBUTING.md#L23-L33
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20942