nanogpt
Agent skill fromOrchestra-Research/AI-Research-SKILLs
Educational GPT implementation in ~300 lines. Reproduces GPT-2 (124M) on OpenWebText. Clean, hackable code for learning transformers. By Andrej Karpathy. Perfect for understanding GPT architecture from scratch. Train on Shakespeare (CPU) or OpenWebText (multi-GPU).
How to install nanogpt
install nanogpt
# install the AI-Research-SKILLs pack with the skills CLI
npx skills add Orchestra-Research/AI-Research-SKILLs# or add only this skill to Claude Code: copy the folder
01-model-architecture/nanogpt/
# into
~/.claude/skills/nanogpt/ (all projects)
.claude/skills/nanogpt/ (one project)
1# nanoGPT - Minimalist GPT Training23## Quick start45nanoGPT is a simplified GPT implementation designed for learning and experimentation.67**Installation**:8```bash9pip install torch numpy transformers datasets tiktoken wandb tqdm10```1112**Train on Shakespeare** (CPU-friendly):13```bash14# Prepare data15python data/shakespeare_char/prepare.py1617# Train (5 minutes on CPU)18python train.py config/train_shakespeare_char.py1920# Generate text21python sample.py --out_dir=out-shakespeare-char22```2324**Output**:25```26ROMEO:27What say'st thou? Shall I speak, and be a man?2829JULIET:30I am afeard, and yet I'll speak; for thou art31One that hath been a man, and yet I know not32What thou art.33```3435## Common workflows3637### Workflow 1: Character-level Shakespeare3839**Complete training pipeline**:40```bash41# Step 1: Prepare data (creates train.bin, val.bin)42python data/shakespeare_char/prepare.py4344# Step 2: Train small model45python train.py config/train_shakespeare_char.py4647# Step 3: Generate text48python sample.py --out_dir=out-shakespeare-char49```5051**Config** (`config/train_shakespeare_char.py`):52```python53# Model config54n_layer = 6 # 6 transformer layers55n_head = 6 # 6 attention heads56n_embd = 384 # 384-dim embeddings57block_size = 256 # 256 char context5859# Training config60batch_size = 6461learning_rate = 1e-362max_iters = 500063eval_interval = 5006465# Hardware66device = 'cpu' # Or 'cuda'67compile = False # Set True for PyTorch 2.068```69…
Excerpt shown under the repository's MIT license.
