Skip to main content
QUICK REVIEW

[Paper Review] CRUXEval: A Benchmark for Code Reasoning, Understanding and Execution

Alex Gu, Baptiste Rozière|arXiv (Cornell University)|Jan 5, 2024
Parallel Computing and Optimization TechniquesComputer Science5 citations
TL;DR

CRUXEval introduces an 800-sample Python benchmark to test code execution (CRUXEval-O) and code understanding (CRUXEval-I) in LMs, revealing gaps between open-source models and GPT-4 and showing CoT and fine-tuning help but do not solve the benchmark.

ABSTRACT

We present CRUXEval (Code Reasoning, Understanding, and eXecution Evaluation), a benchmark consisting of 800 Python functions (3-13 lines). Each function comes with an input-output pair, leading to two natural tasks: input prediction and output prediction. First, we propose a generic recipe for generating our execution benchmark which can be used to create future variation of the benchmark. Second, we evaluate twenty code models on our benchmark and discover that many recent high-scoring models on HumanEval do not show the same improvements on our benchmark. Third, we show that simple CoT and fine-tuning schemes can improve performance on our benchmark but remain far from solving it. The best setup, GPT-4 with chain of thought (CoT), achieves a pass@1 of 75% and 81% on input and output prediction, respectively. In contrast, Code Llama 34B achieves a pass@1 of 50% and 46% on input and output prediction, highlighting the gap between open and closed source models. As no model is close to acing CRUXEval, we provide examples of consistent GPT-4 failures on simple programs as a lens into its code reasoning capabilities and areas for improvement.

Motivation & Objective

  • Motivate a benchmark that measures code understanding and execution beyond generation tasks like HumanEval and MBPP.
  • Provide two tasks: input prediction (reasoning about code) and output prediction (execution of code).
  • Describe a generic recipe to generate execution benchmarks for future variation.

Proposed method

  • Generate 102,000 candidate functions and 489,306 input-output pairs using Code Llama 34B across 69 standard library functions.
  • Filter samples to ensure solvable, memory-light problems (no floats, limited arity, deterministic, no side effects).
  • Construct an 800-sample benchmark by random selection with execution-based correctness metrics for both tasks (pass@1 and pass@5).
  • Evaluate a range of models (GPT-4, GPT-3.5, Code Llama, WizardCoder, Phi, Phind, Mistral, DeepSeek, StarCoder) using N=100 samples for non-GPT models and N=10 for GPT models.
  • Examine effects of Chain-of-Thought prompting and simple fine-tuning on CRUXEval performance.

Experimental results

Research questions

  • RQ1Can LM-based code models reason about code execution and predict outputs of simple Python functions (CRUXEval-O)?
  • RQ2Can LM-based models predict inputs that yield a given output when applying a function (CRUXEval-I)?
  • RQ3How do open-source models compare to GPT-4 on code execution and understanding tasks?
  • RQ4Do prompting techniques like Chain-of-Thought and simple fine-tuning improve performance on CRUXEval?
  • RQ5What are the failure modes of modern LMs on straightforward code execution tasks?

Key findings

  • GPT-4 with Chain-of-Thought achieves the highest reported scores (pass@1: ~75% input, ~81% output).
  • Open-source models lag GPT-4, with Code Llama 34B achieving around half the GPT-4 performance on both tasks.
  • CoT and simple fine-tuning improve CRUXEval performance but do not fully close the gap to acing the benchmark.
  • HumanEval-correlated models still show gaps on CRUXEval, especially distilled GPT-4–based models which do not consistently improve execution understandings.
  • Many GPT-4 failures on simple programs reveal persistent gaps in code execution understanding even for strong models.
  • Fine-tuning on similar samples can match GPT-4 on both tasks but plateaus below 70% accuracy, indicating the benchmark remains challenging.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.