Large Language Models Are Reasoning Teachers

Paper name

Large Language Models Are Reasoning Teachers

Paper Reading Note

URL: https://arxiv.org/pdf/2212.10071.pdf
twitter 宣传: https://twitter.com/itsnamgyu/status/1605516353439354880

TL;DR

  • 提出了 Fine-tune-CoT 方法,旨在利用非常大的语言模型 (LMs) 的CoT推理能力来教导小模型如何解决复杂任务,蒸馏出来的小模型在某些数据集上精度甚至能超过 teacher 大模型

Introduction

背景

  • 最近的研究表明,通过包含思维链 (CoT) 推理或促使模型一步一步地思考的几个示例,可以在大语言模型 (LLM) 中激发复杂推理能力。
  • 基于提示的CoT推理方法的一个主要缺点是它们依赖于跨越数千亿参数的超大模型,由于巨大的计算需求和推理成本,这些模型无法大规模部署
  • 虽然有人试图通过显式推理步骤来微调小模型来解决这个问题,但它们需要复杂的推理注释,通常还需要特定于任务的训练设置
  • 本文希望在小模型中实现复杂的推理,以便在实际应用中使用,提出了一种名为 Fine-tune-CoT 的方法,旨在利用非常大的语言模型 (LMs) 的CoT推理能力来教导小模型如何解决复杂任务

本文方案

  • 应用现有的 zero-shot CoT 提示从非常大的教师模型中生成理据,并使用它们来微调较小的学生模型
    • 该方法可以很容易地应用于新的下游任务,因为基于 LM 的教师具有显著的 zero-shot 推理能力,没有手工推理注释或任务特定工程
    • 保留了基于提示的CoT的多功能性,而不需要过大的模型
      在这里插入图片描述
  • Fine-tune-CoT 的蒸馏步骤
    1. 一个非常大的教师模型被提示通过生成多步推理解释(绿色)来解决复杂的问题(黄色)
    2. 根据最终预测的正确性(红色)对生成的补全进行筛选。问题、基本原理和答案用于组成由提示和多步骤完成组成的推理示例
    3. 精心策划的推理样本用于微调一个小的、轻量级的学生模型
      同时基于 LM 的教师模型支持了多样化的推理——为每个原始样本生成多个不同的基本原理,以丰富微调数据。这提高了学生模型的性能,并且不需要人工注释

Dataset/Algorithm/Model/Experiment Detail

实现方式

Step 1. Reasoning generation
  • 首先利用一个大型教师模型为给定的任务生成CoT推理解释
  • 考虑一个标准样本Si,由一个问题qi和它的真实答案ai组成。使用 Zero-shot-CoT 模型,提示教师模型生成一个推理解释 r^i\hat{r}_ir^i 来解决 qi,生成的最终答案为 a^i\hat{a}_ia^i
    • 生成的文本序列,包括提示符和生成,采用以下形式: “Q: . A: Let’s think step by step. <ˆri> Therefore, the answer is <ˆai>”
Step 2. Curation
  • 为了准备微调样本,过滤生成的样本并将它们重新格式化为提示补全对
    • 对于过滤,简单地将教师模型的最终预测 a^i\hat{a}_ia^i 与 ground-truth 答案 ai 进行比较,挑选预测与 gt 一致的样本
    • 将(Si, r^i\hat{r}_ir^i , a^i\hat{a}_ia^i ) 重新打包成一个推理样本S’i = (pi, ci),一个提示补全对
Step 3. Fine-tuneFine-tune
  • 使用广泛可访问的 OpenAI API 在组装的推理样本上对一个小型预训练的学生模型进行微调。使用与预训练期间相同的训练目标,即 autoregressive language modeling objective 或 next-token prediction
Diverse reasoning
  • 为了使微调- cot的样本效率最大化,为每个训练样本生成多个推理解释,从而增加微调数据
    • 具体而言,对于给定的样本 Si,采用随机采样策略,即大 T 的温度采样,而不是采用贪婪解码的 Zero-shot-CoT 来获得单个解释-答案对 (ei, ai),以获得 D 个不同的样本对

实验结果

实验配置
  • 模型列表,学生模型比非常大的教师模型小25 - 500倍
    在这里插入图片描述
  • 用于对比的 baseline 模型
    在这里插入图片描述
    Zero-shot-CoT: task-agnostic prompting baseline
    finetuning:使用原始训练样本进行 finetune
    Fine-tune-CoT:本文方法
实验结果
  • 12 个数据集上的对比结果,“Random” 指的是在多项选择题的任务中,根据选项的数量随机猜测的表现,即只能以正确格式输出随机答案的模型的性能。
    在这里插入图片描述
    Fine-tune-CoT 性能超过 Zero-shot-CoT
    一些小模型效果超过了大模型:Shuffled Objects and Coin Flip
    Fine-tune vs Fine-tune-CoT: Date Understanding and Shuffle Objects 数据上 Fine-tune-CoT 比 Fine-tune 精度明显高(Fine-tune 精度与 Random 差不多),某些数据集上 Fine-tune 精度也会比 Fine-tune-CoT 高,不过 Fine-tune-CoT 性能随着模型大小显示出更可靠的缩放曲线,并在需要多个步骤的任务中显示出明显的优势

Thoughts

  • 利用大模型提取一些更利于小模型学习的训练样例,并将训练样例转换为更利于 student 模型学习的形式,看起来挺合理
### Chain-of-Thought Prompting Mechanism in Large Language Models In large language models, chain-of-thought prompting serves as a method to enhance reasoning capabilities by guiding the model through structured thought processes. This approach involves breaking down complex problems into simpler components and providing step-by-step guidance that mirrors human cognitive processing. The creation of these prompts typically includes selecting examples from training datasets where each example represents part of an overall problem-solving process[^2]. By decomposing tasks into multiple steps, this technique encourages deeper understanding and more accurate predictions compared to traditional methods. For instance, when faced with multi-hop question answering or logical deduction challenges, using such chains allows models not only to generate correct answers but also articulate intermediate thoughts leading up to those conclusions. Such transparency facilitates better interpretability while improving performance on various NLP benchmarks. ```python def create_chain_of_thought_prompt(task_description, examples): """ Creates a chain-of-thought prompt based on given task description and examples. Args: task_description (str): Description of the task at hand. examples (list): List containing tuples of input-output pairs used for demonstration purposes. Returns: str: Formatted string representing the final prompt including both instructions and sample cases. """ formatted_examples = "\n".join([f"Input: {ex[0]}, Output: {ex[1]}" for ex in examples]) return f""" Task: {task_description} Examples: {formatted_examples} Now try solving similar questions following above pattern. """ # Example usage examples = [ ("What color do you get mixing red and blue?", "Purple"), ("If it rains tomorrow, will we have our picnic?", "No") ] print(create_chain_of_thought_prompt("Solve logic puzzles", examples)) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
OSZAR »