Acceptability Judgements via Examining the Topology of Attention Maps (2022)

Abstract: The role of the attention mechanism in encoding linguistic knowledge has received special interest in NLP. However, the ability of the attention heads to judge the grammatical acceptability of a sentence has been underexplored. This paper approaches the paradigm of acceptability judgments with topological data analysis (TDA), showing that the geometric properties of the attention graph can be efficiently exploited for two standard practices in linguistics: binary judgments and linguistic minimal pairs. Topological features enhance the BERT-based acceptability classifier scores by 8%-24% on CoLA in three languages (English, Italian, and Swedish). By revealing the topological discrepancy between attention maps of minimal pairs, we achieve the human-level performance on the BLiMP benchmark, outperforming nine statistical and Transformer LM baselines. At the same time, TDA provides the foundation for analyzing the linguistic functions of attention heads and interpreting the correspondence between the graph features and grammatical phenomena. We publicly release the code and other materials used in the experiments.

## introduction linguistic competence of neural language models (lms) has emerged as one of the core sub-fields in nlp. the research paradigms explore whether transformer lms @xcite induce linguistic generalizations from raw pre-training corpora @xcite , what properties are learned during task-specific fine-tuning @xcite , and how the experimental results are connected to grammar and language acquisition theories @xcite . one of these paradigms is centered around acceptability judgments, which have formed an empirical foundation in generative linguistics over the last six decades @xcite @xcite . acceptability of linguistic stimuli is traditionally investigated in the form of a forced choice between binary categories or minimal pairs @xcite , which are widely adopted for acceptability classification @xcite and probabilistic lm scoring @xcite . a scope of approaches has been proposed to interpret the roles of hundreds of attention heads in encoding linguistic properties @xcite and identify how the most influential ones benefit the downstream performance @xcite . prior work has demonstrated that heads induce grammar formalisms and structural knowledge @xcite @xcite , and linguistic features motivate attention patterns @xcite . recent studies also show that certain heads can have multiple functional roles @xcite and even perform syntactic functions for typologically distant languages @xcite . our paper presents one of the first attempts to analyze attention heads in the context of linguistic acceptability (la) using topological data analysis (tda foot_0 ; @xcite . tda allows for exploiting complex structures underlying textual data and investigating graph representations of transformer's attention maps. we show that topological features are sensitive to well-established la contrasts, and the grammatical phenomena can be encoded with the topological properties of the attention map. the main contributions are the following: (i) we adapt tda methods to two standard approaches to la judgments: acceptability classification and scoring minimal pairs ( §3). (ii) we conduct acceptability classification experiments in three indo-european languages (english, italian, and swedish) and outperform the established baselines ( §4). (iii) we introduce two scoring functions, which reach the human-level performance in discriminating between minimal pairs in english and surpass nine statistical and transformer lm baselines ( §5). (iv) the linguistic analysis of the feature space proves that tda can serve as a complementary approach to interpreting the attention mechanism and identifying heads with linguistic functions ( §4.3, §5.3, §6). ## discussion topology and acceptability. the topological properties of the attention graph represent interpretable and versatile features for judging sentence acceptability and identifying acceptability contrasts in minimal pairs. as one of such properties, the sum length of bars (h 0 s) -and its normalized version (h 0 m ) -have proved to be efficient for both la approaches. this simple feature can serve as a profitable input for la classifiers and a scoring function to discriminate between minimal pairs. figure 4 shows an example of the h 0 s sensitivity to cola's question-like properties, such as whmovement out of syntactic islands and matrix and embedded questions. we provide more examples in appendix e, which demonstrate the distribution shifts between the acceptable and unacceptable sentences. acceptability phenomena. the underlying structure of the attention graph encodes various well-established grammatical concepts. we observe that the persistent graph features capture surface properties, morphological agreement, structural relationships, and simple/complex syntactic phenomena well. however, with topology, lexical items, optional syntactic elements, and abstract semantic factors may be difficult to infer. attention to the first token and punctuation marks contribute least to la classification, while the other attention pattern features capture various phenomena. linguistic roles of heads. topological tools help gain empirical evidence about the linguistic roles of heads from another perspective. our findings on the heads' roles align with several related studies. the results on the cola-style and blimp benchmarks indicate that (i) a single head can perform multiple linguistic functions @xcite , (ii) some linguistic phenomena, e.g., phrasal movement and island effects, are better captured by head ensembles rather than one head @xcite , and (iii) heads within the same or nearby layers extract similar grammatical phenomena @xcite . ## conclusion and future work our paper studies the ability of attention heads to judge grammatical acceptability, demonstrating the profitable application of tda tools to two la paradigms. topological features can boost la classification performance in three typologically close languages. the h 0 m /rtd scoring matches or outperforms larger transformer lms and reaches human-level performance on blimp, while utilizing 9-to-59 attention heads. we also interpret the correspondence between the persistent features of the attention graph and grammatical concepts, revealing that the former efficiently infer morphological, structural, and syntactic phenomena but may lack lexical and semantic information. in our future work we hope to assess the linguistic competence of transformer lms on related resources for typologically diverse languages and analyze which language-specific phenomena are and are not captured by the topological features. we are also planning to examine novel features, e.g., the number of vertex covers, the graph clique-width, and the features of path homology @xcite . another direction is to evaluate the benefits and limitations of the h 0 m /rtd features as scoring functions in downstream applications. we also plan to introduce support for new deep learning frameworks such as mindspore foot_2 @xcite to bring tda-based experimentation to the wider industrial community.