A bilingual (English/Chinese) bench showing how reinforcement learning from human feedback shapes a language model: answers, human rankings, a reward model and policy optimisation
RLHF is how a chatbot learns which answers people actually like. This bench runs the recipe from left to right, one station at a time. RLHF 让聊天模型学会人们更喜欢哪种回答。拖动空白处可以转动视角。
Everything on this bench is a small simulation. No real AI model is trained. 这里的一切都是模拟。
First a large language model reads a huge amount of text and learns to predict the next word. It becomes good at continuing text, but not yet at doing what you ask. 预训练模型擅长接着写,但还不太懂得听从指令。
In the InstructGPT study, the starting model was GPT-3, with 175 billion weights. Real recipes also fine-tune on example answers written by people first.
Give the model one prompt and let it answer several times. Because it picks words with some randomness, each answer comes out different. 同一个提示,模型会给出几个不同的回答。
In InstructGPT, people saw between 4 and 9 answers to each prompt.
Now you are the evaluator. Tap the cards from the best answer to the worst, and they slide into ranked places. People compare answers instead of grading them, because we agree more easily on which of two is better. 请从最好到最差依次点击卡片。
Tap a ranked card to undo it. The button ranks them in a sample order.
Your ranking becomes pairs: this answer beat that one. A second network, the reward model, learns to give each answer one score, so the winner of every pair scores higher. 奖励模型学会给回答打分,模仿人类的偏好。
The reward model predicts what people prefer. It writes no text and it is not a person.
Now the language model, called the policy, practises: it answers, the reward model scores it, and its weights shift toward higher scores. A leash called the KL penalty stops it drifting too far from the original model. 策略优化让模型朝高分方向调整,KL 约束防止它偏离太远。
The real algorithm is usually PPO, Proximal Policy Optimization. Without the leash a model can learn to game the scorer.
After practice, the model gives the kind of answer people ranked highest far more often. It learned no new facts here; it learned which style of answer to prefer. 模型更常给出人们喜欢的回答,但并没有学到新知识。
In InstructGPT, people preferred a 1.3 billion weight RLHF model to the 175 billion weight GPT-3.
This bench used four answers, one ranking and a few numbers. Real RLHF uses tens of thousands of comparisons from many people and changes billions of weights on large computers. Your choices here never leave this page. 真实的训练规模大得多,你的选择不会改变任何真实模型。
RLHF also has limits: people disagree, and a model can still make mistakes.