mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
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/18210
Author: @lokiee0
Created: 10/10/2025
Status: ❌ Closed
Base:
main← Head:fix-top-k-multiple-knowledge-bases-issue-17706📝 Commits (7)
5f584abAdd setup documentation and configuration files66e1360Fix memory leak and NUL character issues in web search924c849Add comprehensive pull request template for web search fix31fe01cAdd CLA text to pull request templatea201d43Fix embedding and reranker models not working after JSON config importfc39191Add PR template with CLA text for embedding config fix1becb0eFix Top-K results with multiple knowledge bases (Issue #17706)📊 Changes
22 files changed (+2348 additions, -564 deletions)
View changed files
➕
EMBEDDING_CONFIG_PR_TEMPLATE.md(+95 -0)➕
FIX_EMBEDDING_CONFIG_IMPORT.md(+144 -0)➕
FIX_MEMORY_LEAK_AND_NUL_CHARS.md(+57 -0)➕
FIX_TOP_K_MULTIPLE_KNOWLEDGE_BASES.md(+169 -0)➕
PULL_REQUEST_TEMPLATE.md(+91 -0)➕
SETUP_STATUS.md(+125 -0)➕
TOP_K_PR_TEMPLATE.md(+118 -0)📝
backend/open_webui/retrieval/utils.py(+11 -3)📝
backend/open_webui/retrieval/vector/dbs/pgvector.py(+6 -2)📝
backend/open_webui/retrieval/vector/utils.py(+30 -3)📝
backend/open_webui/routers/configs.py(+99 -1)📝
backend/open_webui/routers/retrieval.py(+49 -22)➕
fix_embedding_config_import.py(+137 -0)➕
fix_top_k_multiple_knowledge_bases.py(+239 -0)➕
litellm_config.yaml(+23 -0)📝
package-lock.json(+113 -533)📝
package.json(+1 -0)➕
test_backend.py(+95 -0)➕
test_embedding_config_fix.py(+204 -0)➕
test_top_k_fix.py(+222 -0)...and 2 more files
📄 Description
Fix: Too Many Results When Using Multiple Knowledge Bases
🐛 Issue Description
Fixes issue #17706: When using multiple knowledge bases with a model, the system returns Top-K results per knowledge base instead of Top-K results total.
Related Issue: #17706
🔧 Root Cause Analysis
query_collection()queries each KB with Top-K limit✅ Solution Implemented
1. Expanded Query Limits
backend/open_webui/retrieval/utils.pyquery_collection()to use expanded K limit for initial queriesquery_collection_with_hybrid_search()for hybrid search scenariosexpanded_k = min(k * num_collections, k * 10)to get sufficient candidates2. Smart Expansion Logic
3. Hybrid Search Support
kandk_rerankerparameters📊 Performance Impact
Performance Notes:
🧪 Testing
Comprehensive Test Suite
test_top_k_fix.pyValidation Results