Transformers, training and fine-tuning
Build a tiny GPT, tokenizers, when to fine-tune, LoRA, data, preference tuning, distillation, scaling, interpretability.
12 skills · 4 stages each
Skills
- Build a tiny GPTFor engineersStart hereWrite a small character-level GPT in PyTorch, from tokenizer and causal self-attention to a training loop and sampling, to see what every LLM does insideneeds: Attention and transformers (intuition)110 questions
- Tokenizers (BPE)For engineersHow byte-pair encoding builds a vocabulary, how real tokenizers are trained and configured, and how tokenizer choices surface as model bugsneeds: Build a tiny GPT110 questions
- When to fine-tune a modelFor engineersDeciding between prompting, retrieval, hosted tuning and open-weight fine-tuning with evidence, cost and long-term maintenance in viewneeds: Post-training110 questions
- LoRA and PEFTFor engineersParameter-efficient fine-tuning with low-rank adapters and QLoRA: how it works, the open tools, a clean run and serving adaptersneeds: Build a tiny GPT110 questions
- Fine-tuning dataFor engineersBuilding supervised fine-tuning datasets: chat formats and loss masking, curation, synthetic data, privacy and licensing, and held-out evaluationneeds: Post-training110 questions
- Preference and RL tuningFor engineersRLHF, DPO, AI feedback and reinforcement learning with verifiable rewards, plus the reward hacking each method invites and how to choose among themneeds: When to fine-tune a model110 questions
- Distillation and small modelsFor engineersTeaching small, cheap models from large ones with logit or output distillation and reasoning traces, measuring the result and respecting provider termsneeds: When to fine-tune a model110 questions
- Scaling laws and computeFor engineersHow loss scales with parameters, data and compute, how to estimate a run's cost, compute-optimal choices, inference-time scaling and reading scaling claims criticallyneeds: How pre-training builds a language model110 questions
- Interpretability basicsFor engineersFeatures, superposition, sparse autoencoders, circuits, probes and steering, and what they can and cannot tell us about model behaviour and safetyneeds: Build a tiny GPT110 questions
- Modern LLM architecture choicesFor engineersWhat changed between GPT-2 and today's open-weight models: rotary positions, RMSNorm and SwiGLU, grouped-query attention, mixture of experts and hybrid layersneeds: Build a tiny GPT110 questions
- Running training jobs on GPUsFor engineersMemory math, mixed precision, gradient accumulation, multi-GPU parallelism, renting compute and keeping a long run healthyneeds: Build a tiny GPT110 questions
- Fine-tuning risks and safeguardsFor engineersForgetting, weakened safety, emergent misalignment, poisoned data and memorised secrets in tuned models, and the release checks that catch themneeds: When to fine-tune a model110 questions
Scenarios using this domain
Where to study
- OpenAI: Supervised fine-tuning guide (opens in a new tab)DocsFree
How a hosted provider expects training data to be formatted, sized and evaluated.
- Hugging Face TRL: SFT Trainer (opens in a new tab)DocsFree
How an open-source trainer reads conversational data and masks the loss.
- Chat templates (Hugging Face Transformers) (opens in a new tab)DocsFree
Shows how a model's chat template turns messages into the exact training text.
- LIMA: Less Is More for Alignment (Zhou et al.) (opens in a new tab)PaperFree
Evidence that about 1,000 carefully curated examples can shape a model's response style.
- Deduplicating Training Data Makes Language Models Better (Lee et al.) (opens in a new tab)PaperFree
Shows that removing duplicate text reduces memorisation and improves models.
- Extracting Training Data from Large Language Models (Carlini et al.) (opens in a new tab)PaperFree
Demonstrates that models can reproduce training text verbatim, including personal data.
- The Curse of Recursion: Training on Generated Data Makes Models Forget (opens in a new tab)PaperFree
Describes model collapse when models are trained repeatedly on model-generated data.
- EleutherAI lm-evaluation-harness (opens in a new tab)ToolFree
An open framework for running standard benchmarks to check general skills after tuning.
- The Ultra-Scale Playbook: Training LLMs on GPU Clusters (opens in a new tab)BookFree
An interactive guide to data, tensor, pipeline and ZeRO parallelism with measured trade-offs.
- Getting Started with Fully Sharded Data Parallel (FSDP) (opens in a new tab)DocsFree
A runnable FSDP setup that shows how parameters, gradients and optimizer state are sharded.
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (opens in a new tab)PaperFree
Breaks down the bytes per parameter for weights, gradients and Adam states, and how sharding removes the copies.
- Mixed Precision Training (opens in a new tab)PaperFree
The original paper on half-precision training with an fp32 master copy and loss scaling.