All tools
Open source India-first

smriti

Ask the Ramayana and Mahabharata a question, answered on your phone.

  • React Native
  • llama.rn
  • Gemma GGUF

01 · What it does

The problem it solves

A React Native app that downloads a Gemma GGUF model to the device and runs it locally, so questions are answered on the phone rather than by a cloud API. Each question is matched against a bundled corpus of 1,014 episode records segmented from public-domain English translations — 492 from Griffith’s Valmiki Ramayana, 522 from Ganguli’s Mahabharata — and the top matches are injected into the prompt. A refusal layer then screens every reply for prescriptive advice, character breaks, and Devanagari that is not a verbatim quote, regenerating once before falling back to a neutral line.

Who it's for

React Native developers who want a working example of on-device LLM inference combined with retrieval and output filtering, plus anyone curious to explore the epics conversationally without sending questions to a server. It assumes comfort with Expo development builds — there is no store listing.

02 · Setup

Before you start

  • Node.js 22 (both CI workflows pin it)
  • An Expo account and the EAS CLI (10.0.0 or newer)
  • A physical device or emulator — llama.rn is a native module, so Expo Go will not work
  • Roughly 2.4 GB free storage on the device for the model
  • Network access on first launch to fetch the GGUF file

Clone

git clone https://github.com/ca-who-codes/smriti.git && cd smriti

Install

npm install

Build a dev client

npx eas build -p android --profile development

03 · Step by step

Getting it running

  1. Install dependencies

    Pulls expo, llama.rn, zustand and the voice modules. The runtime corpus is already committed, so nothing needs generating before the app will run.

    npm install
  2. Regenerate the corpus (optional)

    The build script fetches Griffith’s Ramayana from Project Gutenberg and Ganguli’s Mahabharata from archive.org, then re-segments them into the two runtime JSON files.

    npm run corpus:build:comprehensive
  3. Make a development build

    llama.rn is a native module, so the app cannot run in Expo Go. The development profile produces an APK for internal distribution.

    npx eas build -p android --profile development
  4. Install the build and start the bundler

    Side-load the APK from the EAS build page onto the device, then start Metro and connect the dev client to it.

    npm start
  5. Let the model download

    On first launch the app streams the GGUF file into its document directory, showing progress in MB. This happens once; later launches load from disk.

  6. Ask a question

    Type into the input field. Retrieval pulls three episodes per turn, the reply streams in, and it is read aloud unless you switch voice replies off.

  7. Inspect what the model actually used

    A PIN-gated debug view reveals, under each reply, the retrieved episode ids, quoted verse ids, the refusal layer’s result, and the raw model output before filtering.

04 · What you get

Capabilities

On-device inference

llama.rn loads the model locally, with Android clamped to a 768-token context to stay inside phone memory.

Episode retrieval

An index over 1,014 episode records returns the top matches per turn with any linked canonical verses attached.

Refusal layer

Each reply is screened for prescriptive phrasing, bullet lists, character breaks, and whether it references a retrieved episode.

Verses are never generated

Sanskrit only appears by verbatim reproduction from an 11-entry verse pack; anything else fails the check and forces a regenerate.

PIN-gated debug view

Exposes retrieved ids, quoted verses, refusal result and unfiltered output for each turn.

Corpus build scripts

Two Node scripts rebuild the corpus from public-domain sources, tagging segments by character, theme and situation.

05 · Before you rely on it

Limitations, honestly

Every tool has edges. These are the ones that will cost you time if nobody tells you first.

  • Semantic retrieval is not implemented — the embeddings module is an explicit stub returning hash-based pseudo-random vectors, so episode matching is effectively arbitrary until a real model is wired in.
  • Nothing is fine-tuned. A general instruction-tuned Gemma is steered at runtime by retrieval and a persona prompt, so "trained on" overstates what happens.
  • It is a study aid built on public-domain English translations, not an authority on scripture. Translations differ, and anything that matters should be checked against the source texts and people qualified to teach them.
  • Voice input is not connected — the speech-to-text module is never called, and the mic button only focuses the text field.
  • Conversations vanish on restart; the store is an in-memory map standing in for persistent storage.
  • Corpus metadata is thin — all 492 Ramayana records share a template summary, and 526 of 1,014 records list characters as just "Narrative".
  • No README, no tests and no license file, so terms of use for the code are undefined.

Read the source

Everything above came from the repository. Read it, fork it, or open an issue if something here is wrong.

github.com