基于人类反馈的强化学习

面向语言模型的后训练RLHF简明指南

作者:Nathan Lambert 译者:Junwei He

本章目录

评测

评测方法始终在不断演进。 理解大语言模型的评测(尤其是后训练阶段),关键在于:当前流行的评测体系其实反映了主流训练实践和目标的变迁。 虽然有挑战性的评测推动了模型能力的突破,但大多数评测的设计初衷还是为新模型提供有用的信号。

本章将以小故事的方式,梳理RLHF早期历史中流行的评测体系,帮助读者理解其中的共性、细节与常见失效模式。

RLHF与后训练的评测经历了几个明显阶段:

  1. 早期聊天阶段:最早的RLHF或偏好微调模型,评测重点是模型的对话表现,尤其是与GPT-4等强模型的比较。典型评测有MT-Bench [1]、AlpacaEval [2]、Arena-Hard [3]。这些评测领域现在被归类为“聊天”或“指令跟随”。
  2. 多技能时代:随着时间推移,业界逐渐认识到RLHF不仅能提升聊天能力,还能改善多种技能。例如,Tülu评测套件涵盖知识(MMLU [4]、PopQA [5]、TruthfulQA [6])、推理(BigBenchHard [7]、DROP [8])、数学(MATH [9]、GSM8K [10])、代码(HumanEval [11]、HumanEval+ [12])、指令跟随 [13]、安全性(多项评测综合)。这反映了后训练已被视为多面手,而不仅仅是安全或聊天的解决方案。
  3. 推理与工具阶段:当前后训练的主流方向是挑战性更高的推理与工具使用任务,包括知识密集型难题(如GPQA Diamond [14]、Humanity’s Last Exam [15])、复杂软件工程任务(如SWE-Bench+ [16]、LiveCodeBench [17]),以及高难度数学题(如最近的AIME竞赛题)。

未来还会有更多新领域不断涌现。 随着AI产业化,评测的激励机制也在变化,变得多方参与、多元化。 自ChatGPT发布以来,私有评测如Scale Leaderboard [18]、社区驱动评测如ChatBotArena [19],以及第三方评测公司如ArtificialAnalysis、Epoch AI等大量涌现。 本章会结合这些评测的实际落地细节进行讲解。

提示格式化:从Few-shot到Zero-shot再到CoT

Prompting(提示工程)本质上是一个动词,但也被认为是一门可以专门练习和训练的“手艺”[20]。 Prompt是为语言模型组织信息和上下文的方式。 日常交互中的prompt通常很简单,但在高级场景下,精心设计的prompt往往决定了模型能否成功完成任务。

在评测中,prompt设计对模型表现影响巨大。 有些提示格式(见下文)甚至能让模型表现从60%跌到接近0。 同样,prompt的变化也能帮助模型在训练中学得更好。 业界常说,“会写prompt”能让你提前体验“未来”模型的能力,突破常规用法的天花板。

现代大模型的高阶prompt往往是一份完整的报告(动辄上千token)。 这种行为改变了模型性能的评测和理解方式。

早期语言模型只被当作智能补全工具。 若想让模型更灵活地完成任务,通常会给出多个示例,再加一个待补全的prompt,这就是few-shot或in-context learning [21],当时还没有指令微调或RLHF。 例如:

# Few-Shot Prompt for a Question-Answering Task
You are a helpful assistant. Below are example interactions to guide your style:

### Example 1
User: "What is the capital of France?"
Assistant: "The capital of France is Paris."

### Example 2
User: "Who wrote the novel '1984'?"
Assistant: "George Orwell wrote '1984.'"

# Now continue the conversation using the same style.
User: "Can you explain what a neural network is?"
Assistant:

对于MMLU风格的多选题,也可以这样few-shot:

# Few-Shot Prompt

Below are examples of MMLU-style questions and answers:

### Example 1
Q: A right triangle has legs of lengths 3 and 4. What is the length of its hypotenuse?
Choices:
(A) 5
(B) 6
(C) 7
(D) 8

Correct Answer: (A)

