LLM 怎么评估?perplexity、benchmark、
LLM-as-a-judge、human eval 各管什么?

英文问法How do you evaluate an LLM? · What is perplexity? · What are the biases of LLM-as-a-judge? · How does Chatbot Arena rank models? · What is benchmark contamination?

考过面经:微软 Teams AS IC2("LLM evaluation metrics (BLEU, ROUGE, human evals, LLM-as-a-judge, etc.)")

先弄清楚:每个概念是什么

Perplexity
模型在每个真实 token 上,平均相当于在几个选项里犹豫。越小越好,全猜对是 1,在 \(V\) 个词里瞎猜就是 \(V\)。例:4 个 token 拿到的概率是 0.5、0.25、0.5、0.125 → PPL ≈ 3.36。
BLEU / ROUGE
拿 reference 逐个 n-gram 对照。BLEU 是 1–4 gram 的 clipped precision 取几何平均,再乘 brevity penalty \(\min(1, e^{1-r/c})\),用于翻译。ROUGE-N 是 n-gram recall,用于摘要。换了说法也会扣分,所以不适合开放式回答。
LLM-as-a-judge
请一个强模型当阅卷老师,便宜、快,但有 bias。pairwise 更稳,但模型多时对数按平方增长。单独打 1–10 分容易扩展,但分不出细微差别。
Contamination
benchmark 的题混进了 pretraining data,像考前背过原题,分数虚高。

30 秒回答

It depends on what we measure. For a base model I'd report perplexity, the exponential of the average per-token negative log-likelihood on held-out text, comparable only under the same tokenizer. With ground truth I'd use benchmarks: accuracy or exact match on MMLU and GSM8K, and pass@k with unit tests for code. Open-ended answers have no single reference, so BLEU and ROUGE work poorly; there I'd use pairwise human preference, aggregated with Elo or Bradley-Terry, or an LLM judge calibrated against human labels, with answer order swapped to cancel position bias. I'd check contamination with n-gram overlap and confirm with an online A/B test.

评什么用什么

评什么用什么坑
base modelheld-out perplexity只能同 tokenizer 比;PPL 低 ≠ 会做任务
有标准答案MMLU(accuracy)、GSM8K(exact match)、HumanEval(pass@k)contamination、分数饱和
翻译、摘要BLEU、ROUGE只看字面重合
开放式回答LLM-as-a-judge(MT-Bench)position、verbosity、self-enhancement bias
真实偏好human pairwise(Chatbot Arena),见 标注规范贵、慢、众包有噪声
上线效果A/B test:点赞率、acceptance rate要流量

推导 / 关键公式

Perplexity

\[ \mathrm{PPL} = \exp\Big(-\frac1n\sum_{t=1}^{n}\log p(x_t\mid x_{<t})\Big) \]

平均 cross-entropy 取 exp,也就是每个 token 概率倒数的几何平均。上面的例子:

\[ \mathrm{PPL} = (2\cdot 4\cdot 2\cdot 8)^{1/4} = 128^{1/4} \approx 3.36 \]

Elo 与 Bradley-Terry

\[ P(A \succ B) = \frac{1}{1+10^{(R_B-R_A)/400}} \]

高 100 分对应预期胜率 64%,高 400 分对应 91%。Elo 每场后在线更新 \(R_A \leftarrow R_A + K(S_A - E_A)\),结果受对战顺序影响。Arena 后来改用 Bradley-Terry,同样的 logistic 形式,用全部对战做 MLE(就是一个 logistic regression)。

LLM judge 的 bias 和对策

上线前抽一批人工标注算 agreement。MT-Bench 上 GPT-4 和专家的 agreement 是 85%,专家之间是 81%。

Contamination 怎么查

GPT-3 把和训练集有 13-gram 重合的测试题标为"脏",去掉后得到 clean subset。clean subset 上分数明显更低,就说明被污染抬高了。拿不到训练数据时,用新出的题(live benchmark)或改写题目。

必答点

追问

两个模型的 perplexity 能直接比吗?

tokenizer 不同就不能。PPL 按 token 平均,切得粗的模型每个 token 信息多,PPL 偏高。要比就按字节归一化(bits per byte)。

pass@k 怎么算?

每题生成 \(n \ge k\) 个样本,\(c\) 个通过 unit test,unbiased 估计 \(1 - \binom{n-c}{k}/\binom{n}{k}\)。例:\(n = 10\)、\(c = 3\):pass@1 = 0.3,pass@5 ≈ 0.92。直接用 \(1-(1-\hat p)^k\) 是有偏的。

来源d2l §9.3.2 eq. 9.3.7–9.3.8 · Zheng et al. 2023, MT-Bench §3.1、§3.3 Table 2–3(pp.4–5)、§3.4 Table 4(pp.5–6)、§4.2(p.7)· Chiang et al. 2024, Chatbot Arena §4 eq. 2(p.4)、§6.3(p.7)· LMSYS blog 2023(Elo)· Brown et al. 2020, GPT-3 §4(pp.29–31)· Chen et al. 2021, Codex §2.1 eq. 1(p.3)· Papineni et al. 2002, BLEU §2(pp.312–315)· Lin 2004, ROUGE §2