--- license: gemma base_model: google/gemma-4-E4B-it tags: [ganesha, marathi, hindi, sanskrit, on-device, litert, lora, devotional] language: [mr, hi, en, sa] pipeline_tag: text-generation --- # Ganesh SLM — Gemma 4 E4B fine-tune An offline assistant fine-tuned on Shri Ganesha's shlokas, stotras, aartis, rituals and stories, for Ganeshotsav 2026. Answers in Marathi, Hindi or English. **No RAG** — the canon is in the weights. **Created in service of Shri Ganesh by Ravi Kadam — https://www.linkedin.com/in/ravikadam/** ## What it does Recites, verbatim and exactly: - **Sukhkarta Dukhharta** (Samarth Ramdas) - **Ganapati Atharvashirsha** — complete, sections 1–19 plus the closing shanti - **Sankatnashan Ganesh Stotra** (Narada Purana) - **Ganapati Ashtottara Shatanamavali** — all 108 names - **Ganesha Pancharatnam** (Adi Shankara) — all five verses - **Vakratunda Mahakaya**, **Ganapati Gayatri** Also covers puja vidhi (pranapratishtha, shodashopachara, durva and the 21 patri, uttarpuja, visarjan), the Puranic stories, the Ashtavinayak, Mumbai's mandals, and 2026 festival dates. ## What it deliberately refuses - **Sankashti moonrise times** — vary by city and month; it defers to a panchang - **Any year other than 2026** — its calendar is frozen at 2026 and it says so - **Live queue or darshan timings** — it is offline and cannot know Every dated answer is **year-stamped** ("In 2026...") so it never reads as a claim about the current year, and every muhurat names its city (Mumbai's 2026 window is 11:20–13:48, about 18 minutes later than the generic figure — which is exactly why a bare time is wrong). ## Known limitations — please read - **It can fabricate.** Asked for a stotra it does not know (e.g. "Ganesha Vajrakavacha"), it may recite a different stotra instead of declining. Do not trust an unfamiliar text from it. - **Four texts are NOT included** because they could not be verified against a reliable source: Ghalin Lotangan, Mantrapushpanjali, Shendur Lal Chadhayo, and the mool mantras. Ghalin Lotangan normally follows Sukhkarta Dukhharta in the aarti sequence — this model does not know it. - Canonical texts were verified against public sources, **not against a printed pothi**. Editions differ in punctuation, anusvara/conjunct conventions, and section numbering. - It is **not a guruji and not a panchang**. For muhurat, family vidhi and anything disputed, ask your elders and your priest. ## Method Small curated corpus (32 units) → deterministic pair generation. Canonical Devanagari is spliced **byte-exact** from YAML and never passes through a generative model; only the *question* side is varied. Unverified texts are gated out of training entirely. 1,959 training pairs (1,216 verbatim / 405 calendar / 338 prose). LoRA r=64, alpha=128, 3 epochs, lr 1e-4, bf16, seq 2048, on an L40S. Adapters scoped to the language model — Gemma 4's E-series wraps vision/audio projections in `Gemma4ClippableLinear`, which PEFT cannot target. Final train loss 0.46, train token accuracy 0.97. ## Usage ```python from transformers import AutoTokenizer, AutoModelForCausalLM import torch m_id = "ravikadam/ganesh-gemma4-e4b" tok = AutoTokenizer.from_pretrained(m_id) model = AutoModelForCausalLM.from_pretrained(m_id, dtype=torch.bfloat16, device_map="auto") msgs = [ {"role": "system", "content": "You are an offline assistant fine-tuned on Shri Ganesha's shlokas, stotras, aartis, rituals and stories. Answer in the language the user writes in. Never invent a verse."}, {"role": "user", "content": "सुखकर्ता दुखहर्ता आरती म्हण."}, ] enc = tok.apply_chat_template(msgs, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt").to(model.device) out = model.generate(**enc, max_new_tokens=700, do_sample=False) print(tok.decode(out[0][enc["input_ids"].shape[-1]:], skip_special_tokens=True)) ``` गणपती बाप्पा मोरया 🙏