Aditya Dutt Pandey

Builder · Live on a free-tier host · public · 2026

Speculative RAG

A voice and text question-answering system over MSMARCO-XI for Hindi, English, Tamil and Urdu. Its hot path retrieves with BM25 and returns an extractive answer without calling a hosted LLM. The target is under 200 ms after transcription; production measurements are around 25 ms when the app and Qdrant share a region.

Hot-path target
under 200 msfrom transcript to extractive answer; speech-to-text excluded
Measured production answer step
about 25 msafter speech-to-text, with Render and Qdrant in the same region
Host memory
512 MBfree-tier instance; separate from the latency target
Retrieval P95
13.67 mslatest reported measurement
Measured answer quality
92.31% faithfullatest 100-query report; correctness 57.14%, false confidence 34%

Answer now, check in the background

The hot path checks unsafe input, retrieves sparse BM25 results from Qdrant, checks for off-topic questions and selects an extractive answer. No hosted model runs there. Production measurements put the answer step in the tens of milliseconds after speech-to-text, with the app and Qdrant in the same region. The under-200-ms figure is the target, not a guarantee; speech-to-text is timed separately.

If the answer doesn't hold up, an async recovery chain checks groundedness, then uses Speculative RAG: it clusters passages, drafts answers in parallel with a smaller model and scores them with a larger verifier. Multi-passage synthesis is the final fallback. Recovery runs outside the SLA and can replace the answer the UI already showed.

The draft ranking multiplies draft confidence by verifier support. I can't use the paper's self-consistency score because the chat API doesn't return prompt log-probabilities. The ranking is a fallback signal, not calibrated confidence.

Constraints that shaped it

BM25 is sparse term-frequency search, not dense semantic retrieval. Keeping dense models out of the deployed process lets the web app fit a free-tier 512 MB host. Speech recognition uses Sarvam and runs before the hot-path clock starts.

The fast answer is intentionally extractive: it can only return text found in a retrieved passage, so multi-hop questions and answers that need rephrasing can miss until recovery finishes. Recovery also costs LLM calls on every groundedness check, whether or not the fast answer is kept.

Python · FastAPI · Qdrant · BM25 · Sarvam STT · OpenAI

← All work