### Example 2
Q: Which of the following is the chemical symbol for Sodium?
Choices:
(A) Na
(B) S
(C) N
(D) Ca

Correct Answer: (A)

### Now answer the new question in the same style:

Q: Which theorem states that if a function f is continuous on a closed interval [a,b], then f must attain both a maximum and a minimum on that interval?
Choices:
(A) The Mean Value Theorem
(B) The Intermediate Value Theorem
(C) The Extreme Value Theorem
(D) Rolle’s Theorem

Correct Answer:

这里可以直接采样生成答案(A/B/C/D),也可以计算各选项的概率,看正确答案是否概率最大(如[22]所述)。 概率法既可以用选项字母,也可以用完整答案文本,两种都合理,但实际评测更常用选项概率。

few-shot提示的常见问题是模型不遵守格式,导致答案判错。 设计评测时,in-context示例数量也是参数,通常3到8个甚至更多。

few-shot提示发展过程中,出现了链式思维(chain-of-thought, CoT)示例,即示例中包含详细推理过程(后来发展为明确提示模型“逐步思考” [23]):

# standard prompting
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?

A: The answer is 11.

Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have?

A: The answer is ...

# chain of thought prompting
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?

A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.

Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have?

A: The cafeteria had 23 apples originally. They..

随着模型能力提升,zero-shot评测(零样本学习)成为主流 [24]。 FLAN(Finetuned Language Net)证明了指令微调后的模型能泛化到未见过的zero-shot问题 [24](T0 [25]也有类似结果)。 这也推动了指令微调(IFT)的流行,为RLHF和后训练奠定了基础。 zero-shot问题示例如下:

User: "What is the capital of France?"
Assistant:

自2022年起,早期RLHF代表作如InstructGPT等陆续出现。 这些模型的核心能力和用例,转向更开放的生成式场景。 随着开放性增强,生成式评测愈发流行,因为这更贴近真实应用。 在ChatGPT发布后的几年里,RLHF研究仍保留多选评测作为对比。

到2024年底、2025年初,推理模型兴起,模型行为发生重大变化——每个答案前都会输出长链式思维(CoT)推理过程。 这时,模型不再需要经典的“think step by step”提示(见[26])。

比如,为了让模型在多选题上输出CoT,可用如下特殊prompt(Tülu 3 [27]):

Answer the following multiple-choice question by giving the correct answer letter in parentheses. Provide CONCISE reasoning for the answer, and make sure to finish the response with “Therefore, the answer is (ANSWER_LETTER)” where (ANSWER_LETTER) is one of (A), (B), (C), (D), (E), etc.

Question: {question}
(A) {choice_A}
(B) {choice_B}
(C) …

Answer the above question and REMEMBER to finish your response with the exact phrase “Therefore, the answer is (ANSWER_LETTER)” where (ANSWER_LETTER) is one of (A), (B), (C), (D), (E), etc.

尤其当模型用特殊格式分隔思考token和答案token时,评测体系也随之更新。 如今,评测正转向链式思维生成的开放式测试。

评测的使用与观察

Epoch AI报告:主流AI评测随时间迅速饱和。CC-BY许可。

公司内部的大模型评测只能与同行横向对比(且误差很大),因为内部评测流程与外部评测不一致。 反复用于调参的内部评测实际上承担验证集的角色;仍应另设未用于调参的测试集。 而社区用来比较领先模型的公开评测,无法确定是否被作为训练集、测试集或验证集。

随着评测分数成为企业营销的核心,评测流程在公司内部不断变化。 据说一些大厂会为GSM8k、MATH等重要评测设计“定制prompt”。 这些做法变化极快。

大模型评测体系常被视为营销手段,因为评测没有标准的“真理源”。 前沿实验室会根据自身需求调整评测套件。 公开的分数只是实验室模型的输出结果,输入细节并未全部披露。 这些输入细节极为敏感,不同公司(OpenAI、Meta、Anthropic、Google)各不相同。 即便是完全开源的评测标准,也很难保证可复现性。 固定模型版本、提示模板、采样参数、推理预算与评分代码,有助于提升可重复性;跨团队比较也需要披露这些条件。 当然,技术团队的出发点是好的。

