arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.06667cs.CLcs.AI
收藏

大型语言模型作为代码执行器:一项探索性研究

Large Language Models as Code Executors: An Exploratory Study

Mohamed bin Zayed University of Artificial Intelligence(穆罕默德·本·扎耶德人工智能大学);Xinjiang University(新疆大学);University of Melbourne(墨尔本大学);Tsinghua University(清华大学);Shanghai Jiao Tong University(上海交通大学);IBM Research(IBM研究院);Nantong University(南通大学);Alibaba(阿里巴巴)

Chenyang Lyu, Lecheng Yan, Rui Xing, Wenxi Li, Younes Samih, Tianbo Ji, Longyue Wang

AI总结:

本文首次探索将大型语言模型作为代码执行器,评估多种主流LLM的代码执行能力,并提出迭代指令提示(IIP)技术逐行处理代码,显著提升较弱模型的执行准确率。

摘要:

大型语言模型(LLMs)的能力已显著提升,从自然语言处理扩展到代码理解和生成等复杂任务。我们将LLMs的能力范围扩展到更广泛的背景,使用LLMs执行代码片段以获取输出。本文开创性地探索了LLMs作为代码执行器的应用,即将代码片段直接输入模型进行执行并返回输出。我们首次全面考察了这种可行性,涵盖了多种LLMs,包括OpenAI的o1、GPT-4o、GPT-3.5、DeepSeek和Qwen-Coder。值得注意的是,o1模型在代码执行中达到了90%以上的准确率,而其他模型则表现出较低的准确率水平。此外,我们引入了一种迭代指令提示(IIP)技术,该技术逐行处理代码片段,使较弱模型的准确率平均提升了7.22%(最高提升18.96%),相较于CoT提示实现了3.86%的绝对平均提升(最高提升19.46%)。我们的研究不仅突显了LLMs在编程领域的变革潜力,还为未来在自动化编程和复杂任务完成方面的进步奠定了基础。

英文摘要:

The capabilities of Large Language Models (LLMs) have significantly evolved, extending from natural language processing to complex tasks like code understanding and generation. We expand the scope of LLMs' capabilities to a broader context, using LLMs to execute code snippets to obtain the output. This paper pioneers the exploration of LLMs as code executors, where code snippets are directly fed to the models for execution, and outputs are returned. We are the first to comprehensively examine this feasibility across various LLMs, including OpenAI's o1, GPT-4o, GPT-3.5, DeepSeek, and Qwen-Coder. Notably, the o1 model achieved over 90% accuracy in code execution, while others demonstrated lower accuracy levels. Furthermore, we introduce an Iterative Instruction Prompting (IIP) technique that processes code snippets line by line, enhancing the accuracy of weaker models by an average of 7.22% (with the highest improvement of 18.96%) and an absolute average improvement of 3.86% against CoT prompting (with the highest improvement of 19.46%). Our study not only highlights the transformative potential of LLMs in coding but also lays the groundwork for future advancements in automated programming and the completion of complex tasks.

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

↑