[PR #8379] [MERGED] Fix the issue of inaccurate answers after enabling RAG query generation #37843

Closed
opened 2026-04-25 11:08:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/8379
Author: @qiaozhi199
Created: 1/7/2025
Status: Merged
Merged: 1/8/2025
Merged by: @tjbck

Base: devHead: main


📝 Commits (3)

  • 506dc01 Merge pull request #8246 from open-webui/dev
  • 1dfb479 Merge pull request #8329 from open-webui/dev
  • 91f22a8 Return the top k results with the highest similarity.

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/retrieval/utils.py (+1 -1)

📄 Description

I upgraded the Open-WebUI version from v0.3.35 to v0.4.7. I found that the RAG response quality is not as good as in version v0.3.35.
I also noticed that others have encountered similar issues: https://github.com/open-webui/open-webui/issues/7143

I read the source code of Open-WebUI and found that the RAG query generation feature was added starting from version v0.4.0.
I saw that after enabling the RAG query generation feature, the Ollama service is called to generate 1 to 3 queries, which are then used to query vectors.

For example, if 3 queries are generated and the top k is set to 6, there will be a total of 18 vector query results. However, the default sorting method of the merge_and_sort_query_results function is ascending order, so it will only return the 6 query results with the smallest distances, meaning the 6 results with the lowest vector similarity. This leads to inaccurate RAG responses.

Therefore, I believe the merge_and_sort_query_results function should use descending order sorting, so that it can return the top k vector query results with the highest similarity.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/8379 **Author:** [@qiaozhi199](https://github.com/qiaozhi199) **Created:** 1/7/2025 **Status:** ✅ Merged **Merged:** 1/8/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (3) - [`506dc01`](https://github.com/open-webui/open-webui/commit/506dc0149ca973e20768fa3d6f171afac289f606) Merge pull request #8246 from open-webui/dev - [`1dfb479`](https://github.com/open-webui/open-webui/commit/1dfb479d367e5f5902f051c823f9aef836e04791) Merge pull request #8329 from open-webui/dev - [`91f22a8`](https://github.com/open-webui/open-webui/commit/91f22a8a8d54399a7616ca69ce28846b74723056) Return the top k results with the highest similarity. ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/retrieval/utils.py` (+1 -1) </details> ### 📄 Description I upgraded the Open-WebUI version from v0.3.35 to v0.4.7. I found that the RAG response quality is not as good as in version v0.3.35. I also noticed that others have encountered similar issues: https://github.com/open-webui/open-webui/issues/7143 I read the source code of Open-WebUI and found that the `RAG query generation` feature was added starting from version v0.4.0. I saw that after enabling the `RAG query generation` feature, the Ollama service is called to generate 1 to 3 queries, which are then used to query vectors. For example, if 3 queries are generated and the top k is set to 6, there will be a total of 18 vector query results. However, the default sorting method of the `merge_and_sort_query_results function` is ascending order, so it will only return the 6 query results with the smallest distances, meaning the 6 results with the lowest vector similarity. This leads to inaccurate RAG responses. Therefore, I believe the `merge_and_sort_query_results` function should use descending order sorting, so that it can return the top k vector query results with the highest similarity. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 11:08:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#37843