Estimating the LLC

SLT Lecture 4B

Miguel Donaire Arcas-Sariot

24 November 2026

So far today

Take a small region U around a local minimum w^* of the population loss. Its free energy is

F_n(U)=-\log\int_U e^{-nL_n(w)}\,\varphi(w)\,\mathrm dw .

Watanabe’s free energy formula:

\boxed{F_n(U)=nL_n(w^*)+\lambda\log n-(\mu-1)\log\log n+O_p(1)}

  • \lambda=\lambda(w^*) is the local learning coefficient.
  • \mu=\mu(w^*) is the local multiplicity.

Can we measure it?

As we just proved, the LLC (together with the multiplicity) determines the soft inductive bias of Bayesian inference.

But we know it in closed form only in a few toy settings.

How do we estimate it for a trained neural network?

Whatever we do must respect two constraints:

  • Scale. Up to 10^8 parameters and millions of data points: nothing that integrates over parameter space, or needs many passes over the data.
  • Cost. The estimate should cost no more than a short training run.

We follow Lau, Furman, Wang, Murfet and Wei (2025), who build on Watanabe (2013).

Can we read the LLC off the free energy?

The idealised estimator

The LLC is the coefficient of \log n, so solve the free energy formula for it:

\begin{aligned} \hat\lambda^{\mathrm{ideal}}(w^*) &=\frac{F_n(U)-nL_n(w^*)}{\log n}\\[0.5em] &\htmlClass{fragment}{{}=\lambda(w^*)-(\mu-1)\frac{\log\log n}{\log n} +O_p\Big(\frac{1}{\log n}\Big) \;\xrightarrow[\;n\to\infty\;]{}\;\lambda(w^*).} \end{aligned}

It is correct in the limit, and nL_n(w^*) costs only one pass over the data.

The problem is F_n(U).

Three obstacles

F_n(U)=-\log\int_U e^{-nL_n(w)}\,\varphi(w)\,\mathrm dw

  1. The method has to scale. Under our two constraints, we must use efficient, but less accurate, sampling methods driven by minibatch gradients.
  2. F_n(U) is a normalising constant. These sampling methods are designed to return averages under a distribution, not its normalising constant.
  3. U is a hard constraint. This pairs badly with gradient-based samplers: the gradient of the indicator function is 0 wherever it is defined.

Each obstacle will require one approximation.

How do we measure the free energy from averages?

Add a temperature

From here on, U is fixed: the small region around w^* from before. Put an inverse temperature \beta\geq0 in the exponent:

F_n(\beta)=-\log\int_U e^{-n\beta L_n(w)}\varphi(w)\,\mathrm dw .

The tempered posterior on U is

\pi_\beta(w)\propto e^{-n\beta L_n(w)}\varphi(w),

with averages written \E^\beta_w[\,\cdot\,].

  • \beta=1 is the posterior: F_n(1)=F_n(U).
  • \beta=0 is the prior: F_n(0)=-\log\int_U\varphi.

Its derivative is an average

Differentiate under the integral sign (exercise):

F_n'(\beta)=\E^\beta_w\big[nL_n(w)\big],\qquad F_n''(\beta)=-\operatorname{Var}^\beta_w\big[nL_n(w)\big]\leq0 .

If we normalise \varphi on U, then F_n(0)=-\log\int_U\varphi=0. So we can recover F_n(1) by integrating from 0 to 1. This is thermodynamic integration:

\boxed{F_n(U)=F_n(1)=\int_0^1\E^\beta_w\big[nL_n(w)\big]\,\mathrm d\beta}

So we can now obtain the free energy using only averages over the tempered posterior.

However, each temperature gives a different average. We cannot calculate all of them.

One temperature is enough

The integrand \beta\mapsto\E^\beta_w[nL_n(w)] is continuous and decreasing: its derivative is minus a variance.

So it takes its mean value exactly once. There is a unique \beta_{\mathrm{opt}}\in(0,1) with

F_n(U)=\E^{\beta_{\mathrm{opt}}}_w\big[nL_n(w)\big].

Watanabe (2013), Theorem 3; exercise.

But \beta_{\mathrm{opt}} depends on the data and on the unknown truth.

Can we guess it?

A good ansatz for the optimal temperature

As in the previous lectures, replace L_n by the population loss, with K=L-L(w^*):

\E^\beta_w\big[nK(w)\big] =\frac{\int_U nK\,e^{-n\beta K}\,\varphi\,\mathrm dw}{\int_U e^{-n\beta K}\,\varphi\,\mathrm dw} =\frac{\int_0^\infty nt\,e^{-n\beta t}\,v_\varphi(t)\,\mathrm dt}{\int_0^\infty e^{-n\beta t}\,v_\varphi(t)\,\mathrm dt}.

Two Laplace transforms of the density of states, at n\beta in place of n.

Insert v_\varphi(t)\sim a\,t^{\lambda-1} (take \mu=1), and substitute s=n\beta t:

\E^\beta_w\big[nK(w)\big]\;\sim\;\frac1\beta\cdot \frac{\int_0^\infty s^{\lambda}\,e^{-s}\,\mathrm ds}{\int_0^\infty s^{\lambda-1}e^{-s}\,\mathrm ds} =\frac1\beta\cdot\frac{\Gamma(\lambda+1)}{\Gamma(\lambda)} =\frac{\lambda}{\beta}.

\boxed{\E^\beta_w\big[nK(w)\big]\;\longrightarrow\;\frac{\lambda}{\beta} \qquad\text{as }n\beta\to\infty}

A good ansatz for the optimal temperature

To leading order, with the population loss:

F(n)\approx nL(w^*)+\lambda\log n,\qquad \E^\beta_w\big[nL(w)\big]\approx nL(w^*)+\frac{\lambda}{\beta}.

