Urgent.News

What's breaking now, across thousands of outlets.

Tech

Stop Choosing Between BM25 and Vector Search: Implement Hybrid Search with RRF

Combine dense embeddings and sparse keyword search using Reciprocal Rank Fusion to eliminate retrieval failure modes in production RAG systems. The Bottleneck in Production Most production RAG pipelines start with pure vector search. It works reliably during initial demos, but fails quietly once users begin searching for exact product IDs, error codes, or domain-specific identifiers. Vector…

Most production RAG pipelines start with pure vector search. However, this method fails to deliver accurate results when users search for exact product IDs, error codes, or domain-specific identifiers. Vector search translates text into semantic coordinate spaces. It tends to blur fine-grained details, so a search for error code ERR-502-BAD-GATEWAY may retrieve general network troubleshooting documentation instead of the specific runbook for error 502.

Relying solely on keyword search (BM25) also breaks down when users paraphrase queries, as a query like "reduce database memory footprint" will fail to find an article titled "Mitigating PostgreSQL RAM Saturation" if there is no direct keyword overlap.

The key issue is that relying on a single retrieval strategy introduces hard blind spots that degrade the quality of downstream LLM generation. To address this, concurrent hybrid search using Reciprocal Rank Fusion (RRF) can be implemented. This approach involves running sparse (BM25) and dense (vector) searches concurrently and merging their ranked outputs using RRF.

The algorithm avoids the challenge of score normalization by scoring documents based on their relative rank position across both search lists, rather than comparing raw scores directly.

The implementation of this hybrid search involves a few key steps. First, perform sparse BM25 scoring and ranking using the 'rank_bm25' library. Next, perform dense vector scoring and ranking using the 'sentence_transformers' library and cosine similarity. Finally, apply Reciprocal Rank Fusion by merging the ranked outputs from both search strategies.

The RRF scoring formula sums the reciprocal of the sum of a smoothing constant (k) and the rank position of each document in both retrieval systems. By using this method, the implementation guarantees resilience and ensures that exact keyword matches are prioritized when available, while still providing accurate results for paraphrased queries.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Sweating the Details Matter: Flask, port 5000, localhost, Safari and macOS

Pop quiz : Suppose you are developing a Flask app. Flask uses port 5000 as its default port. Now suppose that you have your Flask app running on macOS on port 5000.

  • Flask app runs on port 5000, causing potential conflicts with AirPlay
  • macOS resolves localhost to IPv6 address ::1, not 127.0.0.1
  • Access Flask app using http://127.0.0.1:5000, not localhost

New York City 911 System Missed 1,700 Calls Due To Software Update

Longtime Slashdot reader belmolis writes: Part of New York City's 911 emergency system was offline from about 3:13 a.m. to 10 a.m. on August 18th due to a software update, according to Medical Daily.

  • Software update caused 1,700 unanswered 911 calls in NYC on August 18th
  • Calls made to Bronx center, 400 direct callers didn't receive help
  • NYC didn't inform public, disclosed info upon journalist request

More from Friday 28 August →