分析与缓解代码评估指标中的表面偏差
Analyzing and Mitigating Surface Bias in Code Evaluation Metrics
AI总结:
针对代码评估指标偏向表面特征的问题,提出包含3117个代码对的基准LoCaL,通过差分模糊测试标注功能相似性,揭示并助力缓解表面偏差。
摘要:
随着大型语言模型(LLMs)和基于LLM的智能体的日益普及,可靠且有效的代码评估指标(CEMs)对于多个软件工程任务的进展变得至关重要。虽然流行的基准测试通常提供测试用例来评估生成代码的正确性,但编写和执行测试用例成本高昂。基于参考的CEMs提供了一种更便宜的替代方案,通过根据候选程序与参考程序的功能相似性对其进行评分。尽管先前的研究侧重于报告这些CEMs与功能正确性之间的弱相关性,但其原因仅是假设,且可行的解决方案仍未探索。在本工作中,我们批判性地评估了四种最先进的基于参考的CEMs,揭示了它们对表面级特征而非代码功能的强烈偏差。尽管存在这种表面偏差,当前用于这些CEMs的评估数据集很少包含表面相似但功能不相似的代码对,或功能相似但表面不相似的代码对。为缓解这一差距,我们提出了LoCaL(Looks Can Lie),一个CEM评估基准,包含3117个方法和程序级别的代码对。每对代码对都标注了功能相似性分数,旨在针对CEMs可能表现不佳的区域。功能相似性分数通过差分模糊测试计算,这消除了对预定义测试用例的需求,同时通过执行比先前工作多一个数量级的测试来提高分数的可靠性。我们发现,与基线相比,所有四种CEMs在LoCaL上均表现出显著的性能下降。最后,基于我们的发现,我们得出启示:将CEMs暴露于类似LoCaL的数据可能有助于开发对表面偏差具有鲁棒性的指标。
英文摘要:
With the increasing popularity of large language models (LLMs) and LLM-based agents, reliable and effective code evaluation metrics (CEMs) have become crucial for progress across several software engineering tasks. While popular benchmarks often provide test cases to assess the correctness of generated code, crafting and executing test cases is expensive. Reference-based CEMs provide a cheaper alternative by scoring a candidate program based on its functional similarity to a reference. Although prior research has focused on reporting the weak correlation between these CEMs and functional correctness, the causes are only assumed, and plausible solutions remain unexplored. In this work, we critically evaluate four state-of-the-art reference-based CEMs, revealing their strong bias towards surface-level features rather than code functionality. Despite this surface bias, current evaluation datasets for these CEMs rarely include code pairs that are surface-similar yet functionally dissimilar, or functionally similar yet surface-dissimilar. To mitigate this gap, we propose LoCaL (Looks Can Lie), a CEM evaluation benchmark, with 3117 code pairs at both the method and program levels. Each pair is labeled with a functional similarity score and aims to target regions where CEMs are likely to perform poorly. The functional similarity scores are calculated through differential fuzzing, which eliminates the need for predefined test cases and, at the same time, improves the reliability of the scores by executing an order of magnitude more tests than prior work. We find that all four CEMs show significant performance degradation on LoCaL, compared to the baselines. Finally, based on our findings, we draw the implication that exposing CEMs to LoCaL-like data might facilitate the development of metrics that are robust to surface bias.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。