model-architecture-nanogpt
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).
Target: Learning & research. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original text
Topics in the source
- nanoGPT - Minimalist GPT Training
- Quick start
- Common workflows
- Workflow 1: Character-level Shakespeare
- Workflow 2: Reproduce GPT-2 (124M)
- Workflow 3: Fine-tune pretrained GPT-2
- Workflow 4: Custom dataset
- When to use vs alternatives
nanoGPT is a simplified GPT implementation designed for learning and experimentation. Installation: Train on Shakespeare (CPU-friendly): Output: Complete training pipeline: Config (config/trainshakespearechar.py): Training time: 5 minutes (CPU), 1 minute (GPU) Multi-GPU training on OpenWebText: Config (config/traingpt2.py): Training time: 4 days (8× A100) Start from OpenAI checkpoint: Example config (config/finetuneshakespeare.py): Train on your own text: Train: Use nanoGPT when: Learning how GPT works Experimenting with transformer variants Teaching/education purposes Quick prototyping Limited compute (can run on CPU) Simplicity advantages: 300 lines: Entire model in model.py 300 lines: Training loop in train.py Hackable: Easy to modify No abstractions: Pure PyTorch Use alternatives instead: HuggingFace Transformers: Production use, many models Megatron-LM: Large-scale distributed training LitGPT: More architectures, production-ready PyTorch Lightning: Need high-level framework Issue: CUDA out of memory Reduce batch size or context length: Issue: Training too slow Enable compilation (PyTorch 2.0+): Use mixed precision: Issue: Poor generation quality Train longer: Lower temperature
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- davila7/claude-code-templates
- Source file
- cli-tool/components/skills/ai-research/model-architecture-nanogpt/SKILL.md
- Fixed revision
- 21be197f100a12b8d0dd9a211cc244c8179f84d3
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: davila7/claude-code-templates · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:43.241Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.