A minimal GPT implementation in 83 lines of Python + PyTorch. Rewrite of microgpt.py by Andrej Karpathy, replacing scalar-level autograd with PyTorch tensor ops + CUDA.
Trains on ~32K English names and generates new ones.
- Python >= 3.10
- PyTorch >= 2.4 (for
F.rms_norm,F.scaled_dot_product_attention)
python microgpt-torch.pyThe script will:
- Download the dataset (if not present)
- Train for 40 epochs (auto-detects GPU)
- Generate 20 new "hallucinated" names
microgpt-torch.py— compact version (83 lines)microgpt-torch-comments.py— same code with bilingual comments (EN/CN)