| Least squares | |
|---|---|
| number of training samples | |
| number of features, which is also the number of parameters of the linear model | |
| feature vector of one sample, with isotropic Gaussian entries | |
| label of one sample, | |
| true coefficient vector of the linear model, with Gaussian prior | |
| label noise in , with variance | |
| data matrix, one row per sample | |
| ridge estimate , the posterior mean of | |
| prior variance of each coefficient; the ridge penalty is | |
| Recipes | |
| number of seed tokens available for training (200M tokens of DCLM in the main experiments) | |
| parameters per model (in billions in the fitted laws) | |
| number of ensemble members, independently trained copies that differ only in random seed | |
| every training choice other than the data (parameter count, epochs, learning rate, weight decay) | |
| the model trained on tokens with choices (Kim et al. write ) | |
| validation loss, cross-entropy per token on the held-out set | |
| best loss reachable from tokens with unlimited compute, | |
| probability that ensemble member gives a sequence | |
| the ensemble's probability of a sequence, | |
| Scaling laws | |
| fitted loss against parameter count, | |
| best loss against seed tokens, | |
| coefficient of a fitted scaling law such as (Kim et al. write ) | |
| exponent of a fitted scaling law such as (Kim et al. write ) | |
| asymptote of a fitted scaling law, the loss it approaches with unlimited parameters or data (Kim et al. write ) | |
| number of tokens the standard recipe needs to match a better recipe's loss; is the data multiplier | |
| coefficient of the standard recipe's data scaling law | |
| coefficient of the better recipe's data scaling law | |
| Transfer | |
| number of Python characters used for fine-tuning | |
| effective data transferred by pre-training, the extra Python a model of the same size trained from scratch would need to match the fine-tuned model, | |
| coefficient of the transfer law ( from text to Python) | |
| exponent of the fine-tuning data in the transfer law (0.18 from text to Python; Hernandez et al. write ) | |
| exponent of the parameter count in the transfer law (0.38 from text to Python; Hernandez et al. write ) | |
| pre-trained model read as a mixture of capabilities, | |
| capability of the pre-trained model (coding, writing and so on), a conditional distribution | |
| weight of capability for input , the probability that calls for capability (the lecture writes ) | |
| Constants | |
| coefficient of the regularized law at 200M tokens | |
| exponent of the regularized law at 200M tokens | |
| asymptote of the regularized law at 200M tokens, the recipe's estimated best loss with unlimited compute | |
| coefficient of the transfer law from text to Python | |
| exponent of the fine-tuning data in the transfer law from text to Python | |
| exponent of the parameter count in the transfer law from text to Python | |
Context. Compute-optimal pre-training assumes an unlimited stream of fresh tokens. A Chinchillathe compute-optimal recipe of Hoffmann et al. (2022): for a fixed training budget, train on about 20 tokens per parameter. Reading note: Chinchilla scaling-style recipe uses about 20 tokens per parameter, inference-focused models stretch to roughly 2,000, and the course's d8 trains about 30M parameters on 600M tokens. Each token appears once, so training loss on a fresh batch is an unbiased estimate of test loss and overfitting cannot occur. That infinite-data regime is ending. Web text grows about 3% a year while pre-training compute grows four- to five-fold a year (Villalobos et al., 2024; Sevilla and Roldán, 2024). Specialized domains such as agent trajectories, DNA, robotics, prices, and personal data are small from the start. Lecture 10 of Stanford CS 312 (Hashimoto and Kotha, Fall 2026) asks how to train when data is fixed and compute is abundant. It covers regularized pre-training first, then pre-training on related data followed by fine-tuning.
With fixed data and ample compute, repeating epochs and scaling up the model both overfit under standard defaults. Tuning weight decay far above the usual 0.1, up to 32 times higher, restores clean power-law scaling in model size. Recipes can then be compared by their scaling-law asymptote, the loss approached at unlimited compute. By that metric, an ensemble of independently trained models beats a single larger model. Ensembles of larger models match the standard recipe's best loss with roughly a fifth of the data, and sequence-level distillation packs most of that gain back into one model. When related data is available, pre-training multiplies a small fine-tuning set by orders of magnitude. Schedule handoff, data replay, and pre-training breadth then govern how well transfer holds up.
Lessons from least squares. Linear regression with samples, isotropicwith covariance equal to the identity, so every feature direction has the same variance Gaussian features, and noise variance gives two guiding principles, worked out further in the benign-overfitting notes. Past , gradient descent from zero converges to the minimum-norm interpolator, the coefficient vector of smallest Euclidean norm among those that fit every training label exactly. Reading notes: Double descent, Surprises in High-Dimensional Ridgeless Least Squares Interpolation. Its implicit bias pulls test error down again as grows, producing the second descent of double descenttest error that rises as the parameter count approaches the number of samples, where the fit just interpolates and its variance is largest, and falls again beyond it (Hastie et al., 2022). Reading note: Double descent. In a latent-variable model where features are noisy views of a low-dimensional signal, too few features underfit and too many fit the noise. Under a Gaussian prior , the posterior mean is ridge regression, for data matrix . Tuning the ridge penalty at each makes test error fall monotonically in (Nakkiran et al., 2021). The lecture carries both lessons to neural networks. Training may already bias models toward useful simplicity, and explicit regularization should be tuned until scaling turns monotone again.
Setting. The main pre-training experiments come from Kim et al. (2025), co-authored by the course instructors. They fix M tokens of DCLMDataComp for Language Models, a large filtered web-text corpus built for pre-training research web text with a 4M-token held-out validation set. On this pool they train Llama-style models of equal to 150M, 300M, 600M, and 1.4B parameters using AdamW, a cosine schedule decaying to zero, context length 4,096, and batches of 64 sequences. At 300M parameters, the model has 1.5 parameters per token, 30 times Chinchilla's ratio. Loss denotes validation cross-entropy per token. Collect every training choice besides the data (model size, epochs, learning rate, weight decay) into , and write for the trained model. The goal is the best loss reachable from tokens with unlimited compute: Assignment 6 runs the same program on d8 using a 30M-token pool of DNA from OpenGenome2, with a 19-token vocabulary, default 32 epochs, learning rate 0.003, and weight decay 3.2.
Repeating data and adding parameters both overfit. Under standard defaults, throwing compute at fixed data backfires. In Kim et al.'s figure for a 300M model at weight decay 0.1 and a tuned learning rate, validation loss drops from about 4.98 at 1 epoch to about 3.78 at 8 epochs. By 128 epochs it climbs back to about 4.96, even while training loss keeps falling. Scaling up the model with epochs and learning rate tuned at each size helps little. From 150M to 1.4B parameters, validation loss improves by less than 0.1, hitting its low of 3.75 at 600M while 1.4B does slightly worse. Overfitting with repeated epochs contradicts the data-constrained scaling law of Muennighoff et al. (2023), which predicts monotonically falling loss with epochs. Their study filtered out most overfitting runs before fitting its curve.
Heavy weight decay restores power-law scaling in model size. Jointly tuning learning rate, epochs, and weight decay by coordinate descent at each size changes scaling completely. Optimal weight decay climbs from 0.8 at 150M to 3.2 at 600M and 1.4B, up to 32 times the usual 0.1, while optimal epochs drop from 16 to 8. Validation loss then falls monotonically in (in billions) along a power law with an asymptote: The exponent near 1 far exceeds Chinchilla's 0.34 and matches the variance-limited regime of Bahri et al. (2021), where fixing one resource makes excess loss shrink inversely with the other. Because the curve is monotone, its asymptote estimates the recipe's infinite-compute limit, varying by at most 0.02 across three seeds. Heavy decay also reshapes the loss curve: loss falls slowly at first and drops steeply near the end, so runs can be judged only at schedule completion. Smaller batches improve per-token loss down to 64 sequences, the hardware minimum. It remains open whether heavy weight decay acts mainly as a regularizer or sets optimization speed through the weight norm. On d8, experiments test this by plotting loss against the product of learning rate and weight decay and comparing against Hyperballan optimizer wrapper that holds the norm of each weight matrix, and of its update, at a fixed value in place of weight decay (Wen et al., 2026). Reading note: Noisy quadratics and weight norms, which fixes weight norms without weight decay.
Independent ensembles reach a lower asymptote than larger models. Spending compute on multiple independent runs pushes the infinite-compute floor lower than regularizing one model. Train copies differing only in random seed (initialization and data order), and combine their sequence probabilities by averaging log-probabilities and renormalizing: Count the ensemble as parameters to reflect its -fold inference cost. Excess loss again falls roughly as , but toward a lower asymptote of 3.34 for 300M members as , below the single-model limit of 3.43. Three 300M models already beat 3.43, and two 300M models beat one 600M model. Either source of randomness alone, initialization or data order, captures most of the gain, with data order contributing slightly more.
Ensemble members should overfit more than the best single model. The best ensemble members are not the best standalone models. Halving each member's weight decay and doubling its epochs lets individual models overfit more, yet lowers the 300M ensemble's asymptote from 3.34 to 3.27. That rule held in every tested setting except one. Lecture 10 connects this to the multi-view picture of Allen-Zhu and Li (2023). When examples carry several predictive features and optimal prediction combines them all, a single model latches onto one view. Independent seeds capture different views, and averaging cancels their individual overfitting. Dropout cheaply imitates ensembling. Experiments on d8 test how much of the ensemble gain dropout recovers and whether the two compose.
| Recipe | Loss |
|---|---|
| Standard, best run | 3.75 |
| Regularized, | 3.43 |
| 300M ensemble, | 3.27 |
| Joint, | 3.17 |
Distillation compresses the ensemble, and self-distillation mimics it. Ensembles multiply inference cost by , so sequence-level distillationtraining a student on text sampled from a teacher model, in place of matching the teacher's per-token probabilities (Kim and Rush, 2016) packs their gain back into one model. Sample a large unprompted synthetic corpus from the teacher, then train a fresh student on a mix of real and synthetic tokens. Distilling an eight-member 300M ensemble (loss 3.32) into one 300M student reaches 3.36 at one-eighth the inference cost. That keeps 83% of the ensemble's gain over the best regularized 300M model (3.57), beats the regularized asymptote (3.43), and matches a four-member ensemble. Self-distillation, with the same architecture for teacher and student, also beats the teacher. A single 300M teacher at 3.71 produces a student at 3.43, ahead of both its teacher and the best regularized 300M model. Mixing in real data is essential: training on teacher samples alone degrades the student to 4.07, consistent with model collapsethe loss of diversity and quality when models are trained repeatedly on text that models generated. Allen-Zhu and Li read self-distillation as an implicit ensemble of teacher and student. Kim et al. (2026) support that view, finding that ensembles of self-distilled students approach nearly the same limit as ensembles trained on real data alone (3.32 against 3.31). Self-distillation therefore does not compose with ensembling, which suggests the two deliver the same benefit.
Validation gains carry over to benchmarks and continued pre-training. Kim et al. evaluated PIQA, SciQ, and ARC Easy only after locking in every recipe on validation loss. Lower validation loss carried straight to accuracy. The best ensemble beat the best unregularized model by over 9 percentage points on average, and distilled 300M students outperformed every other 300M model. The same toolkit helps continued pre-trainingfurther next-token training of an already pre-trained model on a narrower corpus, here math web text of Llama 3.2 3B on MegaMath-Web-Pro restricted to 4B of its 73B tokens. Smaller batches and repeated epochs raised the GSM8K, MATH, and MathQA average from 30.59 under reference hyperparameters to 35.82, though weight decay did not help here. An ensemble of eight such models reached 40.58, surpassing the 39.23 of the reference recipe trained on all 73B tokens for a 17.5-fold data-efficiency gain.
Pre-training multiplies small fine-tuning sets. When related pre-training data exists, transfer amplifies a small target corpus sharply. Hernandez et al. (2021) pre-train transformers on English text, fine-tune on characters of Python, and measure effective data transferred: the extra Python that a model of the same size trained from scratch would need to match the fine-tuned model's loss . In the small- regime, and the resulting data multiplier follow with non-embedding parameters . From text to Python, , , and . The multiplier peaks when fine-tuning data is scarce. In their Figure 1 example, a 40M model fine-tuned on characters matches training from scratch on roughly 1,000 times as much Python. Because , a 10-fold larger model is worth roughly 100 times more fine-tuning data. On a fixed small target set, from-scratch models plateau as grows, whereas pre-trained models keep improving at a gentler slope. Small models given abundant target data are the exception: pre-training leaves them worse than training from scratch, a failure the authors call ossification.
Why transfer works and how stronger base models learn faster. One conceptual picture writes a pre-trained model as a mixture of capabilities such as coding and writing, weighted by the probability that input invokes capability . Identifying the weights takes far fewer samples than learning a capability from scratch. In-context learning can be read as estimating those weights by Bayesian inference over tasks (Xie et al., 2021), and fine-tuning as adjusting them by gradient descent while keeping the other capabilities intact. Recent 2026 studies show that stronger base models also extract more from target data. To match retrieval-augmented generation on a reading-comprehension benchmark using synthetic document rewrites, a 14B Qwen3 model needs 102 times the original text against 813 times for a 1.7B model (Han et al., 2026). In chess, the reward gain per tenfold increase in RL compute grows with the number of pre-training tokens (Shen et al., 2026).
Schedule handoff, optimizer choice, and replay during fine-tuning. How pre-training ends governs how smoothly a model adapts. Under a decaying learning rate, most loss reduction happens during the decay phase. Sharing one decaying schedule across pre-training and fine-tuning would starve fine-tuning of step size, so the cleaner handoff uses a warmup-stable-decaya schedule with a short warmup, a long constant phase and a final decay to zero. Reading note: Learning-rate schedules and batch size schedule and runs its final decay on the target data. Because released checkpoints are already decayed and lack optimizer state, practitioners warm the learning rate back up. Pre-training loss alone also fails to predict transfer cleanly. Watts et al. (2026) find that flatter solutions from higher peak pre-training learning rates fine-tune with less forgetting even when pre-training loss is worse. Li et al. (2026) find that past a large enough pre-training data budget, Muonan optimizer that replaces each weight matrix's momentum by the nearest matrix with all singular values equal to 1, for momentum . Reading note: Muon beats AdamW in pre-training loss yet finishes worse after fine-tuning. Replay largely prevents catastrophic forgetting. In Marek et al. (2026), a 2M-parameter transformer trained sequentially on addition, reversal, sorting, and modular addition forgets prior tasks without replay. Mixing in samples generated by the current model keeps all four intact. Once replay is used, residual forgetting tracks capacity. Small models saturated by many tokens per parameter overwrite old knowledge when absorbing new data, whereas larger models trained at lower token-to-parameter ratios adapt more easily.
Out-of-distribution robustness comes from diverse pre-training. Across many models and interventions, shifted test accuracy is closely linear in in-distribution accuracy on a probit, the inverse of the standard normal distribution function applied to an accuracy, which stretches accuracies near 0 and 1 apart scale (Recht et al., 2019; Miller et al., 2021). Most techniques therefore lift both accuracies along one fixed line. Pre-training breaks that line. On iWildCam, a benchmark of camera-trap photos from unseen locations scored by macro F1, ImageNet-pretrained models sit on a separate, steeper line. At the scores they reach, they beat what the from-scratch line predicts out of distribution. Across broad comparisons of robustness methods, pre-training on more diverse data remains the most reliable lever (Fang et al., 2022).
Limits. The data-constrained pre-training results come from one corpus, one recipe, and one group's runs, mostly at 200M tokens. Each asymptote extrapolates from four or five points, and the data scaling laws from four asymptotes. The 1.4B model also used fewer layers than the 600M model (16 versus 24), a framework preset that the authors suggest may have aggravated its overfitting. Ensembles multiply inference compute by unless distilled.
Terms
- : the best loss reachable from tokens with unlimited compute
- standard recipe
- more epochs and more parameters at weight decay 0.1; both eventually overfit
- regularized recipe
- learning rate, epochs and weight decay tuned jointly per size; best weight decay 0.8 to 3.2; loss
- asymptote as a metric
- compare monotone recipes by of their scaling law, not at one compute budget
- ensemble
- average log-probabilities of seeds; excess loss about ; lower asymptote than
- member settings
- half the weight decay and twice the epochs of the best single model
- data efficiency
- , the extra data the standard recipe needs; when agree
- sequence-level distillation
- train a student on teacher samples mixed with the real data; 8-ensemble into one 300M model keeps 83% of the gain
- self-distillation
- student of the teacher's size beats it, if real data is mixed in; same benefit as ensembling
- effective data transferred
- ; multiplier shrinks as grows
- ossification
- pre-training that hurts a small model when target data is plentiful
- replay
- mixing old (or self-generated) data into fine-tuning; largely prevents forgetting
- accuracy on the line
- shifted-set accuracy is about linear in original accuracy (probit scale); pre-training changes the line
Sources
Lecture 10, “Generalization 1: Regularization and fine-tuning” (Nov 12, 2026), of Stanford CS 312 Deep Learning Alchemy, Fall 2026. Taught by Tatsunori Hashimoto and Suhas Kotha; course staff Kaiyue Wen and Tristan Thrush (CAs).
Course site Lecture slides Assignment Assignment code
The lessons, experiments, figures and quiz problems in this note are the course's, shown here with the instructors' permission.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Lecture 10: Generalization 1: Regularization and fine-tuning. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Assignment 6: Generalization. Stanford, Fall 2026.
- Konwoo Kim, Suhas Kotha, Percy Liang, and Tatsunori Hashimoto. Pre-training under infinite compute. arXiv preprint, 2025.
- Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling Laws for Transfer. arXiv preprint, 2021.
- Trevor Hastie, Andrea Montanari, Saharon Rosset, and Ryan J. Tibshirani. Surprises in High-Dimensional Ridgeless Least Squares Interpolation. Annals of Statistics, 2022.
- Konwoo Kim, Suhas Kotha, Yejin Choi, Tatsunori Hashimoto, Nick Haber, and Percy Liang. Data-efficient pre-training by scaling synthetic megadocs. arXiv preprint, 2026.
- Seungju Han, Konwoo Kim, Chanwoo Park, Benjamin Newman, Suhas Kotha, Jaehun Jung, James Zou, and Yejin Choi. Synthetic Mixed Training: Scaling Parametric Knowledge Acquisition Beyond RAG. arXiv preprint, 2026.
- Martin Marek, Dongkyu Cho, Shikai Qiu, Rumi Chunara, Pavel Izmailov, and Andrew Gordon Wilson. Forgetting in Language Models: Capacity, Optimization, and Self-Generated Replay. arXiv preprint, 2026.
Connected notes
- Stein's paradox and the James-Stein estimatorBenign overfitting · Shrinkage toward a common point
Because exceeds by about on average, the best factor is about , and the James-Stein version beats the raw observation at every once .
- Understanding deep learning requires rethinking generalizationGeneralization bounds · Implicit bias of the optimizer
SGD started at zero stays in the row space of the data, so on a linear model it returns the minimum-norm interpolant, which reaches 1.2% test error on raw MNIST with no regularization.
- Transformers Learn In-Context by Gradient DescentIn-context learning · Hyperparameters set what the loss leaves free
In one-layer linear self-attention, the loss depends only on the product and leaves the scale split between the label-value scalar and the key-query matrix free; gradient flow conserves , which pins the limit on the hyperbola of equivalent global minima.
- Maximal update parametrizationLazy training and feature learning · Predicting large runs from small ones
Under P the optimal learning rate, initialization scale and multipliers are nearly stable in width, so they can be tuned on a small proxy and copied, and a 40M proxy beat the published 6.7B GPT-3 at a tuning cost of 7% of its pretraining cost.