Skip to content
nonconvexcard

The cross-entropy gradient is the prediction error

ProofBeginner⏱ 15 minLLMssoftmaxcross entropygradientfused kernel

Problem

Show ∂ℓ/∂z=q−ev⋆\partial\ell/\partial z = q - e_{v^\star} for ℓ=−log⁡qv⋆\ell = -\log q_{v^\star} with q=softmax⁡(z)q = \operatorname{softmax}(z), and explain why softmax and cross-entropy are implemented as a single fused operation.

Write a complete argument. Every inequality you use should be one you could state precisely.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Maximum likelihood is KL minimisationLLMsProofBeginner15 min
Perplexity is not comparable across tokenisersLLMsNumericalBeginner15 min
The irreducible loss is the conditional entropyLLMsProofIntermediate30 min
The softmax Jacobian as a variance, and saturationDeep LearningProofIntermediate30 min
The softmax Jacobian is a covarianceFoundationsProofIntermediate30 min