Into the Terrain of Giants: A Loss-Landscape Tour of Pre-training, Safety, and Forgetting in LLMs

Authors: Wang from Japan AI research team
For: researchers who live in LoRA configs, RLHF logs and jailbreak prompts
1. Turning Trillions of Dimensions into a 2-D Map
Training an LLM is nothing more—and nothing less—than hunting for a low point on a loss surface in \mathbb{R}^d, where d can easily be in the trillions.
To see that surface we borrow the classic trick from Li et al. (2018):
- Pick a reference point
\theta^*(your current checkpoint). - Choose two random but filter-normalized directions
\delta,\etaso that scale-invariance tricks don’t fool us. - Plot
f(\alpha,\beta)=L(\theta^*+\alpha\delta+\beta\eta).
The resulting contour lines are our “terrain map.” Below, we use it to read three stories: safety, pre-training vs. fine-tuning, and catastrophic forgetting.
2. Safety Has Its Own Private Basin
Peng et al. (NeurIPS 2024) replace the usual cross-entropy with Attack Success Rate (ASR) and draw the landscape again.
What pops out is a shape never seen in accuracy plots:
- Capability landscape: gentle hill, performance tapers off gradually.
- Safety landscape: a flat mesa (Safety Basin) surrounded by a cliff.
Inside the mesa ASR ≈ 0 %; step outside and it jumps to 100 %.
| Model | VISAGE score (basin “depth”) | ASR after 10-shot harmful LoRA |
|---|---|---|
| LLaMA2-7B-chat | 85.32 | 0 % → 90 % |
| Vicuna-7B-v1.5 | 73.26 | 5 % → 95 % |
Take-aways
- Malicious fine-tuning is an optimizer pushing weights over the cliff.
- Mixing harmful + safe data 1:1 keeps the trajectory inside the mesa—ASR stays low.
- VISAGE gives a pre-flight safety meter: compute once, know how far you can fine-tune before you fall.
3. Russian-Doll Basins: Pre-training Digs the Big Hole, Fine-Tuning Carves the Small Ones
Chen et al. (2025) zoom out and see nested basins:
- Pre-training drops the model into a broad foundational basin—good at everything a little.
- Fine-tuning chisels smaller, task-specific basins (coding, math, safety) inside it.
They then split directions into two regimes:
| Direction type | Landscape shape | Interpretation |
|---|---|---|
| Most-case (random Gaussian) | Wide basin | Ordinary LoRA/SFT rarely escapes → benign forgetting. |
| Worst-case (optimized ascent) | Vertical wall | 10-shot harmful data can be crafted exactly along this wall → instant jailbreak. |
They also give a certified radius: if the fine-tuning step||\theta_{\text{sft}}-\theta_0||_2 < \sigma\sqrt{2\pi}\,\Phi^{-1}(p_A), performance drop is provably bounded.
p_A:clean performance of the original model inside the σ-basin (0–1).Φ: standard normal CDF, monotonically increasing ⇒ right-hand side degrades linearly with ||Δθ||₂.
On a 0.5 B model their Gaussian-Augmented Optimizer enlarges σ five-fold in four epochs; scaling to 7 B+ awaits engineering tricks.
4. Sharp Minima Forget; Flat Minima Remember
Li et al. (EMNLP 2024) translate catastrophic forgetting into landscape sharpness:
- A model in a sharp valley slips off the ridge after one gradient step → forgets.
- A model in a flat plain drifts gently → remembers.
They plug Sharpness-Aware Minimization (SAM) into the fine-tuning loop to actively flatten the surface:
| Task sequence | MMLU drop (plain Adam) | MMLU drop (w/ SAM) |
|---|---|---|
| Alpaca→Open-Platypus | -6.7 % | +7.0 % (negative drop!) |
| Alpaca→MetaMath | -6.8 % | +3.8 % |
SAM is orthogonal to rehearsal or weight-averaging—stack them for even better retention.
5. Three Contour Maps for Practitioners
| Goal | Tool / Recipe | Read from the Map |
|---|---|---|
| Stay safe after fine-tune | VISAGE audit + 1:1 safe/harmful mix | Safety basin depth & width |
| Avoid forgetting | Add SAM(Sharpness-Aware Minimization) to your LoRA script | Flatness around current weights |
| Boost overall robustness | Pre-train with Gaussian-Augmented Optimizer | σ-basin radius |
6. From Black-Box to Topographic Map
Loss-landscape analysis turns LLM behaviors into visible topography:
- Is the model safe? Check if it’s still inside the Safety Basin.
- Will it forget? Check if the valley is flat enough.
- How far can I fine-tune? Read the σ-basin radius.
“Bring a good map, and even trillion-parameter mountains become walkable.”
References
- Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein.
Visualizing the loss landscape of neural nets.
In Advances in Neural Information Processing Systems (NeurIPS), 2018.
- Sheng Yun Peng, Pin-Yu Chen, Matthew Hull, and Duen Horng Chau.
Navigating the Safety Landscape: Measuring Risks in Finetuning Large Language Models.
In Advances in Neural Information Processing Systems (NeurIPS), 2024.
- Huanran Chen, Yinpeng Dong, Zeming Wei, Yao Huang, Yichi Zhang, Hang Su, and Jun Zhu.
Understanding Pre-training and Fine-tuning from Loss Landscape Perspective.
arXiv preprint arXiv:2505.17646, 2025.
- Hongyu Li, Liang Ding, Meng Fang, and Dacheng Tao.
Revisiting Catastrophic Forgetting in Large Language Model Tuning.
In Findings of the Association for Computational Linguistics: EMNLP, 2024.
- Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur.
Sharpness-aware minimization for efficiently improving generalization.
In International Conference on Learning Representations (ICLR), 2021.
⭐️JAPAN AI is looking for people to work with us!
株式会社ジーニー JAPAN AI の求人一覧hrmos.co