Evaluating Language Models on Cross-Language Code Functional Equivalence

📄 arXiv: 2608.23961v1 📥 PDF

作者: Hui Sun, Anderson Uchôa, Rohit Gheyi, Wesley K. G. Assunção

分类: cs.SE, cs.AI, cs.CL

发布日期: 2026-08-25

备注: 20 pages. To appear in the 20th International Symposium on Empirical Software Engineering and Measurement (ESEM 2026), LIPIcs vol. 394, Article No. 41


💡 一句话要点

提出PolyHuman数据集以评估跨语言代码功能等价性

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 功能等价性 跨语言评估 代码理解 PolyHuman数据集 模型稳定性 编程语言敏感性

📋 核心要点

  1. 现有方法主要集中在单语言设置,缺乏对跨语言功能等价性的深入评估。
  2. 论文提出PolyHuman数据集,评估LLMs在不同编程语言间的功能等价性,强调人类编写代码的重要性。
  3. 实验结果显示,模型在处理更复杂问题时更易误判等价性,且存在模型特定的语言敏感性。

📝 摘要(中文)

背景:大型语言模型(LLMs)在多种代码理解任务中表现出色,但现有评估主要集中在单语言环境或依赖合成生成代码,导致对语义理解的真实反映产生疑虑。目标:我们研究LLMs是否能够准确判断人类编写的不同编程语言之间的功能等价性,这需要超越表面相似性的深入推理。方法:我们引入PolyHuman数据集,评估开放权重和专有LLMs在语言内和语言间的等价性检测,并分析81个模型错误判断功能等价性的案例。结果:我们发现等价判断的困难依赖性和模型对编程语言的敏感性,表明当前LLMs在捕捉功能等价性方面并不可靠。

🔬 方法详解

问题定义:本论文旨在解决当前LLMs在跨语言代码功能等价性判断中的不足,现有方法多依赖单一语言或合成代码,无法真实反映模型的语义理解能力。

核心思路:通过引入PolyHuman数据集,包含CPP、Java和Python的真实人类编写程序,评估LLMs在不同语言间的功能等价性,强调深层次推理的重要性。

技术框架:整体流程包括数据集构建、模型选择(以GPT-o4-mini为代表)、等价性检测和系统性错误分析,重点关注模型在不同语言间的表现。

关键创新:最重要的创新在于使用真实人类编写的代码进行评估,而非合成代码,从而更准确地反映模型的实际能力和局限性。

关键设计:在实验中,选择了多个模型进行对比,分析了81个错误判断案例,关注代码逻辑和生成的思维链推理,揭示了模型的稳定性和语言敏感性。

🖼️ 关键图片

img_0
img_1
img_2

📊 实验亮点

实验结果表明,模型在处理复杂问题时更易误判等价性,尤其在Python语言上表现出保守行为。GPT-o4-mini在相同设置下显示出显著的运行不稳定性,表明其能力并非缺失,而是存在不一致性。

🎯 应用场景

该研究的潜在应用领域包括代码审查、自动化测试和跨语言代码转换等。通过提高LLMs在功能等价性判断上的准确性,可以为软件开发和维护提供更智能的支持,推动编程语言间的互操作性和理解。未来,随着数据集和模型的进一步优化,该研究有望在实际应用中发挥更大价值。

📄 摘要(原文)

Background: Large Language Models (LLMs) have demonstrated strong performance across a variety of code-understanding tasks, leading many to believe that they can reason about program semantics. However, existing evaluations primarily focus on single-language settings or rely on synthetically generated code, raising concerns about whether current results reflect true semantic understanding. Aims: We investigate whether LLMs can accurately judge functional equivalence across different programming languages in human-written code, a setting that requires deeper reasoning beyond superficial similarity. Method: We introduce PolyHuman, a dataset of human-written programs in CPP, Java, and Python. Using this dataset, we evaluate intra- and inter-language equivalence detection across open-weight and proprietary LLMs, selecting GPT-o4-mini as a representative model to assess stability. We then manually analyze 81 cases of systematic disagreement in which models incorrectly judge functional equivalence, examining the code logic and the generated Chain-of-Thought reasoning. Finally, we categorize these failures and compare them across GPT-o4-mini, Claude-Opus-4.7, and Gemini-3-Flash to determine whether they reflect model-specific issues or broader limitations of state-of-the-art LLMs. Results: We identify a difficulty-dependent breakdown in equivalence judgment (harder problems make the model increasingly prone to misclassifying non-equivalent code as equivalent), a model-specific sensitivity to programming language for the best-performing model (particularly a more conservative behavior on Python), and a partial reliance on similarity-based cues. GPT-o4-mini also shows substantial run-to-run instability under identical settings, indicating inconsistent rather than absent capability. Conclusions: Current LLMs do not reliably capture functional equivalence within or across languages.