Skip to content

A straightforward method for training your LLM, from downloading data to generating text.

docs(pipeline): link each stage page to its modern variants (architecture, Muon, LoRA, IPO/SimPO, GRPO follow-ups)

FareedKhan-dev1acb34f621aa
diff --git a/docs/02_pretraining.md b/docs/02_pretraining.md
index 90c5663..91cf985 100644
--- a/docs/02_pretraining.md
+++ b/docs/02_pretraining.md
@@ -44,6 +44,10 @@ The base config lives in [`config/post_training_config.py`](https://github.com/F
(`BaseModelConfig`): `n_embed=1024, n_head=16, n_blocks=24, context_length=1024` → ~406M params. The
context length is bumped to 1024 (vs the original 512) so GSM8K reasoning chains fit later.
+Set `"arch": "modern"` in `configs/base.json` to pretrain (and post-train) the modern decoder
+instead, and `--optimizer muon --lr_schedule wsd` to try the newer optimizer and schedule. See
+[the modern model](modern/README.md) and [optimizers and schedules](modern/optimizers.md).
+
## The training step
The heart of [`pretrain_base.py`](https://github.com/FareedKhan-dev/train-llm-from-scratch/blob/main/scripts/pretrain_base.py) is a gradient-accumulation loop under
diff --git a/docs/03_sft.md b/docs/03_sft.md
index b422f8f..0ba007a 100644
--- a/docs/03_sft.md
+++ b/docs/03_sft.md
@@ -80,6 +80,9 @@ torchrun --standalone --nproc_per_node=2 scripts/train_sft.py # both GPUs
# tune: --lr 1e-5 --epochs 3 --batch_size 16
```
+To fine-tune only small low-rank adapters instead of every weight, add `--lora_rank 16`; see
+[LoRA](modern/lora.md).
+
## What the numbers mean
- **train_loss / ppl**: masked cross-entropy (and its perplexity) over assistant tokens; should drop
diff --git a/docs/05_dpo.md b/docs/05_dpo.md
index 6b86c39..f92a882 100644
--- a/docs/05_dpo.md
+++ b/docs/05_dpo.md
@@ -5,7 +5,8 @@ Direct Preference Optimization is the shortcut around RLHF: instead of training
running an RL loop, DPO optimizes the policy *directly* on preference pairs, using a frozen copy of the
SFT model as a reference anchor. No reward model, no rollouts, no value function: just one clean loss.
I also implemented two popular variants behind a `--loss_type` flag: **ORPO** (reference-free) and
-**KTO** (works from a desirable/undesirable signal).
+**KTO** (works from a desirable/undesirable signal). IPO, SimPO and conservative DPO are there too;
+[Preference optimization](modern/preference.md) compares all of them.
For the sequence log-probability notation used here, see
[Objectives, Losses & Perplexity](foundations/objectives.md).
diff --git a/docs/07_grpo.md b/docs/07_grpo.md
index 60a537b..e6d81fa 100644
--- a/docs/07_grpo.md
+++ b/docs/07_grpo.md
@@ -77,6 +77,9 @@ rewards = torch.tensor([reward_gsm8k(responses[i], golds[i]) for i in range(len(
adv = group_advantages(rewards, G)
```
+The 2025 follow-ups to GRPO (Dr. GRPO, DAPO's clip-higher and dynamic sampling, GSPO's
+sequence-level ratio) are flags on this same trainer; see [RL for reasoning](modern/rl_reasoning.md).
+
## Run it
```bash