Skip to main content
QUICK 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 Techniques被引用 5
一句话总结

CRUXEval 引入一个包含 800 个样本的 Python 基准测试,用于在语言模型中测试代码执行(CRUXEval-O)和代码理解(CRUXEval-I),揭示开源模型与 GPT-4 之间的差距,并显示 Chain-of-Thought(CoT)和微调有帮助但无法解决基准测试。

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.

研究动机与目标

  • 提出一个基准测试,用以衡量超越 HumanEval 和 MBPP 等生成任务的代码理解与执行能力。
  • 提供两个任务:输入预测(对代码的推理)和输出预测(代码执行)。
  • 描述一个通用的生成执行基准的步骤,以便未来的变体。

提出的方法

  • 使用 Code Llama 34B,在 69 个标准库函数上生成 102,000 个候选函数和 489,306 对输入-输出。
  • 筛选样本以确保可解、内存友好的问题(不使用浮点数、限制入参个数、确定性、无副作用)。
  • 通过随机选择构建一个 800 样本的基准,在两个任务上使用基于执行的正确性指标(pass@1 和 pass@5)。
  • 使用 N=100 的非 GPT 模型样本和 N=10 的 GPT 模型样本,评估一系列模型(GPT-4、GPT-3.5、Code Llama、WizardCoder、Phi、Phind、Mistral、DeepSeek、StarCoder)。
  • 研究链式推理提示(Chain-of-Thought)和简单微调对 CRUXEval 性能的影响。

实验结果

研究问题

  • RQ1基于语言模型的代码模型是否能够对代码执行进行推理并预测简单 Python 函数的输出(CRUXEval-O)?
  • RQ2基于语言模型的模型是否能够预测在应用一个函数时产生给定输出的输入(CRUXEval-I)?
  • RQ3开源模型在代码执行与理解任务上与 GPT-4 相比如何?
  • RQ4诸如 Chain-of-Thought 的提示技巧和简单微调是否可以提升 CRUXEval 的性能?
  • RQ5现代语言模型在直接的代码执行任务中的失败模式是什么?

主要发现

  • 具备 Chain-of-Thought 的 GPT-4 获得最高的报告分数(pass@1:约 75% 输入,约 81% 输出)。
  • 开源模型落后于 GPT-4,Code Llama 34B 在两个任务上的表现大约只有 GPT-4 的一半。
  • CoT 和简单微调提升 CRUXEval 的性能,但尚未完全接近在基准测试中获得满分的水平。
  • 与 HumanEval 相关的模型在 CRUXEval 上仍存在差距,特别是蒸馏自 GPT-4 的模型在执行理解方面并不总是有所改善。
  • 在简单程序上的许多 GPT-4 失效揭示了即使是强模型在代码执行理解方面仍存在持续的差距。
  • 在相似样本上的微调可以在两个任务上达到与 GPT-4 相当的表现,但准确率仍低于 70%,表明该基准仍具有挑战性。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。