arica.hu

arica.hu / Articles / Q&A

Production RAG Search Pipeline: Frequently Asked Questions

A practical guide to building robust retrieval pipelines using hybrid search, reranking, and context expansion.

By Zoltán Varga2026-11-055 min read

Short answerA production-grade RAG pipeline requires a hybrid search strategy combining dense semantic vectors with sparse lexical weights, followed by a cross-encoder reranker to refine results. This architecture balances speed and accuracy by using Reciprocal Rank Fusion to merge distinct scoring methods before expanding context around the top matches.

Which embedding model and dimension?

Selecting an embedding model depends on your specific needs for language support, latency, and licensing. BGE-M3 remains the only model providing native dense and sparse outputs in a single forward pass, making it ideal for hybrid search without extra infrastructure. It supports over 100 languages and operates efficiently on standard hardware with approximately 1 GB of memory usage.

Newer models like Qwen3-Embedding offer superior performance on multilingual benchmarks but lack native sparse vector generation. The 8B variant achieves top rankings in MTEB scores but requires significant GPU resources, while the 0.6B version offers a lightweight alternative with competitive English retrieval scores. These models utilize Matryoshka representations, allowing flexible dimension selection from 32 up to their maximum capacity.

Licensing constraints often dictate the final choice for commercial applications. NV-Embed-v2 holds the highest retrieval scores but carries a non-commercial license, restricting its use in paid products. BGE-M3 uses the MIT license, permitting unrestricted deployment. For teams prioritizing speed and simplicity, BGE-M3 provides a balanced starting point, whereas high-stakes environments might justify the complexity of dual-model architectures.

  • BGE-M3: Native dense + sparse, 100+ languages, MIT license, ~1 GB size.
  • Qwen3-8B: Top MTEB scores, 32K context, Apache 2.0, no sparse output.
  • Qwen3-0.6B: High efficiency, strong English scores, no sparse output.
  • NV-Embed-v2: Best retrieval metrics, non-commercial license only.

Do I need sparse vectors?

Sparse vectors capture exact keyword matches that dense semantic embeddings often miss. While dense vectors excel at understanding synonyms and conceptual relationships, they struggle with precise entity names, specific years, or unique technical terms. Sparse representations fill this gap by weighting individual tokens, ensuring that queries like 'Kahneman prospect theory 1979' retrieve the exact document rather than a semantically similar but chronologically incorrect one.

Only BGE-M3 currently generates both dense and sparse vectors simultaneously in a single encoding pass. Other high-performing models like Qwen3 or GTE produce dense vectors exclusively, requiring a separate sparse encoder like SPLADE-v3 if hybrid search is desired. This separation increases system complexity and latency, as two different models must process the same query sequentially.

The benefit of adding sparse vectors becomes critical in domains with strict factual requirements. Medical records, legal statutes, and financial reports often rely on exact terminology where semantic drift leads to errors. Combining dense and sparse signals through Reciprocal Rank Fusion creates a more robust retrieval system that handles both broad conceptual searches and precise fact-checking queries effectively.

  • Sparse vectors ensure exact matches for years, names, and specific terms.
  • Dense vectors handle synonyms and conceptual understanding better.
  • BGE-M3 is the only model offering native dual-output without extra steps.
  • Hybrid search reduces recall errors on out-of-domain data by 1-5 percentage points.

Is a reranker worth it?

A cross-encoder reranker significantly improves the precision of the final results by re-evaluating the relationship between the query and candidate documents. Initial retrieval stages prioritize speed, often returning 50 to 100 candidates that may include false positives. The reranker processes these pairs individually, calculating a more accurate relevance score before selecting the top few for the generator.

The BGE-reranker-v2-m3 model supports over 100 languages and handles inputs up to 8192 tokens. It runs efficiently on CPU hardware, taking approximately 200 to 500 milliseconds to process 50 chunks. This latency is acceptable in production environments where total pipeline time remains under one second, delivering a noticeable boost in answer quality compared to using raw retrieval scores alone.

