arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2311.13508cs.SEcs.LG
收藏

注意力的自然性:重新审视代码语言模型中的注意力

Naturalness of Attention: Revisiting Attention in Code Language Models

Faculty of Computer Science(计算机科学学院)

Mootez Saad, Tushar Sharma

AI总结:

本研究分析了CodeBERT中注意力分布与变换表示,发现输入的缩放变换范数比单独的注意力权重更能捕获语法结构,为理解神经代码模型提供了新见解。

摘要:

诸如CodeBERT之类的代码语言模型提供了学习高级源代码表示的能力,但其不透明性构成了理解所捕获属性的障碍。近期的注意力分析研究仅关注注意力权重,而未考虑Transformers更广泛的上下文建模,从而提供了初步的可解释性见解。本研究旨在阐明除注意力权重之外先前被忽视的注意力机制因素。我们开展了一项初步的实证研究,分析了CodeBERT中的注意力分布和变换后的表示。在Java和Python两种编程语言中,我们发现与单独的注意力权重相比,输入的缩放变换范数能更好地捕获语法结构。我们的分析揭示了CodeBERT如何嵌入语法代码属性的特征。研究结果表明,为了严谨地理解神经代码模型,纳入注意力权重之外的因素至关重要。这为在程序分析中开发更具可解释性的模型和有效利用注意力机制奠定了基础。

英文摘要:

Language models for code such as CodeBERT offer the capability to learn advanced source code representation, but their opacity poses barriers to understanding of captured properties. Recent attention analysis studies provide initial interpretability insights by focusing solely on attention weights rather than considering the wider context modeling of Transformers. This study aims to shed some light on the previously ignored factors of the attention mechanism beyond the attention weights. We conduct an initial empirical study analyzing both attention distributions and transformed representations in CodeBERT. Across two programming languages, Java and Python, we find that the scaled transformation norms of the input better capture syntactic structure compared to attention weights alone. Our analysis reveals characterization of how CodeBERT embeds syntactic code properties. The findings demonstrate the importance of incorporating factors beyond just attention weights for rigorously understanding neural code models. This lays the groundwork for developing more interpretable models and effective uses of attention mechanisms in program analysis.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