mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #8379] [MERGED] Fix the issue of inaccurate answers after enabling RAG query generation #45261
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
dev← Head:main📝 Commits (3)
506dc01Merge pull request #8246 from open-webui/dev1dfb479Merge pull request #8329 from open-webui/dev91f22a8Return 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 generationfeature was added starting from version v0.4.0.I saw that after enabling the
RAG query generationfeature, 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 functionis 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_resultsfunction 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.