What is AI cross-entropy?
Cross-entropy measures the mismatch between a true probability distribution and a model's predicted one; it is the most widely used loss function for classification. With one correct label it equals the negative log probability of that class, hence the names log loss and logistic loss.
Unlike entropy, which measures the uncertainty of one distribution, cross-entropy compares two. The gap is the relative entropy; as the true distribution's entropy is fixed, minimising cross-entropy minimises that divergence.
- Topic
- Machine learning, models and training
- Also known as
- Log loss, logistic loss, cross-entropy loss
- Origin
- Information theory; entropy defined in a 1948 paper on communication theory
How AI cross-entropy works
- The model outputs unnormalised scores (logits) and softmax turns them into probabilities.
- The loss is the negative log probability of the correct class averaged over the batch; minimising it maximises the correct label's likelihood.
- Language models apply it to each next token; the exponent of the average loss is perplexity.
- Class weights help with class imbalance; label smoothing curbs overconfidence.
Commonly confused terms
| Term | How it differs |
|---|---|
| Perplexity | Perplexity is an evaluation measure for language models obtained by exponentiating the average cross-entropy. Cross-entropy is the loss that training minimises directly. |
Why AI cross-entropy matters for on-premises AI
Its roots lie in a 1948 communication theory paper that framed entropy as a measure of information, choice and uncertainty. Differentiable with respect to the logits, it suits gradient training of deep models. Variants target specific problems: the 2017 focal loss down-weights well-classified examples to handle class imbalance, while a 2023 study examined its guarantees as a surrogate loss.
An insurer trains a model that sorts incoming emails into claim reports, policy changes and complaints with cross-entropy. Complaints are rare, so that class gets a higher weight; the team tracks validation loss and per-class recall to catch confident mistakes.
Common questions
Is cross-entropy the same as log loss?
In classification, yes: log loss, logistic loss and cross-entropy loss name the same loss. Each measures the negative log probability a model gives to the correct class.
How does cross-entropy relate to perplexity?
Perplexity is the exponent of a language model's average cross-entropy per token. Lower loss means lower perplexity, although the tokenisation method directly affects comparisons between models.
Is plain cross-entropy enough under class imbalance?
The standard loss can favour majority classes. Class weights or variants such as focal loss, which reduce the share of easy examples, are used.
Related terms
Sources
- A Mathematical Theory of Communication, Bell System Technical Journal, 1948
- Rethinking the Inception Architecture for Computer Vision, arXiv, 2015
- Focal Loss for Dense Object Detection, arXiv, 2017
- Cross-Entropy Loss Functions: Theoretical Analysis and Applications, ICML, 2023
In the glossary: Glossary, A to D