交叉熵是分类损失:正确答案分到的概率越低,惩罚越大;如果模型自信地押错,损失会非线性飙升。Cross-entropy is a classification loss: the less probability assigned to the correct
answer, the larger the penalty. Confidently backing the wrong answer makes the loss
surge.
01 · 不是只看猜没猜中01 · Accuracy is not the whole story
同样答错,“五五开”和“百分之九十九确信错误”该受同样惩罚吗?Two answers are wrong. Should a coin-flip guess and a 99%-confident mistake receive the
same penalty?
−ln
02拖动正确 token 的概率Drag the Correct Token Probability
唯一变量:p(正确)One variable: p(correct)
p(正确correct)
90%
分给正确 tokenassigned to correct token
交叉熵Cross-entropy
0.105
−ln(p)
判断Reading
低LOW
惩罚强度penalty level
03一次交叉熵只盯住正确答案One Cross-Entropy Term Watches the Correct Answer
label · probability · log · penalty
LABEL
正确类别Correct class
标签指出这次应当是“猫”。The label says this example should be “cat.”
PROBABILITY
正确项概率Correct probability
读取模型分给正确项的 p。Read p assigned to the correct item.
LOG
对数形状Log shape
越接近 0,曲线越陡。The curve steepens near zero.
LOSS
分类惩罚Class penalty
p 越高,−ln(p) 越接近 0。As p rises, −ln(p) approaches zero.
04最小机制:概率每少一点,代价并不等量增加Minimal Mechanism: Equal Probability Drops Do Not Cost Equally
L = −ln pcorrect
L = −ln(pcorrect)
p = 0.9 → L ≈ 0.105 p = 0.1 → L ≈ 2.303 p = 0.01 → L ≈ 4.605
降低正确概率Lower correct probability模型更相信其他答案Model backs other answers
进入对数陡坡Enter log cliff低概率区更敏感Low-p region is steeper
惩罚飙升Penalty surges自信错受到重罚Confident errors hurt
05边界实验:自信地押错Boundary Test: Be Confidently Wrong
主动制造失败Create a failure
只给正确 token 1%Give the correct token only 1%
准确率只会记一次“错”,交叉熵还会记住错得多自信。Accuracy records one miss; cross-entropy also records how confident the miss
was.
尚未执行。Not run yet.
✗ 交叉熵就是错误率。Cross-entropy is error rate.
→ ✓ 它还衡量正确答案被分到多少概率。It also measures probability assigned to the correct answer.
✗ 0.1 到 0.01 只差 0.09,所以影响很小。0.1 to 0.01 differs by only 0.09, so impact is small.
→ ✓ 对数让低概率区的惩罚陡增。The log makes low-probability penalties steep.
✗ 损失值是真实模型表现。This loss is real model performance.
→ ✓ 本页数值只用于教学演示公式。These values only demonstrate the formula.
06 · 一句话带走06 · One line to keep
交叉熵把“正确答案得到的概率”变成损失,尤其重罚自信地答错。Cross-entropy turns the correct answer's probability into loss, especially punishing
confident mistakes.