一句话:揭示代码摘要模型对低可读性代码脆弱,并发布考虑可读性差异的评测基准 PoorCodeSumEval。
现有代码理解基准几乎都由高可读性代码构成,无法反映真实世界中大量低可读性代码,因而难以衡量模型对可读性变化的鲁棒性。本文系统分析了代码摘要模型在不同可读性代码上的表现,构建了七个由现有基准经混淆得到的数据集。结果显示,当前摘要模型对低可读性代码十分脆弱,其性能主要依赖代码中的语义线索,常常忽略句法信息;而现有基准偏向评估语义特征,因而掩盖了模型理解非敏感句法特征的能力。基于这些发现,作者提出 PoorCodeSumEval,将可读性引入测试过程,同时覆盖语义混淆、句法混淆及二者的交叉混淆,为代码摘要模型提供更全面严格的评测。文章还给出构建多可读性基准、可读性感知指标以及代码数据自动清洗与规范化等未来研究方向。
Code language models such as CodeT5 and CodeLlama have demonstrated substantial achievement in code comprehension. While the majority of research efforts have focused on improving model architectures and training processes, we find that the current benchmarks used for evaluating code comprehension models are confined to high-readability code, regardless of the popularity of low-readability code in reality. As such, they are inadequate to demonstrate the full spectrum of the model's ability, particularly the robustness to varying readability degrees. In this paper, we analyze the robustness of code summarization models to code with varying readability, including seven obfuscated datasets derived from existing benchmarks. Our findings indicate that current code summarization models are vulnerable to code with poor readability. In particular, their performance predominantly depends on semantic cues within the code, often neglecting the syntactic aspects. Existing benchmarks are biased toward evaluating semantic features, thereby overlooking the models' ability to understand nonsensitive syntactic features. Based on the findings, we present Poor-CodeSumEval, a new evaluation benchmark on code summarization tasks. PoorCodeSumEval innovatively introduces readability into the testing process, considering semantic, syntactic, and their cross-obfuscation, thereby providing a more comprehensive and rigorous evaluation of code summarization models. Our studies also provide more insightful suggestions for future research, such as constructing multi-readability benchmarks to evaluate the robustness of models on poor-readability code, proposing readability-awareness metrics, and automatic methods for code data cleaning and normalization.
DOI 原文 ·
@inproceedings{paperbot8442,
title = {How Effectively Do Code Language Models Understand Poor-Readability Code?},
author = {Chao Hu and Yitian Chai and Hao Zhou and Fandong Meng and Jie Zhou and Xiaodong Gu},
booktitle = {ASE},
year = {2024},
doi = {10.1145/3691620.3695072}
}