一句话:提出 CodeDenoise,在线定位并清洗误预测输入中的噪声标识符,无需重训练即可提升深度代码模型性能。
深度代码模型广泛用于代码任务,但输入中的噪声会导致错误预测。重训练/微调开销大且无法即时改善已部署模型;其他领域的输入去噪方法又难以适用于需满足复杂语法语义约束的离散代码。本文提出首个面向深度代码模型的输入去噪技术 CodeDenoise:在(可能)误预测的输入中定位噪声标识符并清洗,从而在线去噪,无需重训练或重建模型。作者在 18 个深度代码模型(3 个预训练模型 × 6 个数据集)上评估,平均去噪 21.91% 的误预测输入,模型准确率平均提升 2.04%,每个输入平均耗时 0.48 秒,显著优于微调策略。
Deep learning has been widely adopted to tackle various code-based tasks by building deep code models based on a large amount of code snippets. While these deep code models have achieved great success, even state-of-the-art models suffer from noise present in inputs leading to erroneous predictions. While it is possible to enhance models through retraining/fine-tuning, this is not a once-and-for-all approach and incurs significant overhead. In particular, these techniques cannot on-the-fly improve performance of (deployed) models. There are currently some techniques for input denoising in other domains (such as image processing), but since code input is discrete and must strictly abide by complex syntactic and semantic constraints, input denoising techniques in other fields are almost not applicable. In this work, we propose the first input denoising technique (i.e., CodeDenoise) for deep code models. Its key idea is to localize noisy identifiers in (likely) mispredicted inputs, and denoise such inputs by cleansing the located identifiers. It does not need to retrain or reconstruct the model, but only needs to cleanse inputs on-the-fly to improve performance. Our experiments on 18 deep code models (i.e., three pre-trained models with six code-based datasets) demonstrate the effectiveness and efficiency of CodeDenoise. For example, on average, CodeDenoise successfully denoises 21.91% of mispredicted inputs and improves the original models by 2.04% in terms of the model accuracy across all the subjects in an average of 0.48 second spent on each input, substantially outperforming the widely-used fine-tuning strategy.