/ DUTY & ACTION/ CLARITY OF MIND/ EVERYDAY LIFE

Bring a real situation.
Discover a perspective from
the Bhagavad Gita.

700 verses. One grounded answer.

Bhagavad
Gita.

Scroll to explore the dialogue

Wisdom for your moment

A question from your life.
A response grounded in
cited verses.

Pause.
Find a
perspective.

Describe what you are facing. Explore a practical reflection alongside the original Sanskrit and its English translation.

01

Begin with your situationWork, attention, anger, or a difficult decision.

02

Find supporting versesSearch all 700 verses of the Gita.

03

Reflect with contextRead the response alongside its cited sources.

Generate a grounded answer

0 / 2000

Try an example

⌘/Ctrl + Enter to ask

Grounded reflection

Reflection

Original Sanskrit

Transliteration

English translation

Citation grounding

Cited verses

Claim support

Latency for this response

Query generation
Retrieval
Reranking
Selection
Final answer generation
Total pipeline
How this answer was found

Queries sent to retrieval


            

RRF fused candidates


            

Claude evidence ranking


            

Selected grounding verses


            
700

Verses cached locally

Every Bhagavad Gita verse keeps its translation, metadata, and precomputed vector ready in memory for fast search.

4

Retrieval facets generated

Claude generates four focused facets. The original question and deterministic Gita-specific expansions are searched as well.

20

Candidates reranked

Claude ranks up to 20 fused candidates against the natural question and returns the six strongest evidence candidates.

How each answer is grounded

Every stage of the RAG pipeline

The production path combines Amazon Bedrock, a local vector cache, deterministic retrieval controls, RRF fusion, and Claude evidence reranking. Each stage does one narrow job well, from translating the question into search concepts to validating the final evidence-backed answer.

Corpus preparation

The preparation job validates and enriches 700 verse records, then persists translations, metadata, themes, and embeddings for retrieval.

load_records() enrich() validate()

Query intelligence

Claude Sonnet creates four retrieval facets, including ideal evidence, while a controlled domain map adds Gita-specific concepts and synonyms.

generate_search_queries() expand_domain_concepts() Claude Sonnet 4.6 (default)

Hybrid retrieval

Titan semantic search and BM25 lexical search run across the local 700-verse cache for the original question, generated facets, and deterministic domain expansions.

retrieve_candidates() Amazon Titan Text Embeddings V2 local_vector_search.py

Rank fusion

Reciprocal Rank Fusion merges results from every search, rewards repeated evidence, removes duplicate verses, and keeps the top 20 candidates.

RRF_CONSTANT = 60 RESULTS_PER_QUERY = 10 MAX_RERANK_CANDIDATES = 20

Evidence reranking

Claude ranks up to 20 fused candidates against the natural question, prioritizing direct doctrinal evidence over keyword overlap.

rerank_and_select() doctrinal entailment Claude Sonnet 4.6 (default)

Grounding selection

The validated ranking defines the eligible evidence. Final generation may cite one to three passages, but only from those selected sources.

ranked_verse_ids[:2] validate_ranking() cited grounding

Grounded generation

A final Bedrock call receives the question and selected verse context. If the selected evidence is weak, the app shows the closest verse as context instead of forcing a confident answer.

build_context() generate_passage_message() faithfulness guardrails Claude Sonnet 4.6 (default)

Evaluation harness

A 25-question regression set checks whether natural questions land on acceptable verses, so improvements can be tested instead of guessed.

eval/rag_eval_cases.json evaluate_rag.py selected verse accuracy

Orchestration and API

The final orchestration composes the grounded answer and exposes it through a validated FastAPI endpoint for the web experience and API consumers.

answer_question() create_answer() trace evidence strength
Build journey

How a 700-verse experiment became production RAG

The first version could retrieve a verse and generate a reflection. That was enough for a demo, but it was not enough to trust. The work since then has been about finding where the pipeline failed and replacing each weak link with something measurable.

  1. The beginning

    One question in, one plausible verse out

    I started by indexing all 700 Bhagavad Gita verses with Amazon Titan embeddings and using Bedrock to turn a life situation into a response. The system worked, but semantic similarity alone often returned verses that sounded related without directly answering the question.

  2. The retrieval problem

    Broader search without losing precision

    I added four intent facets, deterministic Gita vocabulary, BM25 lexical search, and Reciprocal Rank Fusion. The pipeline now searches the original question and several controlled interpretations, then rewards verses that appear consistently across retrieval methods.

  3. The BGE phase

    Better ranking, with the wrong production cost

    BAAI/bge-reranker-v2-m3 was introduced as a local cross-encoder to compare the strongest candidates. Relevance improved, but model startup, image size, memory use, and latency made it a poor fit for this deployment. Reducing the number of comparisons helped, but did not solve the underlying trade-off.

  4. The replacement

    Ranking evidence instead of matching words

    BGE was removed and replaced with Claude evidence reranking. Claude now ranks six candidates by whether a verse directly supports the user’s situation, records evidence as strong, partial, or none, and limits final generation to the validated passages.

  5. The trust layer

    Make every answer inspectable

    The response now exposes cited verses, claim-level support, missing context, pipeline timings, generated queries, RRF candidates, and the final evidence ranking. When support is weak, the system says so and presents the closest passage instead of manufacturing certainty.

  6. Today

    A deployed and continuously evaluated system

    The production path runs from GitHub Actions to Docker, ECR, and EKS. After each successful deployment, the workflow executes a five-case smoke test followed by the full 25-case regression suite inside the running container. The result is a RAG system whose retrieval, grounding, latency, and failures can all be examined.

    700 versesHybrid retrievalEvidence-rankedCitation-grounded25-case regression