The two agree when \lambda/\beta=\lambda\log n:

\boxed{\beta^*=\frac{1}{\log n}}

The unknown \lambda cancels: the same temperature works for every model.

And we can solve for the LLC: \;\lambda\approx n\beta^*\big(\E^{\beta^*}_w[L(w)]-L(w^*)\big). An average, not a normalising constant.

Does the guess work?

This holds in general:

\beta_{\mathrm{opt}}=\frac{1}{\log n}\bigg(1+O_p\Big(\frac{1}{\sqrt{\log n}}\Big)\bigg).

Watanabe (2013), Corollary 2.

With data: Watanabe’s theorem

Watanabe (2013, Theorem 4) gives the stochastic analogue of the result we just obtained. On the whole parameter space, with a global minimum w_0, take \beta=\beta_0/\log n:

\E^\beta_w\big[nL_n(w)\big]=nL_n(w_0)+\frac{\lambda\log n}{\beta_0} +U_n\sqrt{\frac{\lambda\log n}{2\beta_0}}+O_p(1),

where U_n has mean zero and converges in law to a Gaussian.

At \beta_0=1 this average is the WBIC. Its two leading terms are those of F_n, and for regular models it equals the BIC up to o_p(1).

How do we stay near the minimum?

Localise and temper

The localised tempered posterior around w^*:

\pi_{\beta,\gamma}(w\mid w^*)\;\propto\; \exp\Big(-n\beta L_n(w)-\frac{\gamma}{2}\,\|w-w^*\|^2\Big).

By a direct extension of Watanabe’s proof (Lau et al. 2025), at \beta^*=1/\log n:

\E^{\beta^*,\gamma}_{w\mid w^*}\big[nL_n(w)\big] =nL_n(w^*)+\tilde\lambda(w^*)\log n +U_n\sqrt{\frac{\tilde\lambda(w^*)\log n}{2}}+O_p(1).

Here \tilde\lambda(w^*) is the coefficient of \log n in the free energy with the soft wall.

Conjecture (Lau et al.): \tilde\lambda(w^*)=\lambda(w^*), under conditions on \gamma. Experiments support it.

The LLC estimator

Keep the first two terms, and solve for the coefficient of \log n:

\boxed{\hat\lambda(w^*)=n\beta^*\Big(\E^{\beta^*,\gamma}_{w\mid w^*}\big[L_n(w)\big]-L_n(w^*)\Big)} \qquad\beta^*=\frac{1}{\log n}

How to read it:

  1. Perturb w^*, in the directions that the tempered loss and the spring allow.
  2. Average the increase in loss.
  3. Rescale by n\beta^*=n/\log n.

A degenerate minimum has more nearly optimal neighbours, so the loss barely rises and \hat\lambda is small. This is volume scaling, seen from the sampler’s side.

How do we compute the average?

Langevin dynamics

We want samples from a density \pi(w) that we know only up to its normalising constant. We can still compute \nabla\log\pi.

w_{t+1}=w_t+\frac{\epsilon}{2}\,\nabla\log\pi(w_t)+\xi_t, \qquad\xi_t\sim\mathcal N(0,\epsilon I_d).

Gradient ascent on the log density, plus Gaussian noise. The noise keeps the iterates spread over the distribution, instead of settling at its mode.

For the localised tempered posterior:

\nabla\log\pi_{\beta^*,\gamma}(w\mid w^*) =-n\beta^*\,\nabla L_n(w)+\gamma\,(w^*-w).

Why Langevin samples \pi

In the small step limit, the iterates follow the SDE

\mathrm dw_t=\tfrac12\,\nabla\log\pi(w_t)\,\mathrm dt+\mathrm dB_t .

The density \rho_t of w_t obeys the Fokker–Planck equation, a conservation law for probability with current J:

\partial_t\rho=-\nabla\cdot J,\qquad J=\underbrace{\tfrac12\,\rho\,\nabla\log\pi}_{\text{drift}} -\underbrace{\tfrac12\,\nabla\rho}_{\text{diffusion}}.

At \rho=\pi, use \pi\,\nabla\log\pi=\nabla\pi:

J=\tfrac12\,\nabla\pi-\tfrac12\,\nabla\pi=0 .

Therefore, \pi is the stationary distribution.

Stochastic gradient Langevin dynamics

Each Langevin step needs \nabla L_n: a pass over all the data.

Do what training does, and use a minibatch B_t (SGLD: Welling and Teh, 2011):

w_{t+1}=w_t+\frac{\epsilon}{2}\Big( \underbrace{-n\beta^*\,\nabla L_{B_t}(w_t)}_{\text{SGD on the tempered loss}} +\underbrace{\gamma\,(w^*-w_t)}_{\text{spring}}\Big) +\underbrace{\xi_t}_{\text{noise}}, \qquad\xi_t\sim\mathcal N(0,\epsilon I_d).

Each step now costs as much as a step of training.

However, with a finite step size and noisy gradients, the samples come only approximately from \pi_{\beta^*,\gamma}.

The SGLD estimator

Start the chain at w^*, discard a burn-in, keep T steps, and average the losses along it:

\boxed{\hat\lambda^{\mathrm{SGLD}}(w^*) =n\beta^*\Big(\frac1T\sum_{t=1}^{T}L_{B_t}(w_t)-L_n(w^*)\Big)}

How accurate is it?

LLC estimator in some toy settings

Recap

Approximation We replaced by
Tempering the free energy F_n(U) an average at \beta^*=1/\log n
Localisation the region U and the prior a Gaussian of strength \gamma
Sampling the exact average an SGLD chain

One more entry: we run it at a trained parameter \hat w, which is not a minimum w^* of the population loss.

Next week, we will cover how these affect the error of our estimate.

fin