A Cross-lingual Comparison of Human and Model Relative Word Importance (2022)

Abstract: Relative word importance is a key metric for natural language processing. In this work, we compare human and model relative word importance to investigate if pretrained neural language models focus on the same words as humans cross-lingually. We perform an extensive study using several importance metrics (gradient-based saliency and attention-based) in monolingual and multilingual models, including eye-tracking corpora from four languages (German, Dutch, English, and Russian). We find that gradient-based saliency, first-layer attention, and attention flow correlate strongly with human eye-tracking data across all four languages. We further analyze the role of word length and word frequency in determining relative importance and find that it strongly correlates with length and frequency, however, the mechanisms behind these non-linear relations remain elusive. We obtain a cross-lingual approximation of the similarity between human and computational language processing and insights into the usability of several importance metrics.

## introduction large pretrained neural language models, such as bert @xcite , have in recent years demonstrated performance equal to that of humans in a range of natural language understanding tasks @xcite . this begs the question of whether the processing and encoding of these models reflect language properties as described by language experts, such as in grammar, semantics, pragmatics and logic and, furthermore, whether the models process language similarly to humans. while extensive research is being done to answer this question, such as inquiries into what linguistic knowledge is encoded into contextual word representations @xcite , how linguistic information is processed @xcite and the effects of architectural choices @xcite , more recent research inspired by psycholinguistics has emerged, which directly compares cognitive signals of language processing to pretrained language models. by using tools such as eye-tracking features and brain activity data @xcite @xcite , this line of research skips the step of having to collect human judgments from speech or text data by directly comparing them to sources of cognitive data. as such, this approach is a direct means of testing whether models process language similarly to humans or, in other words, of evaluating the cognitive plausibility of computational language processing. one method leveraging cognitive data has been to extract relative word importance, a key metric for natural language processing, from eye-tracking data in order to compare these to relative word importance extracted from state-of-the-art pretrained language models. this has been studied for normal english reading @xcite , in task-specific reading @xcite , and in question answering settings @xcite . in this work, we continue in this line of research but apply it across several languages to measure the extent to which pretrained language models focus on the same words as humans cross-lingually. we obtain human relative word importance from eye-tracking data (total reading time) and model relative word importance from pretrained language models using saliency and attention-based methods. these methods have in recent years been developed for the purpose of explainability, however, which methods serve best for this purpose has been a point of contention @xcite . the goal of this study is two-fold: on the one hand, we aim to obtain a rough estimate of the similarity between human and computational natural language processing and, on the other hand, from a usability point of view, see which importance methods best approximate human relative word importance. we compare four methods for calculating relative word importance in pretrained language models, namely first-layer attention, last-layer attention, attention flow, and gradient-based saliency. to investigate whether the same trends hold across multiple languages and are not particular artifacts of one language, we use eye-tracking corpora of four different languages (english, dutch, german, and russian) and compare both monolingual and multilingual language models. more precisely, we make this comparison by looking at how human and model relative word importance statistically correlate across different languages. lexical properties such as word frequency and length are known to have a large effect on eye movements of any language @xcite . therefore, in an additional investigation, we analyze their impact on the fit between human and model relative importance. to sum up, this work examines the following research questions: q1: do human and model relative word importance correlate across languages? q2: is there a difference between language-specific and multilingual language models? q3: is there a difference between gradient-based saliency and the attention-based methods first-layer attention, last-layer attention, and attention flow? q4: to what extent is human and model relative word importance relying on word length and word frequency? contributions we show that human and model word importance correlate strongly in varying degrees across languages (english, dutch, german and russian), although the observed differences appear to be more corpus-specific than languagespecific (q1). we observe a slightly stronger correlation of monolingual models over multilingual models, in particular for first-layer attention and attention flow (q2). we see that other attentionbased methods than last-layer attention, i.e., firstlayer and attention flow correlate strongly to human eye-tracking data with attention flow being on par with saliency for monolingual models (q3). we see a strong correlation with the baselines (positive correlation to word length and negative correlation to word frequency). when using linear regression analysis to measure the ability of word length, word frequency and model relative word importance to predict human relative word importance, we see that word frequency and word length increase the predictive power over model relative word importance alone, indicating that these baselines are not sufficiently accounted for by the models (q4). the code for our experiments is available online. foot_0 ## related work this work lies at the intersection of psycholinguistics, interpretability of neural networks, and natural language processing. more specifically, there are two current streams of research that this study directly draws from, namely relative importance metrics and cognitive analysis of natural language processing. below, we outline the related works in these two subfields. ## method for each sentence in the eye-tracking corpora, we calculate human and model relative word importance values. the same sentences are, however, tokenized differently by the built-in tokenizers of the pretrained language models, resulting in longer sequences of relative word importance values than those obtained from humans. to remedy this, we align human and model importance values by discarding the importance values of special tokens (e.g. [sep] and [cls]) and merging subtokens and adding their values. once aligned, we calculate spearman's correlation coefficient ρ between human and model relative word importance for each sentence. finally, we calculate an average spearman's ρ across all sentences for each eyetracking corpus (human relative word importance) and model, corpus, and importance metric tuple (model relative word importance). additionally, using the same procedure, we explore the correlation of human and model relative word importance to word length and frequency baselines. we analyze the following importance metrics: human relative importance in this work, we use the total reading time per word in the eye tracking corpora as the source for defining human relative word importance. it refers to the sum of all fixation durations for each word including regres-sions (i.e. when a subject goes back to the same word after the first pass). we use the average total reading time across all subjects and normalize the resulting values such that each word is assigned an importance value between 0 and 1, and all values within a sentence sum up to 1. these values are calculated sentence by sentence. gradient-based saliency as described in hollenstein and beinborn (2021), we define a saliency vector for a masked token to indicate the importance of each of the tokens in the context of correctly predicting the masked token @xcite . the saliency s ij for input token x j for the prediction of the correct token t i is calculated as the euclidean norm of the gradient of the logit for x i : last-layer attention we approximate relative importance using the attention values from the last layer and calculate the mean of all heads of each transformer model as @xcite . first-layer attention previous work has indicated that earlier layers encode information closer to word-level than later layers @xcite . therefore, we also include the first-layer attention weights by averaging over all heads to approximate relative word importance. attention flow finally, we compute attention flow @xcite , which has been shown to correlate stronger with human gaze than raw attention weights @xcite . attention flow considers the attention graph as a flow network and computes maximum flow values from later attention layers to the input embedding layer. unlike raw attention weights, which consider token importance at layers in isolation, attention flow computes importance scores that account for mixing of information across layers and, thus, identifies the important tokens for the model prediction. because of the high computational resources needed to calculate attention flow, we do not calculate attention flow of the bert multilingual model for english (geco). baselines we compare human and model relative word importance to two word-level baselines: word length (the number of characters in a word) and word frequency (the proportion of times a word occurs in a corpus). to obtain the word frequencies, we use the wordfreq python package @xcite ) (version 2.3.2), which calculates token frequencies based on corpora from different internet text resources, such as wikipedia, google books, and reddit. ## conclusion in this work, we show that the strong correlation between relative word importance of neural language models and humans holds across several languages, namely, english, german, dutch, and russian. this is the case for both monolingual as well as multilingual pretrained transformer models, which yield similar performance in our correlation analyses. we also find that several relative importance metrics for pretrained language models, both first-layer attention and attention flow as well as saliency, perform similarly well and that these importance values, as their human counterparts, strongly correlate to word length and word frequency. however, as expected, we have found that last-layer attention correlates more weakly. comparing the correlations of relative word importance is a simple, easily interpretable metric for evaluating the similarity of human and computational language processing. using this metric, we can evaluate the extent to which the model's attention compares to approximate human language processing and, thus, get a gauge of their cognitive plausibility. in addition to the bert-based architectures we studied, looking at more recent cross-lingual models such as gpt, t5 and xlnet as well as multimodal language models would give further insights into the role of pre-training tasks as well as non-textual modalities. and attention-based methods to that of human relative word importance only reflects these methods' ability to mimic human behavior, but does not say anything about their ability to accurately represent the inner workings, i.e., the faithfulness of pretrained language models @xcite .