Member-only story
Building a RAG Pipeline for 10M+ Documents With Near-Zero Hallucination
Retrieve, constrain, verify, abstain
Read this story for free: link
The more documents you put into a RAG system, the more ways it has to make things up, and as the corpus grows into the millions, toward 10M and beyond, that hallucination problem only gets worse. To keep answers trustworthy at that scale, you need a pipeline where the agent checks its own evidence and cites every claim it makes, the same idea behind the citations that Claude uses.
Here is everything the pipeline contains, and we build it top to bottom, one component at a time:
- Set up and get the data: download the corpus, inspect its size and a real sample, and fix every seed so the run is reproducible.
- Clean and chunk: normalize the text, drop near-duplicates with MinHash LSH, and cut it into structure-aware chunks with a one-line context prefix.
- Build a hybrid index: store every chunk as a dense vector in LanceDB and a sparse BM25 posting, on disk so it scales to 10M+ vectors.
- Retrieve and rerank: fuse the dense and sparse rankings with reciprocal rank fusion, then rerank 150 candidates down to 20.
- Route and decompose: classify each question and split…










