Sampling 与 Decoding:从概率到文字
This content is not available in your language yet.
直觉版:模型给概率,人来定策略
Section titled “直觉版:模型给概率,人来定策略”LLM 每一步输出的不是一个确定答案,而是一张“下一个 token 概率表”。解码策略决定如何从这张表里选 token。贪心解码总选最高概率,稳定但容易平;采样会引入随机性,更适合写作、头脑风暴和多样化候选。
Temperature 调整分布尖锐程度;top-k 只保留概率最高的 k 个 token;top-p 保留累计概率达到 p 的最小集合。它们不是模型能力本身,而是推理时的控制旋钮。
工程版:可靠性来自约束与评估
Section titled “工程版:可靠性来自约束与评估”生产应用通常不会只调一个 temperature。结构化输出会结合 JSON schema、工具调用或受限解码;问答系统会降低随机性并增加引用;创作系统会允许更高多样性。Chain-of-thought 提示能改变模型内部推理轨迹,但也会增加 token 成本和泄露中间错误的风险。
评估时要记录解码参数,因为同一模型在不同 temperature、top-p 下可能表现完全不同。线上回归测试应固定随机种子或使用确定性策略;开放式产品则应衡量多样性、事实性、拒答率和用户满意度的综合结果。
References
- Language Models are Few-Shot Learners
OpenAI's GPT-3 paper demonstrates that a 175B parameter language model can perform diverse tasks through few-shot in-context learning without fine-tuning. It established the paradigm that scale unlocks emergent capabilities and launched the era of prompt engineering.
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Introduces chain-of-thought prompting: adding intermediate reasoning steps to prompts dramatically improves LLM performance on math, logic, and commonsense reasoning tasks. This simple technique brought LLM reasoning capabilities close to human-level performance.