arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.09074cs.LGcs.AIcs.CLcs.PL
收藏

大型语言模型面临的代码模拟挑战

Code Simulation Challenges for Large Language Models

University of Oxford(牛津大学);Technical University of Munich(慕尼黑工业大学);University of Salerno(萨勒诺大学);University of Bologna(博洛尼亚大学);University of Leeds(利兹大学)

Emanuele La Malfa, Christoph Weinhuber, Orazio Torre, Fangru Lin, Samuele Marro, Anthony Cohn, Nigel Shadbolt, Michael Wooldridge

AI总结:

本文构建多类代码模拟基准评估LLM的算法执行能力,发现复杂度、模式识别与记忆显著影响表现,并提出逐行模拟的CoSm提示方法以提升性能。

摘要:

许多推理、规划和问题解决任务都具有内在的算法性质:正确模拟每一步是正确解决这些任务的充分条件。本工作研究大型语言模型(LLM)在多大程度上能够模拟编码和算法任务,以深入认识其在此类算法推理任务中的通用能力。我们引入了面向直线程序、包含关键路径的代码以及近似指令和冗余指令的基准。我们还利用排序算法和嵌套循环评估了LLM的模拟能力,并表明一个例程的计算复杂度会直接影响LLM模拟其执行的能力。尽管最强大的LLM表现出相对较强的模拟能力,但这一过程较为脆弱,似乎严重依赖模式识别,并受到记忆的影响。我们提出了一种新颖的现成提示方法 Chain of Simulation(CoSm),它指示LLM逐行模拟代码执行/遵循编译器的计算模式。CoSm有效帮助LLM减少记忆和浅层模式识别,同时提升模拟性能。我们认为CoSm在代码模拟中的成功对其他通用例程模拟推理任务具有启发意义。

英文摘要:

Many reasoning, planning, and problem-solving tasks share an intrinsic algorithmic nature: correctly simulating each step is a sufficient condition to solve them correctly. This work studies to what extent Large Language Models (LLMs) can simulate coding and algorithmic tasks to provide insights into general capabilities in such algorithmic reasoning tasks. We introduce benchmarks for straight-line programs, code that contains critical paths, and approximate and redundant instructions. We further assess the simulation capabilities of LLMs with sorting algorithms and nested loops and show that a routine's computational complexity directly affects an LLM's ability to simulate its execution. While the most powerful LLMs exhibit relatively strong simulation capabilities, the process is fragile, seems to rely heavily on pattern recognition, and is affected by memorisation. We propose a novel off-the-shelf prompting method, Chain of Simulation (CoSm), which instructs LLMs to simulate code execution line by line/follow the computation pattern of compilers. CoSm efficiently helps LLMs reduce memorisation and shallow pattern recognition while improving simulation performance. We consider the success of CoSm in code simulation to be inspirational for other general routine simulation reasoning tasks.

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

↑