Views
No views yet
Once upon a time, there was a little girl named Lily. She loved to play with her toys and her favorite toy, a toy truck. One day, Lily's mommy made her a yummy chocolate cake to make her happy. Lily's friend, Timmy, came over to play...
Lily and Tom went to the park and saw a big dog... "Mom, mom, the dog is coming!" Lily cried. "The dog is not mean. It was friendly and friendly. It wants to play with us."
| Component | Choice |
|---|---|
| Layers / heads / dim | 8 layers, 6 heads, n_embd 384 |
| Context length | 256 tokens |
| Vocabulary | 16,384 (ByteLevel BPE) |
| Position encoding | RoPE |
| Attention | Grouped-Query Attention (2 KV heads) + QK-Norm |
| MLP | squared-ReLU (ungated) |
| Normalization | RMSNorm |
| Init | zero-init block output projections (muP-like) |
| Logits | soft-capped at 15 (cap·tanh(logits/cap)) |
| Extra heads | Multi-Token Prediction (2 auxiliary heads) |
| Weight tying | token embedding ↔ output head (and MTP heads) |
| Dataset | TinyStories (~2.1M stories) |
| Steps | 3,000 |
| Batch | 40 × 256 tokens |
| Optimizer | Muon (2D weights) + AdamW (embeddings/norms), peak LR 3e-3, cosine schedule |
| Precision | fp16 mixed precision, torch.compile |
| Hardware | 1× RTX 2060 Super (8 GB), ~8 minutes |
| Train loss | 2.47 (combined next-token + MTP auxiliary) |
| Validation loss | 2.40 (perplexity ~11.0) |
model.py from this repo (small,
dependency-light). Download it next to your script, then:1import torch
2from huggingface_hub import hf_hub_download
3from tokenizers import Tokenizer
4from model import GPT # model.py downloaded from this repo
5
6repo = "epoyraz/tinystories-25m"
7ckpt = torch.load(
8 hf_hub_download(repo, "tinystories-25m.pt"),
9 map_location="cpu", weights_only=True,
10)
11model = GPT(ckpt["config"]).eval()
12model.load_state_dict(ckpt["model"])
13
14tok = Tokenizer.from_file(hf_hub_download(repo, "tokenizer.json"))
15ids = tok.encode("Once upon a time,").ids
16out = model.generate(
17 torch.tensor([ids]), max_new_tokens=120, temperature=0.7, top_k=40,
18)
19print(tok.decode(out[0].tolist()))pip install torch tokenizers huggingface_hubtinystories-25m.pt — checkpoint (config + model state dict)model.py — model definition (GPT, all techniques)config.json — the model config, for referencetokenizer.json — ByteLevel BPE tokenizer (16K vocab)