Back to Home

Hybrid RAG without cloud: search in corporate documents

The article breaks down the architecture of hybrid RAG for corporate systems. The solution allows searching for information in heterogeneous documents without data leaks, keeping data within the company's perimeter. Components, processing stages, and tool selection are described in detail.

Hybrid RAG: document search without cloud and data leaks
Advertisement 728x90

# Hybrid RAG in Corporate Systems: Document Search Without the Cloud and Data Leaks

Large companies in regulated industries face a common problem: searching internal documents takes hours. A logistics manager, for example, wastes time digging through email, SharePoint, and archives to check the history of claims against a supplier. The culprit is the lack of intelligent search that grasps the meaning of a query, not just keywords. Hybrid RAG solves this by keeping data firmly within the company's perimeter.

Why Traditional Search Fails in Regulated Industries

Corporate archives are a mix of PDFs, scans, spreadsheets, and bilingual correspondence. Standard ECM systems and search engines struggle with heterogeneous data. A query like "Were there disputes over code 8471300000?" demands both semantic understanding and exact numeric matches. Standard RAG built on semantic search falls short when documents include tables, handwritten notes, or multilingual content. In banks, customs, and legal firms, data can't leave the perimeter—cloud solutions are off-limits due to architectural requirements.

Hybrid RAG combines two approaches:

Google AdInline article slot
  • Semantic search (dense vectors) for grasping meaning
  • Exact search (sparse vectors) for codes, SKUs, and numbers

This isn't just a mashup—it's a mathematically grounded fusion of results via Reciprocal Rank Fusion (RRF). The algorithm works without manual weight tuning or extra training and integrates seamlessly with vector databases like Qdrant.

Self-Hosted Hybrid RAG Architecture: From Document to Response

Query processing involves six stages, each critical for security and accuracy:

  • Document preprocessing — The Docling library normalizes scans to 300 DPI, extracts tables and structure. This is essential for the multimodal Qwen2.5-VL model, which handles handwritten notes and complex tables.
  • Dual embedding generation — The BAAI/bge-m3 model creates two vectors per chunk: dense (semantics) and sparse (exact matches). Using one model for indexing and queries ensures space compatibility.
  • Hybrid search in Qdrant — Simultaneous queries on dense and sparse vectors with automatic RRF fusion.
  • Preliminary reranking — FastEmbed narrows the list to 10 candidates in 30–50 ms.
  • Final rerank — The cross-encoder bge-reranker-v2-m3 assesses fragment relevance to the specific query. The self-hosted version adds 150–400 ms latency but keeps data in-house.
  • Response generation — The quantized Qwen2.5-72B-Instruct (AWQ INT4) model crafts the response from the filtered context.

The key feature: everything runs locally. Even reranking, which cloud services (like Voyage AI) speed up, is handled via self-hosted components to meet data sovereignty rules.

Google AdInline article slot

Production Tools: Why LangGraph and Haystack Are Essential

LangChain works for prototypes, but in regulated environments, two issues arise. First, no native state management: handling scenarios like "if rerank score is below threshold, rephrase the query" requires hacks. LangGraph fixes this with explicit graph nodes, crucial for production debugging.

Second, observability gaps. Without tracing, quality drops (from document updates or query pattern shifts) go unnoticed until user complaints. Self-hosted Langfuse tracks:

  • Retrieved fragments
  • Rerank scores
  • Stage-by-stage latency

Crucially, Langfuse runs inside the perimeter too—otherwise, corporate data leaks to third-party SaaS.

Google AdInline article slot

Haystack handles pre-production testing. Pipeline changes (like chunking strategies) let you run evaluations on a benchmark set and get metrics:

  • Search accuracy (how often the right document is in the top 5)
  • Response faithfulness to sources

This builds confidence that changes improve the system, not degrade it. LlamaIndex is flexible for prototyping but lags in built-in evaluation depth.

Infrastructure Optimization: From RTX 4090 to A100

Model choice depends on budget and quality needs:

  • Qwen2.5-72B-Instruct in AWQ INT4 — flagship option. Needs two A100 80GB GPUs, delivers top quality, especially with tables. Ideal for big law firms or banks.
  • Qwen2.5-32B-Instruct — sweet spot. Runs on one L40S 48GB (3x cheaper than A100), retaining 90% of 72B quality. Recommended starting point.
  • Qwen2.5-14B-Instruct — for tight resources. Fits on RTX 4090 but struggles with complex multi-step queries.

Pro tip: Start with 32B on L40S, test on real data, scale only if needed. AWQ INT4 quantization halves memory use without critical quality loss.

Key Takeaways

  • Hybrid RAG is essential for messy archives: it blends semantic search and exact matches via RRF.
  • Self-hosted architecture is non-negotiable for regulated sectors. Data stays in-perimeter at every step.
  • LangGraph and Haystack are production must-haves: the first manages real-time query logic, the second delivers objective quality checks.
  • Infrastructure costs are optimizable: Qwen2.5-32B on L40S matches 90% of flagship performance at one-third the cost.

The system responds in seconds, citing specific documents and pages, and admits data gaps instead of hallucinating. This isn't just better search—it's a shift from drudgery to intelligent knowledge access without security trade-offs.

— Editorial Team

Advertisement 728x90

Read Next