Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: mit
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- awa
|
| 4 |
+
- bra
|
| 5 |
+
- hi
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- pytorch
|
| 9 |
+
- causal-lm
|
| 10 |
+
- transformer
|
| 11 |
+
- character-level
|
| 12 |
+
- poetry
|
| 13 |
+
- tulsidas
|
| 14 |
license: mit
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# MANAS (Model for Awadhi Natural Autoregressive Sequences)
|
| 18 |
+
|
| 19 |
+
## Model Description
|
| 20 |
+
**MANAS (Model for Awadhi Natural Autoregressive Sequences)** is a custom **Character-level Causal Transformer (Language Model)** trained exclusively on the classical poetry of Goswami Tulsidas (including the *Ramcharitmanas* and *Vinayapatrika*).
|
| 21 |
+
|
| 22 |
+
Unlike modern token-based LLMs (which use subwords/BPE), this model processes and predicts text **one character at a time**. It learned the grammar, vocabulary, and poetic meter of 16th-century Awadhi entirely from scratch, mapping complex Devanagari characters into coherent poetry.
|
| 23 |
+
|
| 24 |
+
- **Parameters:** ~10 Million
|
| 25 |
+
- **Vocab Size:** 101 (Pure Devanagari, punctuation, numbers. 0 Latin characters)
|
| 26 |
+
- **Architecture:** GPT-style Decoder-only Transformer
|
| 27 |
+
- **Language:** Awadhi, Braj Bhasha
|
| 28 |
+
- **Format:** PyTorch (`.pth` state_dict)
|
| 29 |
+
|
| 30 |
+
## Model Architecture
|
| 31 |
+
The model was built using PyTorch with the following hyperparameter configuration:
|
| 32 |
+
- `n_embd` (Embedding Dimension): 384
|
| 33 |
+
- `n_layer` (Transformer Blocks): 6
|
| 34 |
+
- `n_head` (Attention Heads): 6
|
| 35 |
+
- `block_size` (Context Window): 256 characters
|
| 36 |
+
- `dropout`: 0.2
|
| 37 |
+
|
| 38 |
+
## Intended Use
|
| 39 |
+
This model is built as an experimental, educational exploration into character-level causal modeling for low-resource classical Indian dialects.
|
| 40 |
+
- **Text Generation:** Given a prompt in Devanagari (e.g., `श्री राम`), the model will autoregressively generate poetry in the style of Tulsidas.
|
| 41 |
+
- **Linguistic AI Research:** Useful for observing how transformers learn Devanagari conjuncts (मात्राएँ and संयुक्ताक्षर) without the crutch of subword tokenizers.
|
| 42 |
+
|
| 43 |
+
## Training Data
|
| 44 |
+
The model was trained on the `Awadhi-Tulsidas-Literary-Corpus`, a heavily purified 2.8 million character dataset. The training set is 100% devoid of English and Latin characters to prevent domain confusion.
|
| 45 |
+
- **Train tokens:** 2,550,420
|
| 46 |
+
- **Validation tokens:** 283,381
|
| 47 |
+
|
| 48 |
+
## Training Procedure
|
| 49 |
+
- **Optimizer:** AdamW
|
| 50 |
+
- **Learning Rate:** 3e-4
|
| 51 |
+
- **Batch Size:** 64
|
| 52 |
+
- **Training Steps:** 15,000 iterations
|
| 53 |
+
- **Hardware:** Trained on single consumer GPU.
|
| 54 |
+
|
| 55 |
+
## How to Use (Inference)
|
| 56 |
+
Because the model vocabulary does not contain English, **all inputs must be in Devanagari script.**
|
| 57 |
+
*(An ITRANS-to-Devanagari transliteration layer is recommended for users typing on English keyboards).*
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import torch
|
| 61 |
+
from chat import LanguageModel, encode, decode
|
| 62 |
+
|
| 63 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 64 |
+
|
| 65 |
+
# 1. Initialize model
|
| 66 |
+
model = LanguageModel()
|
| 67 |
+
model.load_state_dict(torch.load('tulsidas_model.pth', map_location=device))
|
| 68 |
+
model.to(device)
|
| 69 |
+
model.eval()
|
| 70 |
+
|
| 71 |
+
# 2. Prompt in Devanagari
|
| 72 |
+
prompt = "श्री राम"
|
| 73 |
+
context = torch.tensor([encode(prompt)], dtype=torch.long, device=device)
|
| 74 |
+
|
| 75 |
+
# 3. Generate
|
| 76 |
+
generated_tokens = model.generate(context, max_new_tokens=200)[0].tolist()
|
| 77 |
+
print(decode(generated_tokens))
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Limitations & Bias
|
| 81 |
+
- **Hallucinations:** As a 10M parameter character-level model, it occasionally invents novel (but morphologically plausible) Awadhi words.
|
| 82 |
+
- **Grammar drift:** Over long generations (>500 chars), the model may lose semantic track, though it heavily preserves phonetic and rhythmic flow.
|
| 83 |
+
- **Zero Modern Knowledge:** This model cannot answer questions about the modern world, nor can it speak conversational modern Hindi. It exists solely to predict 16th-century poetic strings.
|