BurnyCoder's picture
Explain why third derivatives could favor a wider low-loss neighborhood
0366ca1 verified
|
Raw History Blame
22.6 kB

Third derivatives in language-model training

Sepp Hochreiter and Jürgen Schmidhuber proposed that among models that fit the training data equally well, those in flatter minima may generalize better to unseen data. In a flat minimum, many nearby weight settings still fit. If some weights can be rounded more coarsely without spoiling the fit, a good predictor can take fewer bits to describe under a fixed encoding. Their minimum-description-length argument links that shorter description to a lower risk of overfitting. Hochreiter and Schmidhuber, Flat Minima (1997), §1

Earlier work tested penalties on the trace of the loss Hessian, the sum of second derivatives along the weight coordinates. Sankar et al. added a layerwise trace penalty to the training loss of image classifiers. Liu, Yu and Lin proposed a stochastic trace penalty and reported WikiText-2 experiments with LSTM and GRU language models. Zhang, Li and Ju approximated a trace penalty with symmetric weight perturbations when fine-tuning GPT-2 for question answering. Sankar et al., Table 1 · Liu, Yu and Lin, §5.2 · Zhang, Li and Ju, Table 5

Why third derivatives? Two minima can have the same small curvature at the bottom, yet one can steepen much sooner. The third derivatives of next-token loss measure how its Hessian changes as the weights move. The training penalty estimates their sum of squares, so rapid changes of either sign carry a cost. If curvature starts small and changes slowly throughout a neighborhood, the weights can move farther while loss stays low. If the penalty grows toward the edge of that region, its gradient can also oppose movement out of it. Worked examples and width bound · Taylor remainder, equation 22

The study tests whether this penalty improves prediction on unseen tokens compared with ordinary AdamW and Hessian-trace regularization at equal training-token counts. It trains a TinyStories decoder from scratch and fine-tunes Pythia-410M’s low-rank attention adapters on research abstracts. Study design

Can the penalty favor a wider minimum?

A minimum is wide if the weights can move a long way before the loss rises by a chosen amount. Near a smooth minimum, the Hessian trace predicts the average loss increase from a small nudge in a uniformly random direction. Basin width, Definition 1 · Hessian and random perturbations, equation 4

The penalty can help weights stay near a flat bottom. For $L(w)=w^4$, nudging the weight to either side makes the penalty rise, so a small descent step pulls it back. A steep quadratic such as $L(w)=100w^2$ has constant curvature and receives zero third-derivative penalty everywhere. Worked examples

In the language models, an active update measures curvature change for the next-token cross-entropy of two text windows, with respect to all decoder weights for TinyStories or only the adapter weights for Pythia. Differentiating this penalty gives AdamW a fourth-derivative contribution. The registered comparison tests prediction on held-out tokens at equal training-token counts. Whether the models reach wider minima is a separate hypothesis. The proposed late-training experiment would measure width in fixed weight coordinates, since rescaling weights can change measured sharpness while preserving predictions. Training update · Preregistration · Follow-up plan · Dinh et al.

One-weight loss and penalty curves. At the asymmetric minimum the trace pushes left and the third-derivative penalty pushes right. In the quartic both pull displaced weights back. In the steep quadratic both penalty curves are constant.

Analytic examples. The circles mark the ordinary loss minima. Arrows show downhill directions for the two penalties. Each panel has its own vertical scale.

Flat minima, Hessians and third derivatives in earlier work

Setting What the researchers used the derivatives for Original papers and projects
Origin of flat-minimum search Hochreiter and Schmidhuber searched for connected regions of weights where training error changes little. Their journal paper describes a search algorithm using second derivatives. Original NeurIPS paper, 1994 · Flat Minima, Neural Computation, 1997
Hessian penalties in language models Zhang, Li and Ju approximate a Hessian-trace penalty with symmetric weight perturbations when fine-tuning GPT-2 on CommonsenseQA and StrategyQA. Liu, Yu and Lin propose a signed trace objective and report WikiText-2 LSTM and GRU experiments. GPT-2 experiments, Table 5 · Noise stability optimization code · Recurrent LM penalty, §5.2
Other uses of Hessians in LLMs Sophia uses stochastic curvature estimates to precondition GPT training updates. Liu et al. measure Hessian trace and study the downstream behavior of pretrained language models. Sophia paper · Sophia code · Language-model flatness study
Hessians outside language modeling Layerwise Hessian-trace penalties have been tested in image classification. Reparameterization studies explain why a curvature measurement alone cannot establish predictive generalization. Sankar et al. · Dinh et al.
Third derivatives in language models Yang et al. approximate third derivatives of the training loss with respect to weights to predict what happens when training batches are reordered. McGee et al. fit a cubic along a fine-tuning update to select a step size. Zhang and Wang test cubic corrections along hidden-activation interventions in a frozen model and report failures for large perturbations. FUT++, §5.1 and Appendix A.1 · Step selection, Appendix C.1.1 · Activation patching, §4 and supplement
Third derivatives outside LLMs Wolinski projects third derivatives of the weight-space loss to regularize a local optimization model. Lellmann et al. study third spatial derivatives of terrain surfaces. Duchon gives the general squared-derivative roughness formulation. Projected parameter derivatives · Third-order terrain reconstruction · Spline roughness
Third derivatives in image classifiers Grad-CAM++ uses diagonal third derivatives of a class score with respect to convolutional feature activations to locate image regions that contribute to a prediction. Chattopadhyay et al., equation 10 · Authors’ implementation

