通过元课程学习实现抗可读性代码摘要
Readability-Robust Code Summarization via Meta Curriculum Learning
AI总结:
本文提出RoFTCodeSum方法,通过结合课程学习和元学习提升代码摘要对低可读性代码的鲁棒性。
摘要:
代码摘要已成为程序理解领域的一项基本技术。尽管代码语言模型已取得显著进展,但当前的模型和基准测试仅限于高可读性代码,这些代码包含足够的语义线索,如函数和变量名称。然而在现实世界中,代码往往结构不良或被混淆,这显著降低了模型性能。在本文中,我们首先经验性地评估了最先进的语言模型在代码摘要任务中对低可读性代码的鲁棒性,重点关注(1)其有效性,(2)提示工程的影响,以及(3)不同变体的鲁棒性。实验结果表明,最先进的模型,包括GPT-4o和DeepSeek-V3,在面对低可读性代码时性能大幅下降,而提示工程和推理增强的模型提供有限的改进。受这些发现的启发,我们提出了RoFTCodeSum,一种新的微调方法,旨在增强对低可读性代码的摘要鲁棒性。RoFTCodeSum结合了课程学习和元学习的概念:基于原始微调数据集,创建课程训练集,例如从代码中混淆函数名称和标识符,这些数据集在代码理解上具有逐步增加的难度。在每个训练步骤中,该方法使用这些逐步具有挑战性的数据集进行元更新梯度,从而同时优化准确性和可读性鲁棒性。实验结果表明,RoFTCodeSum在对抗语义扰动时表现出增强的鲁棒性,同时提高了原始代码的性能。
英文摘要:
Code summarization has emerged as a fundamental technique in the field of program comprehension. While code language models have shown significant advancements, the current models and benchmarks are confined to high-readability code, which contains sufficient semantic cues such as function and variable names. In the real world, however, code is often poorly structured or obfuscated, significantly degrading model performance. In this paper, we first empirically evaluate the robustness of state-of-the-art language models on poor-readability code for the task of code summarization, focusing on (1) their effectiveness, (2) the impact of prompt engineering, and (3) the robustness of different variants. Experimental results reveal that state-of-the-art models-including GPT-4o and DeepSeek-V3 experience a substantial performance drop when faced with poorly readable code, and that prompt engineering and reasoning-enhanced models offer limited improvements. Motivated by these findings, we propose RoFTCodeSum, a novel fine-tuning method that enhances the robustness of code summarization against poorly readable code. RoFTCodeSum marries the concepts of curriculum learning and meta-learning: based on the original dataset for fine-tuning, it creates curricular training sets, e.g., obfuscating function names and identifiers from the code, respectively, that have progressive difficulty in code comprehension. In each training step, the approach meta-updates the gradients using these progressively challenging datasets, thereby optimizing both accuracy and readability robustness simultaneously. Experimental results demonstrate that RoFTCodeSum exhibits increased robustness against semantic perturbation while enhancing performance on the original code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。