Home/Work/End-to-end retrieval pipeline

Case study · Real Brokerage · Real estate · 2025

End-to-end RAG pipeline

A precise retrieval-augmented generation system: intent routing, semantic chunking, embedding generation, and hybrid vector + keyword retrieval, fused into context-optimised prompts that drive LLM reasoning and structured output across multiple sources.

80K+PDFs a day served downstream
2Retrieval modes, dense and keyword
6Steps, routed query to answer
2025Designed, built, in production

§ 01 — Problem

Naive RAG retrieves plausible-but-wrong context. Chunks are cut at the wrong boundaries, so a passage arrives without the sentence that qualifies it. A single search mode misses what the other would have caught: dense retrieval blurs exact terms such as clause numbers and addresses, keyword search misses paraphrase. And prompts are stuffed past the model's attention budget, so the right passage is in the context and the model still reasons over the wrong one.

The requirement was a system that decides whether to retrieve at all, retrieves from the right sources, and hands the model only the evidence that fits, so that answers over a heterogeneous document corpus come back grounded and in a fixed structure.

§ 02 — Architecture

Route, chunk, retrieve twice, fuse.

Retrieval is a pipeline of narrow stages in front of the LLM, each with one job, and two indexes built from the same semantic chunks.

Fig. 1System architecture
Documents are chunked semantically and indexed twice, as embeddings in a vector store and as terms in a keyword index. A query is routed first: the router decides whether to retrieve and from which sources. Dense and keyword retrieval run together, the fused candidates are reranked, and the context optimiser packs multi-source evidence into a prompt that fits the model's budget. The LLM reasons over that context and returns a structured answer with its sources and a confidence.

§ 03 — How it works

One question, grounded.

The animation follows a single question through routing, chunking, hybrid retrieval, reranking, context assembly and the grounded answer.

Fig. 2Pipeline trace (live illustration)
The question, chunk identifiers, scores and token counts in the trace are sample values, not client data.
FilmCase film, 24 seconds
1280 × 720 · H.264 · no audioDownload MP4

Diagrams and films on this page are illustrations of the system's architecture and behaviour, drawn from my work at Real Brokerage. They are not screenshots or recordings of production systems, which remain confidential.

§ 04 — Approach

Retrieval

  • Intent routing decides whether to retrieve at all and, when it does, which sources to search.
  • Semantic chunking splits documents on meaning, so each passage stays coherent instead of breaking at a fixed length.
  • Embedding generation indexes every chunk in a vector store; a keyword index holds the exact terms.
  • Hybrid dense + keyword retrieval, with reranking to order the candidates by relevance to the question.

Generation

  • Context optimisation fuses evidence from multiple sources and packs it within the model's attention budget before the LLM reasons over it.
  • Structured output: the answer, its sources and a confidence come back in a fixed schema, so every claim can be traced to a chunk.
  • Built to answer across heterogeneous document corpora rather than one clean collection.
  • Serves as the retrieval backbone for the document-intelligence platform and its 80K+ PDFs a day.

§ 05 — Impact

Grounded, structured answers over heterogeneous document corpora. Each answer carries its sources and a confidence, so a reader can check the passage it rests on. The pipeline is the retrieval backbone for the document-intelligence platform, serving its more than 80,000 PDFs a day.

What generalises: routing before retrieval spares the model context it never needed; chunk boundaries matter as much as the embedding model; and two retrieval modes with a reranker in front of a strict context budget are what make the answer precise.

Intent routingSemantic chunkingEmbeddingsHybrid retrievalVector storeKeyword searchRerankingContext optimisationStructured output

§ 06 — At a glance

A one-page summary of this case for sharing. PNG, 1080 × 1350.

Download PNG
At-a-glance infographic for the retrieval pipeline