Two independent random sign vectors estimate the squared Frobenius norm of the minibatch third derivative, including mixed partials between different weights. Estimator derivation · Duchon · Bujanović and Kressner

The protocol and run matrix were published before model execution. The scores, comparisons and continuations below are regenerated from each run’s raw records. Preregistration · Run matrix · Literature · State of the art · Progress

A same-probe check on pretrained Pythia found that single-precision arithmetic materially changed the third-order training gradient. The first adapter pilot is archived as a numerical diagnostic. The corrected adapter arms evaluate derivatives in double precision while ordinary training and prediction use the GPU. Pre-test precision amendment · Full-model numerical checks

Explore the results · Paper · Run ledger

Recorded 19 runs, including 18 with a completed summary.

TinyStories. Awaiting paired test results (0 of 8 full-horizon training triplets).

Research abstracts. Awaiting paired test results (0 of 8 full-horizon training triplets).

TinyStories development pilot. At 2,097,152 training targets, the third-order run recorded 0.00004 nats per target token lower against Ordinary AdamW, 0.00024 nats per target token lower against Trace + third derivative, 0.00175 nats per target token lower against Squared Hessian norm, 0.00032 nats per target token lower against Randomized gradient signs, 0.00034 nats per target token lower against Hessian trace. These are single-seed descriptions using strengths selected on development.

Research abstracts development pilot. At 65,536 training targets, the third-order run recorded 0.00091 nats per target token higher against Ordinary AdamW. These are single-seed descriptions using initial pilot strengths.

Measured scores

Stage Phase Method Ratio Tokens/run Runs Median dev NLL Median test NLL
Research abstracts control Initial checkpoint 0.000 0 1 3.2517 —
Research abstracts control Unigram 0.000 0 1 7.3306 —
Research abstracts pilot Ordinary AdamW 0.000 65,536 1 3.1139 —
Research abstracts diagnostic Third derivative 0.030 65,536 1 3.1168 —
Research abstracts pilot Third derivative 0.030 65,536 1 3.1149 —
Research abstracts pilot Hessian trace 0.010 65,536 1 3.1140 —
TinyStories control Initial checkpoint 0.000 0 1 8.3437 —
TinyStories control Unigram 0.000 0 1 6.0036 —
TinyStories pilot Ordinary AdamW 0.000 2,097,152 1 3.8770 —
TinyStories pilot Trace + third derivative 0.010 2,097,152 1 3.8772 —
TinyStories pilot Squared Hessian norm 0.030 2,097,152 1 3.8787 —
TinyStories pilot Randomized gradient signs 0.010 2,097,152 1 3.8773 —
TinyStories pilot Third derivative 0.010 2,097,152 1 3.8769 —
TinyStories pilot Third derivative 0.030 2,097,152 1 3.8778 —
TinyStories pilot Third derivative 0.100 2,097,152 1 3.8827 —
TinyStories pilot Hessian trace 0.010 2,097,152 1 3.8773 —
TinyStories pilot Hessian trace 0.030 2,097,152 1 3.8802 —
TinyStories pilot Hessian trace 0.100 2,097,152 1 3.8979 —

Parameter-space computation graph

Development NLL

Recorded predictions

First registered checkpoint and sample in run-ID order per stage and method. All continuations

Research abstracts · Initial checkpoint · control, seed 0

Recorded sample

Prompt

One of the central objectives of contemporary neuroimaging research is to
create predictive models

Reference continuation

 that can disentangle the connection between patterns
