Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -14,70 +14,66 @@ tags:
|
|
| 14 |
license: mit
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# MANAS
|
|
|
|
| 18 |
|
| 19 |
-
|
| 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 |
-
|
| 23 |
|
| 24 |
-
|
| 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 |
-
|
| 31 |
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
-
-
|
| 36 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
## Intended Use
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
- **
|
| 51 |
-
- **
|
| 52 |
-
- **
|
| 53 |
-
- **
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
*
|
| 58 |
-
|
| 59 |
-
|
| 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.
|
|
|
|
| 14 |
license: mit
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# MANAS
|
| 18 |
+
### Model for Awadhi Natural Autoregressive Sequences
|
| 19 |
|
| 20 |
+
MANAS is a small experimental **character-level causal Transformer** trained on a corpus centered on the literary works of Goswami Tulsidas.
|
|
|
|
| 21 |
|
| 22 |
+
The model operates directly on individual Unicode characters rather than using a subword tokenizer such as BPE. The project is intended primarily as an educational and research experiment for understanding how Transformer language models learn character-level patterns in classical Devanagari literary text.
|
| 23 |
|
| 24 |
+
## Model Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
- **Architecture:** GPT-style decoder-only causal Transformer
|
| 27 |
+
- **Parameters:** ~10.9M
|
| 28 |
+
- **Embedding dimension:** 384
|
| 29 |
+
- **Transformer layers:** 6
|
| 30 |
+
- **Attention heads:** 6
|
| 31 |
+
- **Context window:** 256 characters
|
| 32 |
+
- **Dropout:** 0.2
|
| 33 |
+
- **Vocabulary size:** 101 characters
|
| 34 |
+
- **Framework:** PyTorch
|
| 35 |
+
- **Checkpoint:** `tulsidas_model.pth`
|
| 36 |
+
|
| 37 |
+
## Corpus
|
| 38 |
+
|
| 39 |
+
The current corpus contains approximately **2.83 million characters** and is focused on Tulsidas-related literary material.
|
| 40 |
+
|
| 41 |
+
The project currently includes material associated with works such as:
|
| 42 |
+
- Ramcharitmanas
|
| 43 |
+
- Vinay Patrika
|
| 44 |
+
- Kavitavali
|
| 45 |
+
- Parvatimangal
|
| 46 |
+
- additional works contained in the Tulsi-Granthavali compilation
|
| 47 |
+
|
| 48 |
+
The corpus is character-level and contains no Latin alphabet characters. However, the current corpus should be considered an **experimental OCR-derived corpus**, and some source-extraction/OCR errors or non-literary material may remain.
|
| 49 |
+
|
| 50 |
+
Future dataset revisions will improve:
|
| 51 |
+
- OCR accuracy
|
| 52 |
+
- literary-text extraction
|
| 53 |
+
- removal of commentary and publication material
|
| 54 |
+
- Unicode cleanup
|
| 55 |
+
- work-level segmentation
|
| 56 |
+
- manual page verification
|
| 57 |
|
| 58 |
## Intended Use
|
| 59 |
+
|
| 60 |
+
MANAS is intended for:
|
| 61 |
+
- educational exploration of Transformer language models
|
| 62 |
+
- character-level language-model research
|
| 63 |
+
- experimentation with Devanagari text generation
|
| 64 |
+
- studying learned character and sequence patterns in Tulsidas-related literature
|
| 65 |
+
|
| 66 |
+
## Inference Note
|
| 67 |
+
Since `chat.py` and the vocabulary arrays are not included in this minimal repository, inference requires manually reconstructing the `LanguageModel` architecture in PyTorch (6 layers, 6 heads, 384 embed dim, 101 vocab size) and loading `tulsidas_model.pth`. It also requires the 101-character mapping array derived from the dataset to properly encode/decode.
|
| 68 |
+
|
| 69 |
+
## Limitations
|
| 70 |
+
- **Small model:** At approximately 10.9M parameters, MANAS is a small experimental language model and should not be compared directly with modern large language models.
|
| 71 |
+
- **Character-level generation:** Character-level modeling allows the experiment to operate directly on Devanagari characters, but it is less efficient than modern subword tokenization.
|
| 72 |
+
- **Corpus quality:** The current corpus was assembled from scanned literary sources and is still undergoing OCR and extraction-quality improvements. Some OCR errors, editorial material, and commentary may remain.
|
| 73 |
+
- **Long-range coherence:** Generation quality can degrade during long samples because the model has limited capacity and a 256-character context window.
|
| 74 |
+
- **No general knowledge:** The model is not designed to answer modern factual questions or function as a general-purpose conversational model.
|
| 75 |
+
|
| 76 |
+
## Project Status
|
| 77 |
+
**MANAS is an experimental educational model (Checkpoint 1).**
|
| 78 |
+
|
| 79 |
+
The next major improvement is a rebuilt, page-verified corpus using OCR for scanned sources with unreliable PDF text layers, followed by cleaner literary-text segmentation and retraining.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|