跳到主要内容Skip to main content

困惑度Perplexity (PPL)

Perplexity (PPL)

  • 核心概念Core concepts
  • 第四站 · 看懂Station 4 · Under the Hood
解决什么问题What problem it solves

语言模型最常用的内在评测指标:模型对测试文本有多「意外」。The most common intrinsic metric for language models: how surprised the model is by test text.

这是什么What it is

困惑度定义为模型对测试序列逐 token 平均负对数似然的指数。

等价于平均交叉熵损失的指数。困惑度越低,模型对文本预测越确信。

它对分词方式敏感:只宜在相同 tokenizer 的模型之间直接比较。

它适用于自回归模型,对 BERT 这类掩码模型定义不佳。

Perplexity is the exponentiated average negative log-likelihood of a sequence, token by token.

Equivalently, the exponent of the average cross-entropy loss; lower perplexity means the model predicts the text more confidently.

It is sensitive to tokenization: compare it directly only between models sharing the same tokenizer.

It applies to autoregressive models and is ill-defined for masked models like BERT.

为什么需要知道Why it matters

论文和模型卡常报这个数。知道它只跟同分词的模型可比,就不会被跨家的困惑度数字误导。Papers and model cards report this number. Knowing it is only comparable across same-tokenizer models keeps you from being misled by cross-vendor figures.

出处Sources
  • Hugging Face Transformers 官方文档《Perplexity of fixed-length models》Hugging Face docs: Perplexity of fixed-length models ↗
  • Jurafsky & Martin《Speech and Language Processing》§3.3 与 §7.7.1Jurafsky & Martin, Speech and Language Processing, §3.3 and §7.7.1 ↗