Negative Log-Likelihood

Negative log-likelihood trains a probabilistic model by penalizing low probability assigned to observed data.

For a conditional model and dataset :

This is equivalent to maximum likelihood estimation:

Common Cases

Categorical likelihood gives cross-entropy loss:

Gaussian likelihood with fixed variance gives mean squared error up to constants and scale:

Autoregressive sequence models factorize likelihood over positions:

so the sequence NLL is:

Distribution Contract

NLL is only meaningful after the output distribution is named.

OutputLikelihoodTypical Loss
binary labelBernoullibinary cross-entropy
categorical labelcategoricalsoftmax cross-entropy
countPoisson or negative binomialcount NLL
scalar with homoscedastic noiseGaussian with fixed varianceMSE up to scale and constants
scalar with learned uncertaintyGaussian with predicted varianceGaussian NLL
sequenceautoregressive categorical factorstoken NLL
continuous densityflow, mixture, diffusion/score surrogatemodel-specific NLL or bound

For a paper note, write the distribution explicitly:

Then state what the log probability is averaged over: examples, tokens, residues, atoms, pixels, poses, or sequences.

Reduction and Units

Per-token and per-sequence NLL are different claims:

The first weights each valid token equally. The second weights each sequence equally after summing its tokens. The choice affects long sequences, proteins, documents, trajectories, and generated structures.

Evaluation Boundary

Lower NLL means the model assigns higher probability to observed data under the chosen factorization. It does not automatically mean better:

  • hard-decision accuracy;
  • calibrated probabilities under distribution shift;
  • generated sample validity;
  • ranking or retrieval utility;
  • molecular or structural physical plausibility.

Link NLL to the downstream metric before treating it as evidence for a broader claim.

Checks

  • What probability distribution is assumed: categorical, Bernoulli, Gaussian, mixture, or autoregressive?
  • Are log probabilities averaged per example, per token, per atom, or per sequence?
  • Are padding, masks, and invalid positions excluded correctly?
  • Is NLL used for training, evaluation, or both?
  • Does likelihood align with downstream utility, validity, ranking, or calibration?