Self-Training Elicits Concise Reasoning in Large Language Models

摘要

思维链(CoT)推理使大语言模型(LLMs)能够通过中间token进行额外计算,以解决复杂任务。然而,我们认为典型的推理过程包含许多冗余token,导致了额外的推理成本。通过研究当前大语言模型的输出分布,我们发现它们相较于默认行为,具备更简洁推理的潜在能力。为激发这种能力,我们提出了简单的微调方法,在特定任务设置中,利用通过N选1采样(best-of-N sampling)和少样本条件设定(few-shot conditioning)生成的自生成简洁推理路径。我们的组合方法在GSM8K和MATH数据集上,对五个模型系列进行实验,结果显示平均输出token减少了30%,同时保持了平均准确率。通过利用大语言模型的基本随机性和上下文学习能力,我们的自训练方法在广泛的模型上都能有效地激发简洁推理,包括那些经过大量后期训练的模型。
在这里插入图片描述

引言

思维链(CoT)推理显著提升了大语言模型(LLMs)执行复杂任务的能力(Wei等人,2022b)。CoT推理的有效性归因于推理过程中分配的额外计算量,因为每个中间推理标记都能让模型通过其参数进行一次额外的前向传递(Nye等人,2021;Wei等人,2022b)。另一方面,这必然会带来额外的推理成本和延迟,大致与输出标记的数量成正比(Agrawal等人,2024;Ho等人,2024)。

我们认为,当前的模型在完成任务时,往往会生成比必要数量更多的标记,从而产生额外的推理成本。从原始模型分布中采样得到的典型推理链

### 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)) ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UnknownBody

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值