File size: 4,175 Bytes
a76cbe2
27a1653
 
a76cbe2
27a1653
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a76cbe2
27a1653
2fd3015
27a1653
2fd3015
27a1653
2fd3015
 
 
27a1653
2fd3015
27a1653
2fd3015
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27a1653
 
2fd3015
27a1653
 
2fd3015
27a1653
 
 
2fd3015
 
 
 
27a1653
2fd3015
 
 
27a1653
 
 
 
 
 
2fd3015
27a1653
2fd3015
27a1653
 
 
2fd3015
 
 
27a1653
 
2fd3015
27a1653
 
2fd3015
27a1653
2fd3015
27a1653
2fd3015
27a1653
2fd3015
 
 
27a1653
2fd3015
27a1653
2fd3015
27a1653
2fd3015
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
language:
  - hi
license: mit
library_name: transformers
tags:
  - hindi
  - story-generation
  - causal-lm
  - llama-style
  - transformer
  - from-scratch
  - text-generation
datasets:
  - SmallScale/Simple-Stories-Hindi
pipeline_tag: text-generation
model-index:
  - name: Simple-Stories-Hindi-20M
    results: []
---

# 📖 Simple-Stories-Hindi-20M (22.3M Parameters)

A **22.3M parameter** decoder-only Transformer language model trained **from scratch** on **2.11 million Hindi simple stories**. The model generates coherent, creative, and grammatically sound Hindi stories given a short text prompt.

---

## 📊 Evaluation & Training Metrics

| Metric / Property | Value |
|---|---|
| **Best Validation Loss** | **`1.6914`** (Cross-Entropy Loss) |
| **Total Training Steps** | **386,000 steps** |
| **Total Parameters** | **22,310,784 (22.3M)** |
| **Non-Embedding Parameters** | **20,006,784 (20M)** |
| **Training Dataset** | [SmallScale/Simple-Stories-Hindi](https://huggingface.co/datasets/SmallScale/Simple-Stories-Hindi) (~2.11M stories) |
| **Model Size on Disk** | ~86 MB (`model.safetensors`) |

---

## 🏗️ Model Architecture Details

| Parameter | Value | Notes |
|---|---|---|
| **Architecture** | LLaMA-style Decoder | RoPE + SwiGLU + RMSNorm |
| **Hidden Size (`d_model`)** | 384 | Vector dimension |
| **FFN Intermediate Size** | 1024 | 8/3 × `d_model` rounded to multiple of 64 |
| **Layers (`n_layers`)** | 10 | Transformer blocks |
| **Attention Heads (`n_heads`)** | 8 | Multi-Head Self Attention |
| **Context Length (`max_seq_len`)** | 512 tokens | Sequence window |
| **Vocabulary Size** | 6,000 | SentencePiece Unigram (Devanagari optimized) |
| **Weight Tying** | Enabled | Token embeddings & output projection share weights |
| **Precision** | float32 | Weights stored in native FP32 safetensors |

---

## 🚀 Quick Start & Usage

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load tokenizer and model directly from Hugging Face
tokenizer = AutoTokenizer.from_pretrained("SmallScale/Simple-Stories-Hindi-20M", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("SmallScale/Simple-Stories-Hindi-20M", trust_remote_code=True)

if torch.cuda.is_available():
    model = model.to("cuda")

# Prompt input
prompt = "एक समय की बात है"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

# Generate story
outputs = model.generate(
    **inputs,
    max_new_tokens=200,
    do_sample=True,
    top_k=40,
    top_p=0.95,
    temperature=0.8
)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

---

## 📝 Sample Generated Stories

**Prompt:** `एक समय की बात है`
> *एक समय की बात है, और वह एक रात एक लड़की के लिए सब कुछ बदल सकती है। वह एक आभासी क्षेत्र में प्रवेश कर गई, जहाँ वह एक लड़के से मिली, जो उसके सपनों से बना था। वे अपने डर और इच्छाओं को साझा करते थे...*

**Prompt:** `एक जंगल में`
> *एक जंगल में जहाँ पेड़ों ने रहस्यों को फुसफुसाया, एक लड़का एक छोटी सी झोपड़ी में रहता था। वह अक्सर सोचता था कि अगर वह अपने सपनों में एक परी से मिल सकता है तो क्या होगा...*

---

## 🔗 Related Resources

- **GGUF (FP16) Model Repo:** [SmallScale/Simple-Stories-Hindi-20M-GGUF](https://huggingface.co/SmallScale/Simple-Stories-Hindi-20M-GGUF)
- **Live In-Browser Demo (WebGPU / WASM):** [SmallScale/simple-stories-20m-webgpu](https://huggingface.co/spaces/SmallScale/simple-stories-20m-webgpu)
- **Dataset:** [SmallScale/Simple-Stories-Hindi](https://huggingface.co/datasets/SmallScale/Simple-Stories-Hindi)

---

## 📄 License

MIT License