AI GLOSSARY · AI CONCEPTS

Cross-entropy loss

Markdown version · Wikidata Q22667762

Definition

Cross-entropy loss is a loss function, a score of how wrong a model is, for classification. It compares the probabilities a model gives each class with the true label and is lowest when the true class gets high probability.

Also called: log loss, logistic loss, cross entropy, binary cross entropy, categorical cross entropy.

In plain language

When a model sorts things into categories, such as spam or not spam, it can say how sure it is: for example, very likely spam. Cross-entropy loss turns that into a penalty. If the model gave a high probability to the right answer, the penalty is small. If it gave a low probability to the right answer, the penalty is large. Training tries to make the total penalty smaller. The score only measures how well the probabilities match the labels you supplied, so wrong or noisy labels teach the wrong lesson. It also says nothing by itself about whether a model is fair, safe or useful.

Technical definition

For one example, scikit-learn's user guide defines binary log loss as the negative log-likelihood of the classifier given the true label: minus the logarithm of the probability the model assigned to the true label. The multiclass form averages, over samples, the negative log of the predicted probability for each sample's true class. The same guide names log loss, logistic regression loss and cross-entropy loss together. In the Stanford CS231n notes, a softmax classifier turns raw scores into probabilities that sum to one and minimises the cross-entropy between the true distribution and the predicted one; the notes say this corresponds to maximum likelihood estimation.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Skill by Skill Almanac · Illustrative, not executed

    llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill builds and validates an eval dataset for an LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
    Why it exercises the concept
    The catalogue has no training skills, so this is a contrast case. Cross-entropy can be a training objective or a held-out evaluation metric for class probabilities. This skill checks eval-set structure rather than computing that loss. Label quality matters for both.
  2. Skill by Skill Almanac · Illustrative, not executed

    split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill checks train, validation and test files for duplicates, shared groups, time and label leakage and prints JSON.
    Why it exercises the concept
    A loss computed on data that leaked from the training set can look better than it should. This skill is a contrast case for checking the data before trusting a loss number. It does not compute cross-entropy.
  3. Guide · Illustrative, not executed

    What Is an LLM? The Facts Agent Users Need

    What you see
    A guide to language models, including an autoregressive next-token illustration and a contrasting BERT masked-token objective.
    Why it exercises the concept
    The guide is about using models, not training them, so it is a contrast case. Its autoregressive illustration shows one prediction setting in which a probability-based score like this one can be applied.

How it shows up when you use agents

You usually do not compute cross-entropy loss yourself when you run Claude Code, Codex or Cursor. It belongs to training, the stage where people build or fine-tune a neural network. It appears in training logs, in fine-tuning reports and in library documentation, and the Stanford CS231n notes and the scikit-learn guide both describe it.

When you read a training log that shows a falling loss curve, check which data the loss was measured on. A loss on the training data and a loss on held-out data answer different questions, and a number that looks good on data the model has already seen does not show how it will do on new cases. Keep the two separate.

If you evaluate an agent feature, do not treat a loss number as a task score. A loss is a training signal computed from probabilities. A pass rate on real tasks is a different measurement, and a model with a good loss can still fail the task. For the general idea of a training score, see Loss function; for how a loss is lowered during training, see Gradient descent.

What breaks when this is misunderstood: teams compare two runs by loss alone, or quote a training loss as if it were quality. Next action: when you train or fine-tune anything, record the loss on a held-out split next to the training loss, and judge the result with a task-level test as well.

Common confusions

  • Cross-entropy loss versus accuracy. Accuracy counts right and wrong labels. Cross-entropy uses the probability given to the true class, so two models with the same accuracy can have different loss.
  • Cross-entropy versus log loss. The scikit-learn guide names log loss, logistic regression loss and cross-entropy loss together. Binary and categorical cross-entropy are the two-class and many-class forms.
  • Cross-entropy versus mean squared error. Both are loss functions, but cross-entropy compares predicted class probabilities with labels, while squared error compares numeric values. The choice depends on the task.
  • Myth. A lower loss means a better model for every purpose. Loss measures fit to the training objective on the data it was computed on; a held-out check and a task-level test answer different questions.

Terms that mention Cross-entropy loss

2 terms mention this one

More in AI concepts

Next steps

  1. What Is an LLM? The Facts Agent Users Need The long-form guide.
  2. llm-eval-test-sets A skill that exercises it.
  3. Neural network Related term.
  4. Gradient descent Related term.
  5. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.

Review record

Last verified

Drafted by Claude (original draft) and OpenAI Codex (targeted revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .

Change log (4)
  • : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
  • : Targeted batch-08 scope and example corrections from independent source review; affected recheck pending.
  • : First version.
  • : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.