mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
[GH-ISSUE #8579] feat: Optimize BM25 Retriever Creation in Hybrid Search for RAG #85920
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?
Originally created by @BobMiles on GitHub (Jan 15, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/8579
Feature Request
Is your feature request related to a problem? Please describe.
When using RAG with hybrid search enabled, the performance is significantly degraded when using larger knowledgebases, especially with multiple collections.
We suspect the issue lies in the way the BM25 Retriever is created for each collection.
Specifically:
4269df041f/backend/open_webui/retrieval/utils.py (L218))4269df041f/backend/open_webui/retrieval/utils.py (L93))From our experience in other RAG applications, the BM25 Retriever generation can be costly.
Describe the solution you'd like
We propose the following optimization to address the performance issue:
Cache the BM25 Retriever
Generate the BM25 Retriever once when a knowledge collection is created, updated, or modified.
Cache the retriever using a hash key derived from the knowledge collection’s state (e.g., metadata, content hash).
Reuse the cached retriever for subsequent queries until the collection changes.
On-Demand Caching
As an alternative, create the BM25 Retriever during the first query execution for a collection and cache it for reuse. Discard the retriever when it becomes invalid due to collection updates.
Describe alternatives you've considered
Disabling hybrid retrieval immediately improves RAG performance. However, the retrieval quality without hybrid search is significantly worse and unsuitable for our use case.
Additional context
Test Setup