Repository navigation
feat(rag): enable MMR/BM25/relevance-floor + benchmark RLM refinement & reranker #10600
Copy link
Copy link
Closed
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or requestknowledgeKnowledge base systemKnowledge base systemnot-wiredImplemented but not connected to appImplemented but not connected to appoptimizationpriority: mediumrag
Description
Task 4 — RAG retrieval-quality flips & hybrid search
Theme: Precision. Several retrieval-quality features are fully built but disabled by default; the hybrid path uses naive substring matching instead of the existing BM25.
Problem
- MMR diversity disabled:
knowledge/search_components/reranking.py:49mmr_lambda=0.0; with reranking ON the crude_diversify_resultsis also skipped (advanced_rag_optimizer.py:799-800) → top-k can be near-duplicate chunks. - RLM adaptive query refinement off:
services/rag_config.py:92enable_rlm_refinement=False; full loop exists (advanced_rag_optimizer.py:945,rag_service.py:198-213) and refinement history is logged-then-discarded. - Hybrid keyword half uses substring TF, not BM25:
advanced_rag_optimizer.py:734-740loads all facts into memory per query and scores via_calculate_keyword_score(:365) — whileknowledge/search_components/bm25.pyexists unused. - No relevance floor on optimizer hybrid path:
advanced_rag_optimizer.py:648-715applies no min score; non-chat callers (cag_service.py:130,graph_rag_service.py:486) ingest low-relevance chunks. - Advanced-search feature flags never enabled:
knowledge/search.py:645-647enable_query_expansion/relevance_scoring/clusteringall default False; onlyenable_reranking=Trueis passed (services/knowledge/service.py:151). - Dated reranker:
services/rag_config.py:47pinscross-encoder/ms-marco-MiniLM-L-6-v2(2021).
Subtasks
- 4.1 Enable MMR diversity —
reranking.py:49,advanced_rag_optimizer.py:799- Step: set a sensible
mmr_lambdadefault; benchmark viaknowledge/rag_benchmarks.py
- Step: set a sensible
- 4.2 Replace substring keyword scan with BM25 index —
advanced_rag_optimizer.py:365,734-740,knowledge/search_components/bm25.py- Step: route hybrid keyword half through BM25; remove full-corpus in-memory scan
- 4.3 Add a uniform relevance floor to
advanced_search—advanced_rag_optimizer.py:648-715- Step: configurable
min_score; protects all callers
- Step: configurable
- 4.4 Enable advanced-search quality flags in chat retrieval —
services/knowledge/service.py:151- Step: pass
enable_query_expansion/enable_relevance_scoring(benchmark clustering separately)
- Step: pass
- 4.5 Benchmark + enable RLM refinement —
services/rag_config.py:92- Step: A/B via
rag_benchmarks.py; flip default only if recall improves without latency regression
- Step: A/B via
- 4.6 Benchmark a stronger reranker —
services/rag_config.py:47- Step: try
bge-reranker/ larger ms-marco; config-only swap; keep if precision lifts
- Step: try
- 4.7 Surface reranker-active metric —
reranking.py:383-440- Step: emit health signal when reranking silently falls back (no
sentence_transformers)
- Step: emit health signal when reranking silently falls back (no
Verification
- Run
knowledge/rag_benchmarks.pybefore/after each flip; record precision/recall deltas in the issue - Confirm no latency regression on chat retrieval
Notes
Every flip is config-gated and benchmarked — no blind enabling. Reuse existing BM25/MMR/reranker code; do not reimplement.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestknowledgeKnowledge base systemKnowledge base systemnot-wiredImplemented but not connected to appImplemented but not connected to appoptimizationpriority: mediumrag
Activity
mrveiss commentedon Jun 28, 2026
Part of umbrella #10603 (AutoBot Efficiency & Precision).
mrveiss commentedon Jun 29, 2026
Decision doc — RAG quality flips (blocked on a missing eval, needs your call)
These flips can't follow the issue's "benchmark then flip" plan as written, because
knowledge/rag_benchmarks.pyis a performance-timing harness (vector-similarity speed, top-k latency, chunking throughput) — not a precision/recall quality eval. There is no labeled-query quality benchmark in the repo, so retrieval-quality changes can't be measured objectively today.The flips, by risk
rag_config.py:51 mmr_lambda(0.0=off)advanced_rag_optimizer.advanced_search(no min)knowledge/search.pyflags (default False)search_components/bm25.py(built, unused)rag_config.py:92 enable_rlm_refinement=Falserag_config.py:47 reranking_modelYour decision (pick one)
I can implement B immediately (config-gated PRs) if you approve — no eval needed for those three. The rest stay tracked here pending the eval decision.
feat(rag): relevance floor (min_score) for advanced_search (#10703) (#…
feat(rag): enable MMR + BM25 hybrid + relevance-floor behind config f…
mrveiss commentedon Jul 6, 2026
Delivered via PR #10985 — MMR + BM25 hybrid + relevance-floor wired into the optimizer chat retrieval path behind config flags (all default OFF, no blind flips); reranker health metric added. 42 tests.