Skipping the reranker simplifies the architecture but risks feeding irrelevant context to the large language model. This can lead to hallucinations or incomplete answers, especially when the initial search retrieves many loosely related documents. The computational cost of reranking is low relative to the value gained in response accuracy, making it a standard component in mature retrieval systems.

  • Rerankers re-score top candidates using a cross-encoder for higher precision.
  • BGE-reranker-v2-m3 supports 100+ languages and runs on CPU.
  • Latency impact is minimal, adding roughly 200-500ms to the pipeline.
  • Without reranking, the generator may receive noisy or irrelevant context.

How does the search flow work end to end?

The pipeline begins with encoding the user query into both dense and sparse vectors using the chosen embedding model. These vectors are sent to the vector database, which performs a hybrid search using Reciprocal Rank Fusion to merge the two result lists. This fusion method ranks documents based on their position in each list, avoiding the need to normalize different scoring scales.

The database returns the top 50 candidates, which are then passed to the reranker. The reranker computes a new relevance score for each pair of query and document text, sorting them by this refined metric. Only the top 10 results proceed to the next stage, ensuring that the most pertinent information reaches the final context assembly step.

Context expansion adds surrounding chunks to the selected documents to provide a complete narrative flow. The system retrieves the previous and next two chunks for each result, linking them via stored metadata. This expanded text block is then formatted and sent to the generative model, reducing the risk of missing crucial details due to arbitrary chunk boundaries.

  • Encode query to dense and sparse vectors.
  • Execute hybrid search with RRF fusion in the vector database.
  • Rerank top 50 candidates down to top 10 using a cross-encoder.
  • Expand context by fetching adjacent chunks before generation.

How do I evaluate retrieval?

Evaluation focuses on measuring how well the system retrieves relevant documents before the generation step occurs. Standard metrics include recall, which checks if all relevant documents were found, and precision, which measures the proportion of retrieved documents that are actually useful. These metrics help identify whether the embedding model or the search strategy needs adjustment.

Human evaluation remains essential for assessing the quality of the final answers generated from the retrieved context. Reviewers check if the system correctly cites sources and avoids hallucinations. Automated tests can simulate thousands of queries against a gold-standard dataset to track performance trends over time, ensuring that changes to the pipeline do not degrade retrieval quality.

Monitoring latency and resource usage is equally important for production readiness. A system that retrieves perfect results but takes ten seconds to respond is not viable for real-time applications. Balancing model size, hardware costs, and response time ensures the pipeline remains sustainable. Regular audits of the vector store also help detect data drift or indexing errors that could affect search accuracy.

  • Use recall and precision metrics to measure retrieval effectiveness.
  • Conduct human reviews to verify answer accuracy and source citation.
  • Track latency to ensure the pipeline meets real-time requirements.
  • Monitor resource usage to maintain cost-efficiency at scale.

Key takeaways

  • Hybrid search combining dense and sparse vectors handles both semantic understanding and exact keyword matching.
  • BGE-M3 is the only model offering native dual-output for hybrid search without additional encoders.
  • A cross-encoder reranker is essential for refining top candidates and improving final answer quality.
  • Context expansion by retrieving adjacent chunks prevents information loss at document boundaries.
  • Evaluation requires both automated metrics and human review to ensure reliability and accuracy.

Related questions

Can I use Qwen3 for hybrid search?

Qwen3 models do not generate sparse vectors natively. To achieve hybrid search with Qwen3, you must pair it with a separate sparse encoder like BGE-M3 or SPLADE-v3. This adds complexity and latency compared to using BGE-M3 alone, which provides both vector types in a single pass.

What is the total latency of this pipeline?

On standard CPU hardware, the full pipeline takes approximately 600 milliseconds to 1.1 seconds. This includes encoding, hybrid search, reranking 50 candidates, and context expansion. Using a GPU can reduce this time to roughly 100-200 milliseconds, depending on the specific hardware configuration.

Why use Reciprocal Rank Fusion instead of weighted sums?

Reciprocal Rank Fusion relies on document ranking positions rather than raw scores, eliminating the need to normalize different scoring scales. Dense vectors use cosine similarity while sparse vectors use BM25-like scores, which operate on different ranges. RRF provides a robust way to combine these distinct signals without complex calibration.

AI-assisted: drafted with a language model from the author's research notes, then edited and checked before publication. Author: Zoltán Varga, AI visibility researcher and AI ecosystem architect, Budapest.

More on arica.hu