ActualBuild Start a project

Work / Case study 03

Prod RAG

Question answering over 25,000+ pages that people actually used, because retrieval was measured, not guessed.

Type
Internship · Generative AI Engineer, Algo Mighty Technology
Scope
Ingestion, retrieval, reranking, evaluation, caching, API · plus voice agents
Stack
Python · FastAPI · LangChain · Qdrant · Redis
Usage
40+ users · 300+ queries a day
Hybrid search finds the answer at rank 4; the cross-encoder moves it to rank 1. Recall@5 82%, MRR 0.76, latency 5.2s to 2.8s.

01 — The problem

A demo RAG is easy. One people use every day isn't.

The client had 1,000+ documents, 25,000+ pages, and people asking questions about them all day. The basic recipe (chunk, embed, take the top few) breaks in predictable ways once real users show up:

  1. Exact terms get lost. Embeddings are good at meaning and bad at names, codes and identifiers, which is exactly what people search for.
  2. The right chunk is found, just not on top. The model only reads the first few results, so rank 7 might as well not exist.
  3. 5.2 seconds is too long. Slow answers are how internal tools quietly stop being used.

And underneath all three: "it feels better" isn't a metric. Without evaluation, every change is a guess.

02 — The approach

Search first, then write.

Most of a RAG system's quality is decided before the LLM sees anything. So the pipeline is built like a search engine: narrow, retrieve two ways, rerank properly, and only then hand the best few chunks to the model. Watch one question travel:

Query path: user question, Redis cache, metadata filters, hybrid BM25 and dense retrieval on Qdrant, cross-encoder rerank, LLM, answer; ingestion and the search index as supporting pieces.FastAPI serviceQuestionfrom the appRedis cacherepeat? skip workFiltersmetadata narrowsHybrid searchBM25 + QdrantRerankcross-encoderLLManswer from top-kAnswerwith sourcesSearch indexBM25 + vectorsIngestionsemantic chunks123456
Query pathGrey lines: indexing & cache hits
  1. 1
    Cache first

    Redis answers repeated questions without running the pipeline at all.

  2. 2
    Filter early

    Metadata filters shrink the search space before ranking, so retrieval is faster and more precise.

  3. 3
    Retrieve two ways

    BM25 catches exact terms, dense vectors on Qdrant catch paraphrases. Results are merged.

  4. 4
    Rerank properly

    A cross-encoder reads each question–chunk pair together and reorders the candidates.

  5. 5
    Write from the best

    Only the top chunks reach the LLM, so its context is small and relevant.

  6. 6
    Index that makes sense

    Ingestion splits 25,000+ pages along document structure, so each chunk is one coherent idea.

03 — Decisions in numbers

82% Recall@5
For most questions, the right chunk is in the top five the model actually reads.
0.76 MRR
The right chunk usually sits at or near the very top, not just somewhere in the list.
+15%
Retrieval relevance gained from hybrid search and reranking, measured on our own evaluation set.
5.2s → 2.8s
Response latency after Redis caching, metadata filtering and query optimization.

04 — How it was measured

The most useful thing I built wasn't a retrieval trick.

It was the evaluation framework: a set of real questions, each mapped to the chunks that actually answer it. Every retrieval change was scored on two numbers before it shipped.

  • Recall@5 asks: is the answer anywhere in the top five?
  • MRR asks: how close to the top is it?
  • Rule: a change only shipped if the numbers went up. That's why "+15%" is a measurement, not a vibe.

05 — What broke, and the fix

Lost exact terms

Symptom Questions with specific names or codes pulled in loosely related text.

Cause Dense embeddings blur exact tokens.

Fix Hybrid search: BM25 alongside vectors on Qdrant.

Right chunk, wrong rank

Symptom The answer was retrieved but sat too low for the model to use.

Cause Embedding similarity is a rough ranker.

Fix Cross-encoder reranking over the merged candidates.

Slow answers

Symptom 5.2 seconds per question.

Cause Every query ran the full pipeline over the whole corpus.

Fix Redis caching, metadata filters and query optimization. 2.8 seconds.

06 — Honest gaps & what's next

  • 2.8 seconds is better, not fast. Streaming tokens to the UI would make it feel instant. Caching only helps repeated questions.
  • The eval set was ours. Logging real queries with user feedback would keep it honest over time.
  • Retrieval was measured, answers weren't. Next: groundedness checks, so every claim in an answer points to a retrieved chunk.
  • Also built. Voice and chat agents (speech-to-text → LLM → text-to-speech) that automated parts of client communication.
Next case study Kafka CDC at PolicyBazaar: from 3-hour batches to 10–15 minute freshness →

Building on your own documents?

I've shipped RAG that people used every day, with the numbers to back it. Happy to look at yours.

Get in touch