JayF14 commited on
Commit
440b264
·
verified ·
1 Parent(s): c748acb

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +57 -61
README.md CHANGED
@@ -14,70 +14,66 @@ tags:
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.
 
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.