评估与提升预训练模型在代码翻译中的句法对抗鲁棒性
Assessing and Improving Syntactic Adversarial Robustness of Pre-trained Models for Code Translation
AI总结:
本文提出 CoTR 方法,通过对抗样本生成与基于语义距离的数据增强及对抗训练,评估并提升预训练模型在代码翻译中的句法鲁棒性,实验验证其有效性。
摘要:
背景:预训练模型(PTMs)在自动代码翻译中已展现出显著潜力。然而,这些模型在翻译任务中的脆弱性,尤其是在句法方面的脆弱性,尚未得到充分研究。目标:为填补这一空白,本研究旨在提出一种新方法 CoTR,用于评估和提升 PTMs 在代码翻译中的句法对抗鲁棒性。方法:CoTR 由两个组件构成:CoTR-A 和 CoTR-D。CoTR-A 通过变换程序生成对抗样本,而 CoTR-D 提出了一种基于语义距离的采样数据增强方法和对抗训练方法,以提升模型的鲁棒性和泛化能力。CoTR 使用 Pass@1 指标评估 PTMs 的性能,该指标更适合代码翻译任务,并能在真实场景中提供更精确的评估。结果:通过在真实世界 Java 到 Python 数据集上的实验评估了 CoTR 的有效性。结果表明,CoTR-A 能显著降低现有 PTMs 的性能,而 CoTR-D 能有效提升 PTMs 的鲁棒性。结论:本研究识别了当前 PTMs(包括大语言模型)在代码翻译任务中的局限性,并凸显了 CoTR 作为提升 PTMs 代码翻译任务鲁棒性的有效解决方案的潜力。
英文摘要:
Context: Pre-trained models (PTMs) have demonstrated significant potential in automatic code translation. However, the vulnerability of these models in translation tasks, particularly in terms of syntax, has not been extensively investigated. Objective: To fill this gap, our study aims to propose a novel approach CoTR to assess and improve the syntactic adversarial robustness of PTMs in code translation. Method: CoTR consists of two components: CoTR-A and CoTR-D. CoTR-A generates adversarial examples by transforming programs, while CoTR-D proposes a semantic distance-based sampling data augmentation method and adversarial training method to improve the model's robustness and generalization capabilities. The Pass@1 metric is used by CoTR to assess the performance of PTMs, which is more suitable for code translation tasks and offers a more precise evaluation in real world scenarios. Results: The effectiveness of CoTR is evaluated through experiments on real world Java to Python datasets. The results demonstrate that CoTR-A can significantly reduce the performance of existing PTMs, while CoTR-D effectively improves the robustness of PTMs. Conclusion: Our study identifies the limitations of current PTMs, including large language models, in code translation tasks. It highlights the potential of CoTR as an effective solution to enhance the robustness of PTMs for code translation tasks.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。