of functional connectivity across the entire brain and various behavioral
traits. Previous studies have shown that models trained to predict behavioral
features from the individual's functional

Model continuation

 that will be used by neuroscience researchers to
identify cases of a disease or to select appropriate therapeutic intervention.

The research of Peter Seager and colleagues has demonstrated that the brain
can
Research abstracts · Unigram · control, seed 0

Recorded sample

Prompt

One of the central objectives of contemporary neuroimaging research is to
create predictive models

Reference continuation

 that can disentangle the connection between patterns
of functional connectivity across the entire brain and various behavioral
traits. Previous studies have shown that models trained to predict behavioral
features from the individual's functional

Model continuation

 neural. is novel In used describe sacrific the theruction
 To their
zo than chronic current the the factor an( simultaneouslyrelated
exchange
purpose,) was} standards
 of
 radio.
Research abstracts · Ordinary AdamW · pilot, seed 0

Recorded sample

Prompt

One of the central objectives of contemporary neuroimaging research is to
create predictive models

Reference continuation

 that can disentangle the connection between patterns
of functional connectivity across the entire brain and various behavioral
traits. Previous studies have shown that models trained to predict behavioral
features from the individual's functional

Model continuation

 that will accurately predict the behavior of
patient-specific neurological disorders such as epilepsy. In this paper, we
present a novel dataset of EEG data recorded from children with focal
subcortical epilepsy
Research abstracts · Third derivative · pilot, seed 0

Recorded sample

Prompt

One of the central objectives of contemporary neuroimaging research is to
create predictive models

Reference continuation

 that can disentangle the connection between patterns
of functional connectivity across the entire brain and various behavioral
traits. Previous studies have shown that models trained to predict behavioral
features from the individual's functional

Model continuation

 that will accurately predict the behavior of
patient-specific neurological disorders such as epilepsy. In this paper, we
present a novel dataset of EEG data recorded from children with focal
subcortical epilepsy
Research abstracts · Hessian trace · pilot, seed 0

Recorded sample

Prompt

One of the central objectives of contemporary neuroimaging research is to
create predictive models

Reference continuation

 that can disentangle the connection between patterns
of functional connectivity across the entire brain and various behavioral
traits. Previous studies have shown that models trained to predict behavioral
features from the individual's functional

Model continuation

 that will be used to assess the cognitive
performance of neurological disorders. We will focus on three major areas:
(1) the nervous system as a whole, (2) the brain regions that
TinyStories · Initial checkpoint · control, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 break painted pleaseerp gif neat lead bro comfort rid shr search impressedosairs try ants oss note daughter woodLater rest independent stars stonesiver mixaybe Le spoon readMe fingersiew embar bached mail
TinyStories · Unigram · control, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 it said her mom girlan he said that fell flut back's hard. a them into work protectt hug?" his and little teeth "What sky some Timmy and on 
 down As's
 very
TinyStories · Ordinary AdamW · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.
TinyStories · Trace + third derivative · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.
TinyStories · Squared Hessian norm · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.
TinyStories · Randomized gradient signs · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.
TinyStories · Third derivative · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.
TinyStories · Hessian trace · pilot, seed 0

Recorded sample

Prompt

Once upon a time, there was a clever little dog named Max. Max loved

Reference continuation

 to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.

Max went to his friend, the wise old owl,

Model continuation

 to play on the cat.

Reproduce the study

Use Python 3.12, uv, and an NVIDIA GPU for the full study. Install with uv sync --locked, run uv run thirdloss verify, then use uv run thirdloss study. In another terminal run uv run thirdloss dashboard --port 18765 for live accuracy and loss. Regenerate the paper, plots and score tables with uv run thirdloss report. Setup, checkpoints and CLI · Document splits · Model collection

The pipeline pins the source texts, splits by document, learns the stories tokenizer using training documents, and freezes the evaluation definition. Identical initializations and document orders pair the competing objectives. The smaller model trains all weights. The pretrained model trains only attention adapters. Examine both improvement and deterioration across seeds and both computational budgets. TinyStories · Pythia · Common Pile · LoRA

Milestones

  • Publish the protocol, references and analysis decisions.
  • Verify the scalar objective and its training gradient on analytical functions and a small Transformer.
  • Train the pilot, publish throughput and establish feasibility on the local GPU.
  • Complete controls, development selection, paired confirmations and a reproducible report.
  • Test whether adding the third-derivative penalty late in Hessian-trace training helps the model stay in a wider low-loss region. Exploratory plan and rationale