如今,前沿大模型的评测既是科学,也是艺术。

不同团队会选择不同评测作为“真正的测试集”,但没人会公开选择了哪些。 比如,MATH和GSM8k等推理评测都自带训练集,prompt本身就能提升表现。 用同分布prompt提升分数,与泛化到新任务是两回事。

事实上,这些“训练集”本身就是高质量数据,模型训练时用它们会直接受益。 基准提供的训练划分可用于训练;若将测试划分也用于训练或调参,就不能再把该测试集上的成绩当作独立泛化证据,应披露用途并采用未污染的测试集。

主流AI实验室往往在少数关键评测上爬坡,最后在核心公开集上报分。 有些内部跟踪指标(如GPT-4报告中的交叉熵loss预测 [28])甚至不对外公开。

后训练评测高度依赖人工评测。 生成式大模型的人工评测常用Elo排名(如Anthropic早期论文中的宪法AI),奖励模型的人工评测则看一致性。 也可以通过A/B测试窗口让用户对比两模型(详见“偏好数据”章节)。

实验室聚焦的评测集,形成了训练与评测的紧密耦合。 比如,MMLU曾是重点评测,推理模型时代GPQA成为新宠。 实验室会不断调整评测以适应自身需求,如OpenAI发布SWE-Bench-Verified [29]。 实际上还有很多内部评测集未公开。

内部评测对下游训练的最大作用,是提升训练对比的统计效力。 通过调整评测,实验室可以降低关键信号的噪声,更好地做训练决策。

现代大模型训练栈的后训练流程极为复杂。 评测语言模型不仅仅是看答案的log概率,而是要生成大量token。 前沿实验室常用一些“小技巧”提升任务表现——最常见的是为特定评测设计专用prompt。

另一个导致评测混乱的例子,是推理时扩展(Inference-time scaling)被引入评测对比。 推理时扩展表明,模型通过生成更多token可以提升表现。 因此,控制推理token总数对评测分数影响很大,但目前还未成为业界常规。

后训练数据格式也会导致模型在不同评测格式下表现差异巨大。 比如两个流行开源数学数据集 [30] 和 MetaMath [31],仅仅因为答案格式不同(Numina用\boxed{XYZ},MetaMath用The answer is: XYZ),联合训练反而比只用单一格式效果更差。 强模型通常能兼容多种格式,但也会有最擅长的主格式。

总之,关于闭源模型评测,我们可以总结几点:

数据污染(Contamination)

当前大模型训练(不仅限于RLHF和后训练)面临的重大问题之一,是训练数据有意或无意地包含了评测数据,这就是数据污染(dataset contamination),而去污染(decontamination)则是相应的防控措施。 去污染通常通过在训练集和测试集之间做n-gram(字符或token)匹配搜索实现 [32]。 数据污染常见于多阶段网络爬取训练数据,评测集常被公开在可爬取的网站上,或用户把评测题输入模型,结果被未来模型采集进训练数据。

例如,在Tülu 3的评测去污染过程中,作者发现多个流行开源数据集都被RLHF常用评测污染 [27]。 如UltraFeedback与TruthfulQA、Evol-CodeAlpaca与HumanEval、NuminaMath与MATH、WildChat与安全评测等均有重合,都是通过8-gram重叠检测到的。

对于未公开训练数据的模型,研究者会制作轻微扰动的新基准(如MATH [33]),检验模型是否专门记住了原题或原格式。 在这种扰动基准上的高方差并不等于污染,但可能暗示模型在某些格式上过拟合,未必能迁移到真实世界。

工具与平台

目前已有许多开源评测工具可选。 包括英国安全研究院的Inspect AI [34]、HuggingFace的LightEval [35](Open LLM Leaderboard背后引擎 [36])、Eleuther AI的evaluation harness [37](基于GPT-Neo-X评测配置 [38])、AI2基于OLMES的库 [39]、斯坦福CRFM的HELM [40]、Mosaic(现Databricks)的Eval Gauntlet [41]等。

