这几天排行榜上又在比谁的困惑度更低。我把定义按原始出处对了一遍,发现大家在比的,常常不是同一把尺子。
困惑度不是一个新词。1977 年 12 月,IBM 沃森研究中心的 Jelinek、Mercer、Bahl 和 Baker,在《美国声学学会杂志》上给它派了一个很窄的活:衡量一项语音识别任务有多难。他们先拆了两个更直觉的指标。词表大小不行,静态或动态的分支因子也不行。信息论上更合适的,是困惑度。它的对数就是熵。直观讲,困惑度 20,就是模型在每一步上不确定得像在 20 个等可能的选项里抽一个。
他们自己的表把这个差距摆了出来。IBM-Lasers 那项任务,词表 1000,动态分支因子也是 1000,词一级的困惑度却是 21.11。词表说字典里有一千条。困惑度说语法把下一步收成了大约 21 个等可能的词。同一张表里,IBM-Raleigh 词表 250,词困惑度 7.74。CMU-AIX05 词表 1011,词困惑度 6.41。分支因子和词表对不上。这就是他们写进摘要的反例。摘要里还留了一句:这个指标自己也有弱点。
再往前,尺子是 Shannon 的。1951 年 1 月,《贝尔系统技术杂志》那篇《印刷英语的预测与熵》里,他按 26 个字母的频率算,英语大约是每个字母 4.14 比特。只考虑不超过 8 个字母的统计约束,熵大约降到 2.3 比特,冗余大约 50%。把统计效应拉到大约 100 个字母,他估计普通书面英语的熵是大约每个字母 1 比特,冗余大约 75%。
这说明什么?
2 的 4.14 次方大约是 17.6。只看字母频率,下一个字母像是在大约 18 个等可能的字母里挑。上下文拉长以后,Shannon 那个“大约 1 比特”对应的有效选择大约是 2。人写字的时候,大部分字母是被前面的句子挤出来的,不是从 26 个里重新抽的。你在手机上打“明天的机票”,前几个字出来以后,输入法不该再把整本字典摊开。
今天模型报出来的困惑度,是同一件事的现代写法。先算模型分给真实下一个 token 的平均负对数概率,再取指数。训练时那个交叉熵损失,取一次 exp,就是困惑度。它变低,只说明模型对这份测试文本更不吃惊。
我的判断:
1. 困惑度是有效选项数,不是智商。它回答下一步有多窄,不回答这个窄有没有用。
2. 拿两家的困惑度横比之前,先问测试文本是不是同一份,token 是不是同一套切法。切得越碎,平均的分母就变了。数字会动,能力不一定动。Jelinek 在 1977 年就写过这个指标有弱点。这一条到现在还在。
3. 想跟 Shannon 的“每字母大约 1 比特”对话,就得把单位换回每字母或每字节的比特,而不是拿一种 token 切法上的困惑度直接去减。换算做不到,就标成不可比。别写成谁超越了英语的熵。
一句话:
困惑度量的是下一步还剩几条路,不是这条路通向哪里。
(Shannon,《贝尔系统技术杂志》1951 年 1 月;Jelinek、Mercer、Bahl、Baker,《美国声学学会杂志》1977 年 12 月)
Leaderboards spent the last few days treating a lower perplexity as a win. I checked the definition against the original sources. Often the numbers are not even on the same ruler.
Perplexity is not a new word. In December 1977, Jelinek, Mercer, Bahl, and Baker at IBM's Watson Research Center gave it a narrow job in the Journal of the Acoustical Society of America: measure how hard a speech recognition task is. They discarded two more intuitive measures first. Vocabulary size does not work. Neither does a static or dynamic branching factor. The better information-theoretic measure of equivalent choice is perplexity. Its logarithm is entropy. A perplexity of 20 means that at each step the model is as unsure as if it were drawing uniformly from 20 options.
Their own table shows the gap. On the IBM-Lasers task the vocabulary is 1,000 and the dynamic branching factor is also 1,000, but word perplexity is 21.11. The vocabulary says the dictionary has a thousand entries. Perplexity says the grammar has squeezed the next step down to about 21 equally likely words. On the same table, IBM-Raleigh has a 250-word vocabulary and a word perplexity of 7.74. CMU-AIX05 has a vocabulary of 1,011 and a word perplexity of 6.41. Branching factor and vocabulary refuse to line up. That mismatch is the counterexample in the abstract. The abstract also keeps one caveat: the metric has weaknesses of its own.
The older ruler is Shannon's. In the January 1951 Bell System Technical Journal paper, Prediction and Entropy of Printed English, letter frequencies alone put English at about 4.14 bits per letter on a 26-letter alphabet. Statistical effects stretching no farther than eight letters brought the estimate to about 2.3 bits per letter, redundancy about 50 percent. Extend those effects out to about 100 letters, and he put ordinary literary English at about one bit per letter, redundancy roughly 75 percent.
What does that tell you?
Two to the power 4.14 is about 17.6. On letter frequencies alone, the next letter looks like a draw from about 18 equally likely letters. Once the context gets long, Shannon's "about one bit" is an effective choice of about 2. When people write, most letters are squeezed out by the sentence in front of them. They are not redrawn from 26. Type "tomorrow's flight" on a phone, and after the first few words the input method should not still be spreading the whole dictionary open.
The perplexity reported for models today is the same object in modern clothes. Average the negative log probability the model assigns to the true next token, then exponentiate. Pass the cross-entropy loss you train with through exp, and you have perplexity. A lower number only means the model is less surprised by that particular test text.
My read:
1. Perplexity is an effective number of options, not an IQ. It answers how narrow the next step is. It does not answer whether that narrowness is useful.
2. Before comparing two labs' perplexities, ask whether the test text is the same and whether the tokens were cut the same way. A finer cut changes the denominator the average runs over. The number moves. The capability may not. Jelinek wrote in 1977 that the metric has weaknesses. That line is still in force.
3. If you want to talk to Shannon's "about one bit per letter," convert back to bits per letter or bits per byte. A perplexity on one tokenization does not subtract from the entropy of English. If the conversion cannot be done, mark them incomparable. Don't write it up as someone beating the entropy of English.
In one sentence:
Perplexity measures how many roads the next step still has, not where the road goes.
(Shannon, Bell System Technical Journal, January 1951; Jelinek, Mercer, Bahl, and Baker, Journal of the Acoustical Society of America, December 1977)