Code Prompting Elicits Conditional Reasoning Abilities in Text+Code LLMs
作者: Haritz Puerto, Martin Tutek, Somak Aditya, Xiaodan Zhu, Iryna Gurevych
分类: cs.CL
发布日期: 2024-01-18 (更新: 2024-09-28)
备注: EMNLP Main 2024. Code, prompt templates, prompts, and outputs are publicly available at https://github.com/UKPLab/arxiv2024-conditional-reasoning-llms
💡 一句话要点
提出代码提示以提升文本+代码LLM的条件推理能力
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 条件推理 代码提示 大型语言模型 推理能力 自然语言处理
📋 核心要点
- 现有的推理技术对LLMs的推理能力触发机制理解不足,限制了其在推理任务中的应用效果。
- 本文提出的代码提示方法通过将自然语言问题转化为代码,直接提示LLM,从而激发其条件推理能力。
- 实验结果显示,代码提示在多个条件推理数据集上提升了LLMs的性能,GPT 3.5的提升幅度达到22.52个百分点。
📝 摘要(中文)
推理是语言理解的基本组成部分。近期的提示技术,如思维链,已显著提升了大型语言模型(LLMs)在各种推理任务上的表现。然而,目前对LLMs在推理阶段触发推理能力的机制仍缺乏深入理解。本文提出了代码提示,这是一种将自然语言问题转化为代码的提示链,直接利用生成的代码提示LLM,而无需外部代码执行。我们假设代码提示能够激发训练于文本和代码的LLMs的某些推理能力,并利用该方法提升条件推理能力。实验结果表明,代码提示在多个条件推理数据集上显著提升了多种LLMs的性能。
🔬 方法详解
问题定义:本文旨在解决现有推理方法对LLMs推理能力触发机制理解不足的问题,尤其是在推理阶段的应用效果不佳。
核心思路:通过引入代码提示,将自然语言问题转化为代码形式,直接利用生成的代码进行提示,旨在激发LLMs的条件推理能力。
技术框架:整体架构包括三个主要模块:首先是自然语言问题的解析与转化为代码,其次是利用生成的代码进行LLM的提示,最后是评估模型在条件推理任务上的表现。
关键创新:代码提示作为一种新颖的提示技术,能够有效提升LLMs在条件推理任务上的表现,区别于传统的自然语言提示方法。
关键设计:在实验中,输入问题的代码格式化被认为是性能提升的关键因素,同时代码提示还提高了上下文学习的样本效率,并促进了变量或实体的状态跟踪。
🖼️ 关键图片
📊 实验亮点
实验结果显示,代码提示在多个条件推理数据集上显著提升了多种LLMs的性能,GPT 3.5的提升幅度达到22.52个百分点,Mixtral提升7.75个百分点,Mistral提升16.78个百分点,展示了该方法的有效性。
🎯 应用场景
该研究的潜在应用领域包括智能问答系统、编程辅助工具和教育技术等。通过提升LLMs的条件推理能力,可以更好地支持复杂问题的解决和决策制定,具有重要的实际价值和未来影响。
📄 摘要(原文)
Reasoning is a fundamental component of language understanding. Recent prompting techniques, such as chain of thought, have consistently improved LLMs' performance on various reasoning tasks. Nevertheless, there is still little understanding of what triggers reasoning abilities in LLMs in the inference stage. In this paper, we introduce code prompting, a chain of prompts that transforms a natural language problem into code and directly prompts the LLM using the generated code without resorting to external code execution. We hypothesize that code prompts can elicit certain reasoning capabilities of LLMs trained on text and code and utilize the proposed method to improve conditional reasoning, the ability to infer different conclusions depending on the fulfillment of certain conditions. We find that code prompting exhibits a high-performance boost for multiple LLMs (up to 22.52 percentage points on GPT 3.5, 7.75 on Mixtral, and 16.78 on Mistral) across multiple conditional reasoning datasets. We then conduct comprehensive experiments to understand how code prompts trigger reasoning abilities and which capabilities are elicited in the underlying models. Our analysis of GPT 3.5 reveals that the code formatting of the input problem is essential for performance improvement. Furthermore, code prompts improve sample efficiency of in-context learning and facilitate state tracking of variables or entities.