arXiv:2506.04019cs.SEcs.CL2025-06被引 1

构建新数据集CETBench,测试大模型代码等价性判断能力。

CETBench: A Novel Dataset constructed via Transformations over Programs for Benchmarking LLMs for Code-Equivalence Checking

  • 基于程序变换生成等价与非等价代码对,构建评测基准。
  • 简单代码变换即导致顶尖模型性能大幅下降。
  • 适合研究代码理解、大模型推理鲁棒性的研究人员。

大语言模型广泛用于自动化代码生成,但其在代码等价性检查这一相对未被充分探索的任务上的适用性仍待考察。该任务旨在判断两个程序是否功能等价,对评估模型在代码重构与翻译中的能力至关重要。为此,我们提出CETBench——一个通过程序库中程序经预定义代码变换生成的基准数据集。每个样本由一对程序经随机变换得到,可能等价或不等价。分析发现,即使是最简单的代码变换,也会显著降低现有最先进模型在代码等价性判断上的表现。为此,我们提出一种基于微调的改进方法,有效提升模型在变换后代码对上的性能。该数据集生成方法通用,可适配不同难度程序库并支持多种变换类型与数量。实验还进行了关于原始程序难度及变换类型影响的消融分析,揭示了当前模型在代码语义理解方面的局限性。

原文摘要 · Abstract (English)

LLMs have been extensively used for the task of automated code generation. In this work, we examine the applicability of LLMs for the related but relatively unexplored task of code-equivalence checking, i.e., given two programs, whether they are functionally equivalent or not. This is an important problem since benchmarking code equivalence can play a critical role in evaluating LLM capabilities for tasks such as code re-writing and code translation. Towards this end, we present CETBench - Code Equivalence with Transformations Benchmark, constructed via a repository of programs, where two programs in the repository may be solving the same or different tasks. Each instance in our dataset is obtained by taking a pair of programs in the repository and applying a random series of pre-defined code transformations, resulting in (non-)equivalent pairs. Our analysis on this dataset reveals a surprising finding that very simple code transformations in the underlying pair of programs can result in a significant drop in performance of SOTA LLMs for the task of code-equivalence checking. To remedy this, we present a simple fine-tuning-based approach to boost LLM performance on the transformed pairs of programs. Our approach for dataset generation is generic, and can be used with repositories with varying program difficulty levels and allows for applying varying numbers as well as kinds of transformations. In our experiments, we perform ablations over the difficulty level of original programs, as well as the kind of transformations used in generating pairs for equivalence checking. Our analysis presents deep insights into the working of LLMs for the task of code-equivalence, and points to the fact that they may still be far from what could be termed as a semantic understanding of the underlying code.

代码等价大模型评测程序变换

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。