SanskritGPT-Itihasa is a decoder-only Transformer (GPT-2 architecture) trained from scratch on classical Sanskrit epic texts (Itihasa). The model learns to generate Devanagari Sanskrit verse in the stylistic register of either the Mahabharata or the Ramayana, using style-control tokens.
This is a computational linguistic research experiment — not an authoritative source of scripture. The model captures statistical patterns of classical Sanskrit poetry including metrical adherence (Anushtubh), sandhi rules, and epic vocabulary.
Content: Electronic texts of all 18 Parvas of the Mahabharata and all 7 Kandas of the Ramayana.
Language: Classical Sanskrit in Devanagari script.
Corpus Size: ~24 MB of cleaned, processed Devanagari text.
Training Procedure
Tokenizer: Custom Unigram tokenizer with Metaspace pre-tokenization, trained specifically on this Sanskrit corpus with a 32,000 token vocabulary.
Style Tokens: <MBH> (Mahabharata), <RAM> (Ramayana), <eos> (End of text).
Optimizer: AdamW with weight decay 0.1.
Learning Rate: Cosine schedule with warmup.
Sequence Length: 512 tokens.
Hardware: Google Colab T4 GPU (16GB VRAM).
Duration: 30 epochs, ~2 hours total.
Evaluation
Metric
Value
Final Training Loss
~1.2
Final Validation Loss
~1.4
Perplexity (Validation)
~4.1
Metrical Adherence
High (Anushtubh meter dominant)
Intended Use
Appropriate Use Cases
Computational Linguistics Research: Analysis of Sanskrit metrical and grammatical patterns.
Digital Humanities: Exploration of AI-generated classical literature.
Educational Demos: Demonstrating Transformer capabilities on low-resource, non-Latin script languages.
Creative Writing Aid: Generating starting verses for research or artistic exploration (with human expert review).
Out-of-Scope Uses
Religious or Ritual use: Generated text is not authentic scripture.
Scholarly Translation: The model does not "understand" semantic meaning.
Authoritative Attribution: Generated text must not be attributed to classical authors.
Limitations
Statistical Mimicry: The model learns phonetic and metrical patterns — it does not possess an understanding of traditional Sanskrit semantics or philosophy.
Occasional Memorization: Due to the finite corpus size, may occasionally reproduce specific training verses.
Fixed Context: Generation quality may decline for very long sequences beyond 512 tokens.
Sandhi Imperfection: While the Unigram tokenizer is morphologically aware, complex Sandhi rules are not always perfectly applied.
Not Scripture: Generated text is not authentic Vedic or Epic scripture and must never be used for ritual, recitation, or canonical scholarly interpretation.
Citation
If you use this model in your research, please cite:
bibtex
1@misc{sanitgpt-itihasa-2026,
2 author = {Dhruvil},
3 title = {SanskritGPT-Itihasa: A GPT-2 Transformer for Sanskrit Epic Verse Generation},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/Dhruvil8/SanskritGPT-Itihasa},
7 note = {Trained from scratch on Mahabharata and Ramayana Devanagari texts.}
8}
License
This project is released under the MIT License. The underlying Sanskrit texts are in the public domain.
This model is an AI-assisted computational experiment. It reflects the language patterns of the corpus, not the wisdom of the tradition. For authentic scriptural guidance, consult qualified scholars and traditional sources.