arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.02575cs.CL
收藏

语言模型即编译器:模拟伪代码执行改进语言模型的算法推理

Language Models as Compilers: Simulating Pseudocode Execution Improves Algorithmic Reasoning in Language Models

Yonsei University(延世大学);KAIST AI(韩国科学技术院人工智能学院)

Hyungjoo Chae, Yeonghyeon Kim, Seungone Kim, Kai Tzu-iunn Ong, Beong-woo Kwak, Moohyeon Kim, Seonghwan Kim, Taeyoon Kwon, Jiwan Chung, Youngjae Yu, Jinyoung Yeo

AI总结:

本文提出 Think-and-Execute 框架,先抽取任务级共享伪代码逻辑,再按实例模拟执行,在七项算法推理任务上优于 CoT、PoT 等基线。

摘要:

算法推理是指理解问题背后的复杂模式,并将其分解为一系列通向解决方案的推理步骤的能力。算法推理的这种性质使其对大型语言模型(LLM)构成挑战,尽管它们已在其他推理任务中展现出可观性能。在此背景下,近期一些研究受编程语言严格且精确语法的启发,使用编程语言(例如 Python)来表达求解给定实例或问题所需的逻辑(例如 Program-of-Thought)。然而,在单次推理调用中即时编写能够表达正确逻辑的可执行代码并非易事。此外,专门为某个实例生成的代码无法复用于其他实例,即使这些实例来自同一任务,并且可能需要相同的求解逻辑。本文提出 Think-and-Execute,这是一个将语言模型的推理过程分解为两个步骤的新颖框架。(1)在 Think 中,我们发现用于求解给定任务、并在所有实例之间共享的任务级逻辑,然后用伪代码表达该逻辑;(2)在 Execute 中,我们进一步使生成的伪代码适配每个实例,并模拟代码的执行。通过在七项算法推理任务上的大量实验,我们证明了 Think-and-Execute 的有效性。与若干执行实例级推理的强基线方法(例如 CoT 和 PoT)相比,我们的方法更好地提升了语言模型的推理能力,这表明发现任务级逻辑是有帮助的。我们还表明,与自然语言相比,伪代码能够更好地指导语言模型的推理,即便这些模型经过训练后本来是遵循自然语言指令的。

英文摘要:

Algorithmic reasoning refers to the ability to understand the complex patterns behind the problem and decompose them into a sequence of reasoning steps towards the solution. Such nature of algorithmic reasoning makes it a challenge for large language models (LLMs), even though they have demonstrated promising performance in other reasoning tasks. Within this context, some recent studies use programming languages (e.g., Python) to express the necessary logic for solving a given instance/question (e.g., Program-of-Thought) as inspired by their strict and precise syntaxes. However, it is non-trivial to write an executable code that expresses the correct logic on the fly within a single inference call. Also, the code generated specifically for an instance cannot be reused for others, even if they are from the same task and might require identical logic to solve. This paper presents Think-and-Execute, a novel framework that decomposes the reasoning process of language models into two steps. (1) In Think, we discover a task-level logic that is shared across all instances for solving a given task and then express the logic with pseudocode; (2) In Execute, we further tailor the generated pseudocode to each instance and simulate the execution of the code. With extensive experiments on seven algorithmic reasoning tasks, we demonstrate the effectiveness of Think-and-Execute. Our approach better improves LMs' reasoning compared to several strong baselines performing instance-specific reasoning (e.g., CoT and PoT), suggesting the helpfulness of discovering task-level logic. Also, we show that compared to natural language, pseudocode can better guide the reasoning of LMs, even though they are trained to follow natural language instructions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