Large Language Models as Code Executors: An Exploratory Study

Chenyang Lyu, Lecheng Yan, Rui Xing, Wenxi Li, Younes Samih +2 more
10/9/2024
cs.CLcs.AI

No confident code implementation found for this paper. 2 possible matches can be shown below.

Abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 2 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{lyu2024large,
  title  = {Large Language Models as Code Executors: An Exploratory Study},
  author = {Chenyang Lyu and Lecheng Yan and Rui Xing and Wenxi Li and Younes Samih and Tianbo Ji and Longyue Wang},
  year   = {2024},
  eprint = {2410.06667},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.06667v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.06667.svg)](https://codeofpaper.com/paper/2410.06667)

Discussion