Views
No views yet
RMSNorm instead of standard LayerNormRoPE (Rotary Positional Embeddings) instead of learned positional embeddingsGrouped Query Attention (GQA) to reduce KV head costSwiGLU as the feed-forward activation blocksrc/model.py and is implemented as a pre-norm transformer.RMSNormGroupedQueryAttention with RoPERMSNormSwiGLURMSNorm is applied.RMSNorm
Normalizes activations using root-mean-square statistics with a learned scale parameter.RoPE
Encodes token position by rotating query and key vectors, allowing attention to capture relative positions naturally.Grouped Query Attention
Uses more query heads than key/value heads, which keeps attention expressive while reducing KV projection cost.SwiGLU
Uses a SiLU-gated feed-forward pathway that is commonly used in modern LLMs.d_model = 256n_layers = 4n_heads = 8n_kv_heads = 2ffn_hidden_dim = 680context_length = 256batch_size = 64roneneldan/TinyStoriesdata/dataset.txttokenizer.jsondownload_dataset.py, train_tokenizer.py, or train.py.pip install -r requirements.txtpip install tokenizers datasets numpypython download_dataset.pypython train_tokenizer.pypython train.pydata/dataset.txt existstokenizer.jsonMiniLLMAdamWmodel.ptdata/dataset.txt, token caches, or model.pt. The included .gitignore already excludes them.python generate.py --prompt "Once upon a time"python generate.py --prompt "Once upon a time" --temperature 0.8 --max-new-tokens 300--prompt starting text for generation--temperature sampling temperature, where 0 is greedy decoding--max-new-tokens number of tokens to generate--model-path optional path to a checkpoint--seed optional random seed for reproducible sampling1.
2├── src/
3│ ├── model.py
4│ ├── tokenizer.py
5│ └── dataset.py
6├── notebooks/
7│ └── first-mini-modern-llm.ipynb
8├── train.py
9├── generate.py
10└── requirements.txt