Losses from First Principles
A Loss Specifies What Learning Means
Let \(Z\sim p^*\) denote an observation and let \(a_\theta\) be the model output. Training minimizes an empirical approximation to a population objective:
\[ R(\theta) = \mathbb E_{Z\sim \mu} \left[\ell(a_\theta,Z)\right]. \]
This compact expression hides four independent design choices:
- Statistical object: a distribution, mean, quantile, boundary, representation, ranking, or policy.
- Source of supervision: observed outcomes, pairs, latent variables, synthetic corruption, rewards, or a teacher model.
- Discrepancy: a proper score, surrogate risk, divergence, variational bound, learned critic, or utility objective.
- Expectation distribution \(\mu\): data examples, constructed pairs, noise levels, teacher trajectories, or student-generated states.
The first-principles question is therefore not merely “which formula should I use?” It is:
What should the optimum recover, from which information, over which population, and with what tractable learning signal?
The Goal Is Not Always to Learn a Full Distribution
Some losses estimate a full probability distribution. Others deliberately estimate less structure because that is all the decision requires.
| Desired object | Example objective | Population optimum or interpretation |
|---|---|---|
| conditional distribution | log loss / cross-entropy | \(p^*(y\mid x)\) when the model is well specified |
| conditional mean | squared error | \(\mathbb E[Y\mid X=x]\) |
| conditional median | absolute error | a median of \(Y\mid X=x\) |
| conditional quantile | pinball loss | \(q_\tau(Y\mid X=x)\) |
| decision boundary | hinge loss | a margin-separated classifier |
| ordering | pairwise ranking loss | relative preferences between candidates |
| representation geometry | contrastive or metric loss | invariances and separations defined by pairs |
| behavior | policy objective | actions that maximize expected utility |
Learning a calibrated distribution is valuable when downstream users need probabilities, uncertainty, simulation, or many different decisions. It can be unnecessary excess structure when only one boundary or ranking matters.
“Assuming a Distribution” Is Not a Binary Property
The same formula can have both a likelihood derivation and a weaker decision-theoretic interpretation.
For example, if
\[ Y\mid X=x\sim\mathcal N(f_\theta(x),\sigma^2), \]
then Gaussian negative log-likelihood reduces to scaled MSE. This is an explicit observation-model assumption. But independently,
\[ \arg\min_a\mathbb E[(Y-a)^2\mid X=x] = \mathbb E[Y\mid X=x], \]
whenever the expectation exists. MSE therefore elicits the conditional mean even when the residuals are not Gaussian. Similarly, MAE is Laplace NLL under one model but elicits a conditional median much more generally.
Ask two separate questions:
- Likelihood question: under which probabilistic model is this loss an NLL or divergence?
- Elicitation question: which statistic or decision does its population minimizer recover without that model being literally true?
Every objective still contains assumptions—about support, noise, costs, invariances, sampling, or teacher reliability—even when it does not specify a normalized density.
Why Discriminative versus Generative Is Secondary
“Discriminative” and “generative” describe model factorization more naturally than they describe loss functions:
\[ \text{discriminative: }p_\theta(y\mid x), \qquad \text{generative: }p_\theta(x)\text{ or }p_\theta(x,y). \]
Cross-entropy demonstrates the limitation of using this as the primary loss taxonomy:
| Use of cross-entropy | Target distribution | Role |
|---|---|---|
| image classification | labels conditioned on an image | discriminative prediction |
| next-token prediction | next tokens conditioned on a prefix | generative density modeling |
| knowledge distillation | teacher outputs conditioned on an input or state | teacher-supervised transfer |
The algebra is nearly identical. What changes is the target, the sampled state, and the meaning of a successful optimum.
A Better Map of the Loss Notes
Prediction and decision objectives
Use Prediction and Decision Losses when the goal is a label, point estimate, boundary, margin, or ranking. It covers:
- proper scoring rules and calibrated classification
- logistic regression, CE, BCE, label smoothing, and focal loss
- margin and ranking surrogates
- mean, median, robust, heteroscedastic, quantile, and count regression
Distribution-learning objectives
Use Distribution Learning Losses when the model must represent or sample from a high-dimensional distribution and direct likelihood is exact, latent, or unavailable. It covers:
- exact autoregressive likelihood and next-token prediction
- KL geometry
- variational likelihood and the VAE ELBO
- sample-based adversarial discrepancies
- diffusion denoising and score-learning abstractions
Representation objectives
Use Representation Learning from First Principles for contrastive, metric, reconstruction, redundancy-reduction, and predictive objectives. These losses specify which information and invariances a representation should preserve rather than directly specifying a final decision.
Teacher-supervised objectives
Use Distillation: Learning from a Teacher when supervision comes from another model. Distillation can train a classifier, generator, representation, or policy, so it is a cross-cutting supervision mechanism—not a subtype of generative modeling.
The Cursor continual-training case study shows all four axes changing together: production supplies states, the current policy supplies actions, users and tools supply reward, and a reference policy or feedback-conditioned teacher supplies KL anchors.
A Loss-Design Procedure
Given a new problem:
- Write the real decision, generation, or representation goal.
- Decide whether you need a full distribution or only a functional/decision.
- State what observations and supervisory signals are actually available.
- Choose a proper score, surrogate, divergence, bound, critic, or utility whose optimum is aligned with that target.
- Write the expectation distribution and reduction explicitly.
- Check support, calibration, robustness, and train–deployment mismatch.
- Only then choose a numerically stable parameterization and implementation.
Two objectives may have the same optimum yet very different gradients. A statistically correct objective can also fail when its estimator has high variance, its sampling distribution misses important states, or its parameterization makes optimization difficult.
Interview Questions
- Why does discriminative versus generative classify models better than losses?
- Give three interpretations of cross-entropy with the same algebra.
- Does using MSE require Gaussian data? Separate its likelihood and elicitation interpretations.
- When is learning a full conditional distribution unnecessary?
- Why are the supervision source and expectation distribution separate from the discrepancy formula?
- Is distillation a loss, a model family, or a source of supervision?
- Can two losses share a population optimum but train very differently?