SELGNov 22, 2023

Naturalness of Attention: Revisiting Attention in Code Language Models

arXiv:2311.13508v14 citationsh-index: 4
Originality Incremental advance
AI Analysis

This work addresses interpretability for researchers and practitioners using neural code models, but it is incremental as it builds on existing attention analysis studies.

The study tackled the problem of understanding what CodeBERT learns about source code by analyzing attention mechanisms beyond just attention weights, finding that scaled transformation norms of the input better capture syntactic structure in Java and Python compared to attention weights alone.

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.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes