The Mahabharata Guide
Ask a question about the Mahabharata and get an answer written only from the real text, with every citation traced back to the passages it came from. It is built on Kisari Mohan Ganguli's English translation, not a model reciting the epic from memory.
Why it's interesting: citations are built in code from the passage numbers the model reports, so an answer can never cite a passage that wasn't retrieved. If an answer has no valid citation, the app says "the text doesn't cover this" instead of showing it.
To try it: the app is bring-your-own-key. Paste an OpenAI, Anthropic or Gemini key when you ask your first question. The key stays in your browser tab and is never stored on the server. The first request may be slow while the free-tier backend wakes up.
- React + TypeScript
- FastAPI
- BM25 + pgvector
- Supabase
- Reciprocal Rank Fusion
- Kiro specs
How it works
- Classify. An LLM labels each question factual, philosophical or ambiguous, with a confidence score. Low confidence is downgraded to ambiguous, and ambiguous questions get two short readings side by side, each cited.
- Retrieve. Hybrid search over 5,578 passages from all 18 parvas: BM25 keyword search plus vector similarity (pgvector), merged with Reciprocal Rank Fusion because the two scores aren't on the same scale. A failed search retries with period vocabulary ("siblings" becomes "brothers and sisters").
- Answer. The model writes only from the retrieved passages. Guardrails handle off-topic questions and prompt-injection attempts.
Product decisions I made
- Cut scope to Q&A. A story-telling mode was specced, then removed to keep v1 focused on one thing done well.
- Changed the architecture after measuring. Self-hosted embedding and re-ranking models needed about 703MB of memory against a 512MB free-tier limit. I moved to an external embeddings API plus pgvector instead of cutting hybrid search or paying for a bigger host. Re-ranking is deferred to v2.
- Chose embeddings on cost and limits. Gemini's free tier would have taken about 6 days to embed the corpus. OpenAI's embeddings cost about $0.07 for all of it.
- Asked for the API key late. The key prompt appears at the first question, not up front, so visitors see value before being asked for a paid key.
- Tested the classifier against real questions. A hand-labeled eval set, and I relabeled rows after live-testing when the model's reading was the more defensible one.
What's next
Add a re-ranker once there's a hosting decision for it, run the labeled eval set across all three providers, and tackle modern-dilemma questions (for example, "should I buy more plants?") that need their own validated classifier.