Skip to content
Science, DecodedContext Jamming

Equation Inspector

Cross-entropy (the language-model loss)

EstablishedAI / MLMathematics
H(p,q)=−∑ipi log⁡qi\htmlClass{sjt-H}{H(p,q)} = -\htmlClass{sjt-sum}{\sum_{i}} \htmlClass{sjt-p}{p_i}\,\htmlClass{sjt-logq}{\log q_i}

Tap a symbol above, or choose one here:

H(p,q)H(p,q)Cross-entropyRosetta entry →

Meaning

Average surprise when outcomes really follow p but you predict with q.

Its job in this equation

The output, and the quantity language-model training minimises.

Picture it

Your average score when the real world deals the cards (p) but you bet using your beliefs (q).

Read it, progressively

1. Gist

How surprised your model is, on average, by what really happens.

What it does not establish

Cross-entropy measures probabilistic prediction of the training distribution, not truthfulness, helpfulness or reasoning. Two models with equal loss can differ in behaviour. It is also not symmetric: H(p,q)≠H(q,p)H(p,q) \ne H(q,p).

Play with it

Loading interactive…