Cross-Entropy Loss
When the target is a one-hot vector concentrated on token , this collapses to the negative log-likelihood .
Cross-entropy measures the average number of bits (or nats, using ) needed to encode events from a true distribution when your model predicts probabilities . Whenever puts high mass on the true next token, the loss drops toward zero; confident wrong predictions are penalized heavily.
An autoregressive LLM evaluates cross-entropy at every vocabulary prediction step during pre-training and supervised fine-tuning.
Suppose vocabulary size is , the true next token is class (), and softmax outputs :
CODE RUNS ONLY IN YOUR BROWSER VIA PYODIDE WEBASSEMBLY — NOTHING IS SENT TO ANY SERVER.
QUESTION 1 / 3
0 / 3 ANSWEREDQ1 · MCQ
For a one-hot target distribution where class k has probability 1, what does multi-class cross-entropy reduce to?
UNLOCKED BY THIS FORMULA (PREREQUISITE MATCH)