I built a RAG application that retrieves relevant Bhagavad Gita verses for ethical dilemmas and generates structured guidance.
The problem: The Gita has 701 verses. Finding applicable wisdom for a specific situation requires either deep familiarity or hours of reading.
How it works:
1. User describes their ethical dilemma
2. Query is embedded using sentence-transformers
3. ChromaDB retrieves top-k semantically similar verses
4. LLM generates structured output: 3 options with tradeoffs, implementation steps, verse citations
Tech stack:
- Backend: FastAPI, PostgreSQL, Redis
- Vector DB: ChromaDB with all-MiniLM-L6-v2 embeddings
- LLM: Ollama (qwen2.5:3b) primary, Anthropic Claude fallback
- Frontend: React + TypeScript + Tailwind
Key design decisions:
- RAG to prevent hallucination — every recommendation cites actual verses
- Confidence scoring flags low-quality outputs for review
- Structured JSON output for consistent UX
- Local LLM option for privacy and zero API costs
What I learned:
- LLM JSON extraction is harder than expected. Built a three-layer fallback (direct parse → markdown block extraction → raw_decode scanning)
- Semantic search on religious texts works surprisingly well for ethical queries
- Smaller models (3B params) work fine when constrained by good prompts and retrieved context
GitHub: https://github.com/geetanjaliapp/geetanjali
Happy to discuss the RAG architecture or take feedback.