CompletedRAG · Retrieval Systems2-Stage Hybrid + Rerank
Ask My Paper — Local & Hybrid RAG Q&A Engine
PyMuPDF extracts page text, a recursive splitter chunks it, and every question runs BM25 and dense retrieval side by side. RRF fuses the two rankings, FlashRank reranks the fused pool, and the top six chunks are the only context the model answers from.
Interactive demo
Demo
Hybrid retrieval, step by step
BM25 and dense lists fuse with RRF (k=60), FlashRank reorders, and the answer cites its chunks.
Loading the demo…
Pipeline
- 01 · Ingestion
PyMuPDF + recursive splitter
PyMuPDF extracts page text; chunks are 1,000 characters with 200 overlap. Docling is a planned upgrade.
- 02 · Embedding & Indexing
nomic-embed-text + Qdrant Cloud
768-dimension Ollama embeddings stored in Qdrant Cloud with cosine distance.
- 03 · Hybrid Retrieval
BM25 + dense, fused with RRF
Top 25 from BM25 and top 25 dense results, fused with Reciprocal Rank Fusion at k=60.
- 04 · Reranking
FlashRank ms-marco-MiniLM-L-12-v2
FlashRank reranks the fused pool; the top 6 chunks go to the prompt.
- 05 · Grounded Answer
Llama 3 8B on Groq
Answers at temperature 0.2 from the top 6 chunks only.
Engineering decisions
- RRF merges BM25 and dense rankings without normalising their scores.
- Separated embedding generation (local via Ollama) from vector storage (Qdrant Cloud) and fast reasoning (Groq API) to optimize cost and latency.
- Inserted FlashRank second-stage reranking to suppress noisy top-k dense retrieval neighbors before prompt assembly.
Benchmarks
- PDF Ingestion
- PyMuPDF
- 1,000-character chunks with 200 overlap
- Retrieval Architecture
- BM25 + dense, RRF (k=60), FlashRank
- Top 25 per retriever, top 6 after reranking
- Embeddings & Inference
- Ollama + Groq API
- nomic-embed-text embeddings, Llama 3 8B answers
PythonPyMuPDFOllamaQdrantrank_bm25FlashRankGroq API