预训练的代码模型对代码了解多少?
What do pre-trained code models know about code?
摘要:
构建在Transformer架构上的代码的预训练模型在软件工程(SE)任务上表现良好,例如预测性代码生成、代码摘要等。然而,来自这些预训练模型的向量表示是否能够很好地对源代码的特征进行全面编码,以适用于广泛的下游任务,这仍然是一个悬而未决的问题。研究这一点的一种方法是使用称为探测器的诊断任务。在本文中,我们为预训练的代码模型构建了四个探测任务(探测表层,语法,结构和语义信息)。我们将展示如何使用探针来识别模型是否在(理解)某些代码属性方面存在缺陷,表征不同的模型层,并深入了解模型的样本效率。我们探讨了四种模型,它们在代码属性的预期知识方面各不相同:BERT(英语预训练),CodeBERT和CodeBERTa(源代码和自然语言文档预训练),以及GraphCode BERT(使用Rightlow对源代码进行预训练)。虽然GraphCode BERT的整体表现更一致,但我们发现BERT在某些代码任务上的表现令人惊讶,这需要进一步调查。
英文摘要:
Pre-trained models of code built on the transformer architecture have performed well on software engineering (SE) tasks such as predictive code generation, code summarization, among others. However, whether the vector representations from these pre-trained models comprehensively encode characteristics of source code well enough to be applicable to a broad spectrum of downstream tasks remains an open question. One way to investigate this is with diagnostic tasks called probes. In this paper, we construct four probing tasks (probing for surface-level, syntactic, structural, and semantic information) for pre-trained code models. We show how probes can be used to identify whether models are deficient in (understanding) certain code properties, characterize different model layers, and get insight into the model sample-efficiency. We probe four models that vary in their expected knowledge of code properties: BERT (pre-trained on English), CodeBERT and CodeBERTa (pre-trained on source code, and natural language documentation), and GraphCodeBERT (pre-trained on source code with dataflow). While GraphCodeBERT performs more consistently overall, we find that BERT performs surprisingly well on some code tasks, which calls for further investigation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。