Large language models (LLMs) have recently demonstrated an impressive ability to perform arithmetic and symbolic reasoning tasks, when provided with a few examples at test time ("few-shot prompting"). Much of this success can be attributed to prompting methods such as "chain-of-thought'', which employ LLMs for both understanding the problem description by decomposing it into steps, as well as solving each step of the problem. While LLMs seem to be adept at this sort of step-by-step decomposition, LLMs often make logical and arithmetic mistakes in the solution part, even when the problem is decomposed correctly. In this paper, we present Program-Aided Language models (PAL): a novel approach that uses the LLM to read natural language problems and generate programs as the intermediate reasoning steps, but offloads the solution step to a runtime such as a Python interpreter. With PAL, decomposing the natural language problem into runnable steps remains the only learning task for the LLM, while solving is delegated to the interpreter. We demonstrate this synergy between a neural LLM and a symbolic interpreter across 13 mathematical, symbolic, and algorithmic reasoning tasks from BIG-Bench Hard and other benchmarks. In all these natural language reasoning tasks, generating code using an LLM and reasoning using a Python interpreter leads to more accurate results than much larger models. For example, PAL using Codex achieves state-of-the-art few-shot accuracy on the GSM8K benchmark of math word problems, surpassing PaLM-540B which uses chain-of-thought by absolute 15% top-1. Our code and data are publicly available at http://reasonwithpal.com/ .
翻译:大型语言模型(LLMs)近期在少量示例提示(少样本提示)下,展现出了执行算术和符号推理任务的惊人能力。这一成功很大程度上归功于"思维链"等提示方法——该方法让LLMs既通过分解步骤理解问题描述,又负责求解每个问题步骤。尽管LLMs似乎擅长这种逐步分解,但在正确分解问题后,其求解过程仍常出现逻辑与算术错误。本文提出程序辅助语言模型(PAL):一种利用LLM阅读自然语言问题并生成程序作为中间推理步骤,但将求解步骤卸载至运行时(如Python解释器)的新方法。采用PAL后,LLM仅需学习将自然语言问题分解为可执行步骤,而求解任务则交由解释器完成。我们通过BIG-Bench Hard及其他基准测试中的13项数学、符号与算法推理任务,验证了神经LLM与符号解释器之间的这种协同效应。在所有自然语言推理任务中,使用LLM生成代码并通过Python解释器进行推理,所得结果比更大规模的模型更为精确。例如,采用Codex的PAL在数学应用题基准GSM8K上实现了少样本最优精度,相比使用思维链的PaLM-540B,绝对top-1准确率提升了15%。我们的代码与数据已公开于http://reasonwithpal.com/。