参考文献

[1]
L. Zheng 等, 《Judging llm-as-a-judge with mt-bench and chatbot arena》, Advances in Neural Information Processing Systems, 卷 36, 页 46595~46623, 2023.
[2]
Y. Dubois, B. Galambosi, P. Liang, 和 T. B. Hashimoto, 《Length-controlled alpacaeval: A simple way to debias automatic evaluators》, arXiv preprint arXiv:2404.04475, 2024.
[3]
T. Li 等, 《From Crowdsourced Data to High-Quality Benchmarks: Arena-Hard and BenchBuilder Pipeline》, arXiv preprint arXiv:2406.11939, 2024.
[4]
D. Hendrycks 等, 《Measuring massive multitask language understanding》, arXiv preprint arXiv:2009.03300, 2020.
[5]
A. Mallen, A. Asai, V. Zhong, R. Das, H. Hajishirzi, 和 D. Khashabi, 《When Not to Trust Language Models: Investigating Effectiveness and Limitations of Parametric and Non-Parametric Memories》, arXiv preprint, 2022.
[6]
S. Lin, J. Hilton, 和 O. Evans, 《Truthfulqa: Measuring how models mimic human falsehoods》, arXiv preprint arXiv:2109.07958, 2021.
[7]
M. Suzgun 等, 《Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Them》, arXiv preprint arXiv:2210.09261, 2022.
[8]
D. Dua, Y. Wang, P. Dasigi, G. Stanovsky, S. Singh, 和 M. Gardner, 《DROP: A reading comprehension benchmark requiring discrete reasoning over paragraphs》, arXiv preprint arXiv:1903.00161, 2019.
[9]
D. Hendrycks 等, 《Measuring Mathematical Problem Solving With the MATH Dataset》, NeurIPS, 2021.
[10]
K. Cobbe 等, 《Training Verifiers to Solve Math Word Problems》, arXiv preprint arXiv:2110.14168, 2021.
[11]
M. Chen 等, 《Evaluating Large Language Models Trained on Code》, 2021, 载于: https://arxiv.org/abs/2107.03374
[12]
J. Liu, C. S. Xia, Y. Wang, 和 L. Zhang, 《Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation》, 收入 Thirty-seventh Conference on Neural Information Processing Systems, 2023. 载于: https://openreview.net/forum?id=1qvx610Cu7
[13]
J. Zhou 等, 《Instruction-Following Evaluation for Large Language Models》. 2023年. 载于: https://arxiv.org/abs/2311.07911
[14]
D. Rein 等, 《GPQA: A Graduate-Level Google-Proof Q&A Benchmark》, arXiv preprint arXiv:2311.12022, 2023.
[15]
L. Phan, A. Gatti, Z. Han, N. Li, 和 H. et al. Zhang, 《Humanity’s Last Exam》, arXiv preprint arXiv:2501.14249, 2025.
[16]
R. Aleithan, H. Xue, M. M. Mohajer, E. Nnorom, G. Uddin, 和 S. Wang, 《SWE-Bench+: Enhanced Coding Benchmark for LLMs》, arXiv preprint arXiv:2410.06992, 2024.
[17]
N. Jain 等, 《LiveCodeBench: Holistic and Contamination-Free Evaluation of Large Language Models for Code》, arXiv preprint arXiv:2403.07974, 2024.
[18]
S. AI, 《SEAL LLM Leaderboards: Expert-Driven Private Evaluations》. 2024年. 载于: https://scale.com/leaderboard
[19]
W.-L. Chiang 等, 《Chatbot arena: An open platform for evaluating llms by human preference》, arXiv preprint arXiv:2403.04132, 2024.
[20]
S. Schulhoff 等, 《The prompt report: A systematic survey of prompting techniques》, arXiv preprint arXiv:2406.06608, 2024.
[21]
T. B. Brown 等, 《Language Models are Few-Shot Learners》, arXiv preprint arXiv:2005.14165, 2020.
[22]
J. Robinson, C. M. Rytting, 和 D. Wingate, 《Leveraging Large Language Models for Multiple Choice Question Answering》, 收入 International Conference on Learning Representations, 2023. 载于: https://openreview.net/forum?id=upQ4o-ygvJ
[23]
J. Wei 等, 《Chain-of-thought prompting elicits reasoning in large language models》, Advances in neural information processing systems, 卷 35, 页 24824~24837, 2022.
[24]
J. Wei 等, 《Finetuned Language Models Are Zero-Shot Learners》, 收入 International Conference on Learning Representations, 2022.
[25]
V. Sanh 等, 《Multitask Prompted Training Enables Zero-Shot Task Generalization》, 收入 International Conference on Learning Representations, 2022.
[26]
T. Kojima, S. S. Gu, M. Reid, Y. Matsuo, 和 Y. Iwasawa, 《Large language models are zero-shot reasoners》, Advances in neural information processing systems, 卷 35, 页 22199~22213, 2022.
[27]
N. Lambert 等, 《T\(\backslash\)" ULU 3: Pushing Frontiers in Open Language Model Post-Training》, arXiv preprint arXiv:2411.15124, 2024.
[28]
J. Achiam 等, 《Gpt-4 technical report》, arXiv preprint arXiv:2303.08774, 2023.
[29]
OpenAI, 《Introducing SWE-bench Verified》. 2024年8月. 载于: https://openai.com/index/introducing-swe-bench-verified/
[30]
J. Li 等, 《Numinamath: The largest public dataset in ai4maths with 860k pairs of competition math problems and solutions》, Hugging Face repository, 卷 13, 页 9, 2024.
[31]
L. Yu 等, 《Metamath: Bootstrap your own mathematical questions for large language models》, arXiv preprint arXiv:2309.12284, 2023.
[32]
A. K. Singh 等, 《Evaluation data contamination in LLMs: how do we measure it and (when) does it matter?》, arXiv preprint arXiv:2411.03923, 2024.
[33]
K. Huang 等, 《MATH-Perturb: Benchmarking LLMs’ Math Reasoning Abilities against Hard Perturbations》, arXiv preprint arXiv:2502.06453, 2025.
[34]
UK AI Safety Institute, 《Inspect AI: Framework for Large Language Model Evaluations》. https://github.com/UKGovernmentBEIS/inspect_ai, 2024年.
[35]
C. Fourrier, N. Habib, H. Kydlicek, T. Wolf, 和 L. Tunstall, 《LightEval: A lightweight framework for LLM evaluation》. https://github.com/huggingface/lighteval, 2023年.
[36]
C. Fourrier, N. Habib, A. Lozovskaya, K. Szafer, 和 T. Wolf, 《Open LLM Leaderboard v2》. https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard; Hugging Face, 2024年.
[37]
L. Gao 等, 《A Framework for Few-Shot Language Model Evaluation》. Zenodo, 2023年. doi: 10.5281/zenodo.10256836.
[38]
S. Black 等, 《GPT-NeoX-20B: An Open-Source Autoregressive Language Model》, 收入 Proceedings of the ACL Workshop on Challenges & Perspectives in Creating Large Language Models, 2022. 载于: https://arxiv.org/abs/2204.06745
[39]
Y. Gu, O. Tafjord, B. Kuehl, D. Haddad, J. Dodge, 和 H. Hajishirzi, 《OLMES: A Standard for Language Model Evaluations》, arXiv preprint arXiv:2406.08446, 2024.
[40]
P. Liang 等, 《Holistic Evaluation of Language Models》, Transactions on Machine Learning Research, 2023, doi: 10.1111/nyas.15007.
[41]
MosaicML, 《Mosaic Eval Gauntlet v0.3.0 Evaluation Suite》. https://github.com/mosaicml/llm-foundry/blob/main/scripts/eval/local_data/EVAL_GAUNTLET.md, 2024年.
← 上一章: 合成数据与蒸馏 下一章: 过度优化 →