Train your own LLM from scratch — a step-by-step PyTorch repo covering the full pipeline: raw text → tokenized data → a transformer built from individual components (MLP, attention head, multi-head attention, transformer block, full model) → pretraining → text generation → post-training (SFT, reward modeling, DPO, PPO, GRPO).
Training data comes from The Pile, tokenized with tiktoken's r50k_base and stored in HDF5. A 13M-parameter model trains on a free Colab/Kaggle T4 and produces real words with roughly correct grammar. Larger configs (up to roughly 2B–8B depending on GPU) need cards like an RTX 3090/4090/5090 or A100 — a full compatibility table is included in the repo.
A separate notebook (sft_rlhf_guide.ipynb) walks through SFT and RLHF. The main repo also ships a script-based post-training suite (SFT → reward model → DPO/PPO → GRPO), hand-written in plain PyTorch with no trl, peft, or transformers.
MIT licensed, 10.8k+ GitHub stars.