ApyHTML19 commited on
Commit
e1646b2
·
verified ·
1 Parent(s): 813b44b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -0
README.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: openrail
4
+ tags:
5
+ - text-generation
6
+ - causal-lm
7
+ - gpt
8
+ - small-language-model
9
+ - tinystories
10
+ - pytorch
11
+ base_model: []
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # ABADES-SLM-15M
16
+
17
+ A small GPT-style language model trained from scratch on the [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories) dataset. Designed as a lightweight, educational SLM (Small Language Model).
18
+
19
+ ---
20
+
21
+ ## Model Details
22
+
23
+ | Property | Value |
24
+ |---|---|
25
+ | **Architecture** | GPT (decoder-only transformer) |
26
+ | **Parameters** | ~15M |
27
+ | **Vocab size** | 50,257 (GPT-2 tokenizer) |
28
+ | **Context length** | 128 tokens |
29
+ | **Layers** | 6 |
30
+ | **Attention heads** | 6 |
31
+ | **Embedding dim** | 384 |
32
+ | **Training dataset** | TinyStories |
33
+ | **Training iterations** | 45,000 |
34
+ | **License** | OpenRAIL |
35
+
36
+ ---
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ import torch
42
+ import tiktoken
43
+ from model import GPT, GPTConfig # your model file
44
+
45
+ # Load tokenizer
46
+ enc = tiktoken.get_encoding("gpt2")
47
+
48
+ # Load model
49
+ config = GPTConfig(
50
+ vocab_size=50257,
51
+ block_size=128,
52
+ n_layer=6,
53
+ n_head=6,
54
+ n_embd=384,
55
+ dropout=0.0,
56
+ bias=True
57
+ )
58
+
59
+ model = GPT(config)
60
+ checkpoint = torch.load("ABADES-SLM-15M.pt", map_location="cpu")
61
+ model.load_state_dict(checkpoint["model_state_dict"])
62
+ model.eval()
63
+
64
+ # Generate text
65
+ sentence = "Once upon a time there was a little girl"
66
+ context = torch.tensor(enc.encode_ordinary(sentence)).unsqueeze(0)
67
+
68
+ with torch.no_grad():
69
+ output = model.generate(context, max_new_tokens=200, temperature=0.8, top_k=40)
70
+
71
+ print(enc.decode(output.squeeze().tolist()))
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Training Details
77
+
78
+ - **Tokenizer:** GPT-2 BPE (`tiktoken`)
79
+ - **Optimizer:** AdamW (`lr=1e-4`, `betas=(0.9, 0.95)`, `weight_decay=0.1`)
80
+ - **LR Schedule:** Linear warmup (1000 steps) → Cosine decay
81
+ - **Mixed precision:** bfloat16 / float16
82
+ - **Gradient accumulation:** 32 steps
83
+ - **Gradient clipping:** 0.5
84
+
85
+ ---
86
+
87
+ ## Example Outputs
88
+
89
+ **Prompt:** `"Once upon a time there was a pumpkin."`
90
+ > Once upon a time there was a pumpkin. It was big and orange and lived in a garden...
91
+
92
+ **Prompt:** `"A little girl went to the woods"`
93
+ > A little girl went to the woods with her dog. They were looking for something fun to do...
94
+
95
+ ---
96
+
97
+ ## Limitations
98
+
99
+ - Trained only on simple children's stories (TinyStories)
100
+ - Context window limited to 128 tokens
101
+ - Not suitable for complex reasoning or factual tasks
102
+ - May generate repetitive or incoherent text on out-of-domain prompts
103
+
104
+ ---
105
+
106
+ ## Author
107
+
108
+ **ApyHTML19** — built as a learning project to understand transformer training from scratch.
109
+
110
+ Inspired by [nanoGPT](https://github.com/karpathy/nanoGPT) by Andrej Karpathy.