Large Language Models as Code Executors: An Exploratory Study
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 12 papers in the map (data through 14 Oct 2026). Builds on 14 of its 19 references that are in the map. First posted on arXiv 9 Oct 2024.
Builds on
14 of 19 references.
References · 14
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023GPT-4 Technical Reportcited by 18,396
- 2022Training language models to follow instructions with human feedbackcited by 15,971
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2023A Multitask, Multilingual, Multimodal Evaluation of ChatGPT on Reasoning, Hallucination, and Interactivitycited by 894
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
- 2023Document-Level Machine Translation with Large Language Modelscited by 90
Built on by
Citing papers per year: 2025: 10; 2026: 2.
12 papers.
- 2025ProgCo: Program Helps Self-Correction of Large Language Modelscited by 14
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoningcited by 14
- 2025CoCoNUT: Structural Code Understanding does not fall out of a treecited by 7
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Modelscited by 7
- 2025Advancing the Scientific Method with Large Language Models: From Hypothesis to Discoverycited by 7
- 2025LLMs Lean on Priors, Not Programming Language Semanticscited by 6
- 2025SURGE: On the Potential of Large Language Models as General-Purpose Surrogate Code Executorscited by 3
- 2025LongReasonArena: A Long Reasoning Benchmark for Large Language Modelscited by 3
- 2025Can LLMs Solve ASP Problems? Insights from a Benchmarking Study (Extended Version)cited by 1
- 2025StackPilot: Autonomous Function Agents for Scalable and Environment-Free Code Executioncited by 0
- 2026Failing to Explore: Language Models on Interactive Taskscited by 0
- 2026Predicting Program Exit Code with LLMs and Programming Language Semanticscited by 0
- 2026Predicting Program Exit Code with LLMs and Programming Language Semantics1 Sep 2026
- 2026Failing to Explore: Language Models on Interactive Tasks29 Jan 2026
- 2025LLMs Lean on Priors, Not Programming Language Semantics3 Oct 2025
- 2025LongReasonArena: A Long Reasoning Benchmark for Large Language Models26 Aug 2025
- 2025StackPilot: Autonomous Function Agents for Scalable and Environment-Free Code Execution6 Aug 2025
- 2025Can LLMs Solve ASP Problems? Insights from a Benchmarking Study (Extended Version)26 Jul 2025
- 2025Advancing the Scientific Method with Large Language Models: From Hypothesis to Discovery22 May 2025
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning19 Apr 2025
- 2025SURGE: On the Potential of Large Language Models as General-Purpose Surrogate Code Executors16 Feb 2025
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Models5 Feb 2025
- 2025CoCoNUT: Structural Code Understanding does not fall out of a tree27 Jan 2025
- 2025ProgCo: Program Helps Self-Correction of Large Language Models2 Jan 2025