Code Execution with Pre-trained Language Models

Chenxiao Liu, Shuai Lu, Weizhu Chen, Daxin Jiang, Alexey Svyatkovskiy +3 more
5/8/2023
cs.PLcs.AIcs.CL

No official code found. Best implementation: microsoft/CodeBERT (2,786 stars, MIT, last commit 2023-07-09).

Abstract

Code execution is a fundamental aspect of programming language semantics that reflects the exact behavior of the code. However, most pre-trained models for code intelligence ignore the execution trace and only rely on source code and syntactic structures. In this paper, we investigate how well pre-trained models can understand and perform code execution. We develop a mutation-based data augmentation technique to create a large-scale and realistic Python dataset and task for code execution, which challenges existing models such as Codex. We then present CodeExecutor, a Transformer model that leverages code execution pre-training and curriculum learning to enhance its semantic comprehension. We evaluate CodeExecutor on code execution and show its promising performance and limitations. We also demonstrate its potential benefits for code intelligence tasks such as zero-shot code-to-code search and text-to-code generation. Our analysis provides insights into the learning and generalization abilities of pre-trained models for code execution.

View on arXivView PDF

Code Implementations(1)

microsoft/CodeBERTCommunity100%
MIT

CodeBERT

2,786498Shell, PythonJun 17, 20203 years agoMIT

Similar Papers

Cite this paper

@article{liu2023code,
  title  = {Code Execution with Pre-trained Language Models},
  author = {Chenxiao Liu and Shuai Lu and Weizhu Chen and Daxin Jiang and Alexey Svyatkovskiy and Shengyu Fu and Neel Sundaresan and Nan Duan},
  year   = {2023},
  eprint = {2305.05383},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2305.05383v1}
}

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/2305.05383.svg)](https://codeofpaper.com/paper/2305.05383)

Discussion