Context Matters: A Pragmatic Study of PLM s’ Negation Understanding (2022)

Abstract: In linguistics, there are two main perspectives on negation: a semantic and a pragmatic view. So far, research in NLP on negation has almost exclusively adhered to the semantic view. In this article, we adopt the pragmatic paradigm to conduct a study of negation understanding focusing on transformer-based PLMs. Our results differ from previous, semantics-based studies and therefore help to contribute a more comprehensive – and, given the results, much more optimistic – picture of the PLMs’ negation understanding.

## introduction transformer-based pre-trained language models (plms) have become the de facto standard in a variety of natural language processing tasks. based on the original transformer architecture @xcite , researchers have proposed a number of extraordinarily successful architectures, such as bert @xcite , roberta @xcite , xlnet @xcite , and smaller versions such as distilbert @xcite . such transformer-based models perform impressively at standard natural language understanding (nlu) benchmarks, often outperforming the human benchmark, as evinced by the glue and superglue leaderboards @xcite . while it is impossible to deny the performance of these models at such benchmarks, it is another, particularly challenging question whether this performance is driven by simple shallow heuristics or by any real understanding of the languages that they are processing. 1 this study contributes to answering this question with a focus on negation. answering the question is important for both theoretical and practical reasons. on the theoreti-cal side, the study contributes to a more accurate understanding of the driving forces behind the predictions issued by plms. the phenomenon of negation, being both highly semantically relevant and having a small footprint on the syntactic surface of a sentence, is ideally suited for this purpose. for real-world applications, it is crucial to know whether the model predicts based on simple contextual clues or on a real understanding of negation. for instance, for nlu applications, it makes a substantial difference whether a certain microblog recommends that one should "(not) get vaccinated against covid-19". the question is challenging for two main reasons. first, because the models' performance is typically strong. however, it is wrong, not correct predictions that potentially unveil underlying heuristics. second, as we will show, it requires careful, linguistically conscientious construction of the datasets to be able to draw sound conclusions even from wrong predictions. for example, if a model predicts "fly" in example (1), this has been taken by most researchers as a clear indication that the model does not understand negation, especially if its confidence in this prediction is similar to the confidence with which it predicts "fly" in example (2). in contrast, our hypothesis is that this behavior of the models is not due to lack of negation understanding, but to a failure to, as it were, resolve the context in samples such as (1) and (2). while human beings automatically read sentences such as (1) within a default context, perhaps something like a biology class in primary school, where it is clear that birds can fly, this does not mean that it is never sensible or appropriate to say that they cannot. 2 our hypothesis is grounded in the linguistic research tradition called "pragmatics", while virtually all research in nlp focusing on negation understanding is based on the competing tradition called "semantics" (for a case in point, see @xcite , who use samples very similar to ( 1 ) and ( 2 )). semanticists tend to assume that truth values and appropriateness of propositions are unambiguous and context-independent. pragmatics, in contrast, emphasizes the importance of context and of syntactic, prosodic and other details to judge the appropriateness of a sentence. see below, section 3, for more details and references. to test our hypothesis, we construct datasets that, while being designed to be challenging to the models, provide a micro-context that allow us to rule out failure to resolve context as a cause of wrong predictions by the models. in detail, we contribute to the investigation of transformer-based plms in three ways. first, following the pragmatic tradition in linguistics, we develop a novel testing approach for negation understanding. rather than using isolated sentencepairs such as (2) and (1), our approach builds on automatically creating pragmatically and stylistically sound micro-contexts. second, by tailoring our datasets to the individual models to be tested, and by varying a number of possibly influencing factors, we are able to pin down precisely the true driving forces behind the models' predictions. finally, by fine-tuning the most successful models, we gain a view towards the potential for improving the performance with such fine-tuning. ## previous nlp research on negation we emphasize that our study is not directly connected to research on negation clue and scope detection (for an overview on that research, see @xcite . rather, our experiments test whether the models are able to process the information contained in a negated sentence to predict a semantically admissible token in a following sentence. hence, our research is connected to other work that examines various aspects of transformer-based 2 for instance, when observing an ostrich, somebody might use (1) as a shorthand for "these are some birds that cannot fly". furthermore, one can imagine example (1) to pop up in multiple-choice examinations, many dialogues ("birds cannot fly? -of course they can!"; "barcelona cannot win the champions league!" -"oh yes, and birds cannot fly."), fictional literature, etc. plms (the field is often called "bertology", testifying to the dominance of bert-focused studies in this area). @xcite 2020 ) provides an overview. there are studies examining the inner functional differentiation of the system's parts, such as @xcite , whose findings suggest that many of the attention heads of the original transformer are superfluous; @xcite examine the functions of bert's attention heads and find none that are specifically dedicated to negations. @xcite report state of the art performance in word-sense disambiguation using bert's contextualized word embeddings. @xcite study the models' abilities to learn so-called "physical commonsense". @xcite find that large models fare better in particular regarding common-sense reasoning (and show little improvement over smaller models with regard to semantic or syntactic tasks). as we are trying to get the models to commit mistakes that reveal underlying shallow heuristics, our research is connected to so-called adversarial attack or probing studies. these studies are trying to go beyond the nlu benchmarks such as glue and superglue to see whether the models achieve their impressive performance using shallow heuristics or real understanding. there are such studies in the field of argument reasoning @xcite and natural language inference @xcite . @xcite have proposed a general diagnosis of the problem of shallow heuristics, and @xcite have urged a more comprehensive, multi-dimensional approach to testing the abilities of these models instead of simply submitting them to automated benchmarks. furthermore, as we are studying negation by testing whether the models are able to draw very simple inferences, research in natural language inference (nli) is also relevant for our work. in this regard, @xcite show that, in the main datasets used in nli, negated sentences are biased towards contradiction, @xcite show that certain triggers can be inserted contextindependently and lead to a stark decline in @xcite show that simply ignoring negation does not substantially decrease model performance in many nli datasets. notably, @xcite is among the rare nlp studies that presuppose a pragmatic background, studying the ability of plms to cope with implicatures. of particular importance for our study are contri-butions by @xcite , ettinger (2020), and @xcite . all three studies develop minimal pairs to examine the ability of plms to correctly categorize a number of linguistic phenomena, including negation. hence, all of these studies are squarely based on the semantic side of the ongoing debate in linguistics between semantics and pragmatics (see above, section 1, examples (1) and ( 2 )), and all of them find that the models largely ignore negation, as for each minimal pair, the predictions differ little between positive and negated sentence; ettinger (2020) finds slightly better performance for more natural examples, hinting at the relevance of pragmatics in this context. ## linguistics & philosophy of language: understanding negation between semantics and pragmatics negation is a multi-faceted phenomenon that can be realized in a number of ways. in the study of negation, it is common to distinguish two very different approaches in linguistics and philosophy of language: semantics and pragmatics (for a recent discussion of the distinction, see @xcite ). the tradition of semantics has been initiated in its modern, formal-logical form by frege (1892). arguably the most important analysis of negation in this semantic tradition is @xcite . for a recent contribution in this tradition with a focus on computability, see @xcite . as mentioned above, (section 1), semanticists often try to context-independently assess the truth of a proposition. pragmatic studies of negation understanding have traditionally had a focus on the readings of ambiguous negated sentences, and on systematic ways in which conversational contexts and other nonsemantic features systematically disambiguate such sentences (e.g., identifying types of contexts in which example (1) is read as containing a negated universal quantifier, as opposed to the types of contexts in which it is read as containing a negated existential quantifier). @xcite provides an overview on recent experimental-pragmatic research on negation understanding. for a study with a focus on the influence of context on human's understanding of negation, see @xcite . in his seminal study of negation, @xcite also discusses contextual factors, davis (2016) continues in horn's footsteps. furthermore, according to the orthodox gricean version of conversational implicatures (see davis, 2019 for an introduction, for canonical texts by grice see @xcite @xcite , one can assume that participants follow conversational maxims, including the one of relation. this maxim urges the participants to a conversation to only contribute statements that are relevant. accordingly, merely repeating the same assertion in a discourse would be seen as apparently violating this maxim, and hence as calling for a non-standard interpretation according to which the statement is, pace first appearances, in agreement with that maxim. based on this pragmatic perspective on meaning, and on its emphasis on the importance of context in particular, testing anybody's negation understanding abilities with minimal pairs such as examples (1) and (2) is questionable: there are many contexts in which it is appropriate to say that birds cannot fly, and these contexts might be more common than others where, say, it is appropriate to say that birds cannot breastfeed -even if the latter, but not the former would be considered true from a zoological point of view. this pragmatic perspective then grounds our hypothesis that it is context resolution, not negation understanding, that explains the models' performance on minimal-pairs such as (1) and (2), which is the main evaluation method in current research. ## dataset following our pragmatic outlook and our hypothesis, we construct our datasets always using microcontexts to guide the models and to avoid confounding inability to determine context with inability to understand negation. furthermore, we pay careful attention to grammatical details that might influence prediction, and we construct our positive examples (those not containing a negation) such that they respect the maxim of relation. we here give the generic way how we create our datasets. in the following section 5, we discuss the experiment-specific details of the templates used in each of the experiments. as we are tailoring our datasets to each individual model, we actually create some 12 million of potentially different test sentences in total. we have discussed each of the templates (43 in total) with a native speaker and philosopher of language, dr. david dolby. we detail how his review has influenced the dataset in the appendix, section c. ## experiments for our experiments, we use the models provided by huggingface @xcite . we fine-tune the most promising models using a dataset that has been filtered from english wikipedia with a rather simple regular expression, yielding 315 thousand sentences. for details, see the appendix, section d. we have conducted three different experiments using the dataset creation method spelled out in the previous section. all of our experiments obey the basic pragmatic requirement to use micro-contexts, we pay attention to syntactic details that might matter for prediction, and we observe the maxim of relation for positive samples (requiring that we don't expect the models to merely repeat information). the first experiment forms the basis, it examines the ability of the models to correctly use information contained in negated sentences for prediction in a later sentence. in the second experiment, we use three kinds of misprimes to see whether this confuses the models, and in the final experiment, we test whether the models are sensitive to changes of referents. for a full list of the templates used in all experiments, see the appendix, section b; the scripts as well as these templates are also available on github. 4 experiment 1 in the first experiment, we used sentences of the form (7) and ( 8 ) to test the models' sensitivity to negation. note that, with these templates, we made sure that the negated versions have a higher subsequence overlap than the corresponding positive versions, as the plms have a reputation for reacting strongly to such subsequences ("subsequence overlap" here refers to the overlap in tokens between the context where the act-token occurs and the context where the mask occurs, see @xcite . this means that, if the results show that the models predict an act-token to fill the mask more often with positive than with negated sentences, this cannot be because of the subsequence heuristic, as following this heuristic would pull the models ' prediction in the opposite direction. from a linguistic perspective, examples such as (8) obey grice's maxim of relation by introducing new information in the second sentence. furthermore, we varied gender and the number of act-tokens in the first sentence (ranging from 1 to 3), and we also varied the extent to which we syntactically express the contrast in the negated version, motivated by pragmatic attention to syntactic detail. starting from example (7), we first removed the conjunction ("however"), then we also removed the "does", which also marks a contrast. in the positive version, we added templates that do not have a conjunction signaling implication ("so"). overall, this yields 30 different templates, which we expanded into sentences as described in the previous section. then, we let the models predict the tokens to fill the mask. experiment 2 in the second experiment, we wanted to further probe the robustness of the models' negation understanding by adding specific misprimes. examples (9), (10), and (11) illustrate the patterns used here. by varying gender as well as the presence or absence of a contrastive conjunction ("in contrast"), we obtained 10 templates, which we expanded and saturated as described above. the basic idea behind templates of the kind of ( 9 ) and ( 10 ) is to bring to light shallow heuristics that are based on occurrence of the verbs in the context of the mask to be filled. the expectation is that, if the models do not represent any logical structures involving negation, then the logically more explicit patterns of the form (10) are going to be more misleading to them than the less explicit ones of the form (9): in the former sentences, the proper name appears again in the context of the activity that is not supposed to be predicted as a filler of the mask. the random sentence inserted in (11), finally, is intended to test whether the models can transfer information contained in a negation across an unconnected sentence (one, notably, that might appear odd to humans as well, but which would not lead them to forget about the negated sentence). experiment 3 this third experiment, finally, is entirely dedicated to assessing whether the models are sensitive to changes in referents. by using templates of the form (12) (3 in total), we wanted to see whether the models are sensitive to obvious changes in referents. in templates such as (12), we included genderincongruity and different proper names to clearly signal that the person of the first sentence that does not like to act is not the same as the cleopatra of the second sentence. ## results in the following, we report on the results of the experiments conducted as described in the previous section. the key figure that we are reporting is the percentage at which the model predicted an actreplacement token (in the following: "act-token"), for instance, "draw" in ( 6 )) to fill the mask. we call this figure "%-act-repetition". generally, a high percentage of act-repetitions implies poor performance with negated first sentences: these are the exactly wrong predictions. in contrast, a high percentage of act-repetitions is ok with positive first sentences; indeed, it is often a natural completion of the sentence, given the information in the first sentence. furthermore, we report on results obtained by using act-tokens of probability rank 0 and 50 (for information on probability ranks, see above, section 4.3). finally, xlnet-large-cased performed so poorly that it has been excluded in the display of results in the present section. since the predictions of this model were often ungrammatical, listing them along with the others would have given a false impression of equivalence; for instance, predicting ")" as an act-token in example (5) and "," to fill the mask in example (6) would not count as an exactly wrong prediction, but it would of course be mistaken. in this sense, our approach requires that the predictions by the models be more or less sensible and grammatical, which all models except for this one fulfilled. however, xlnet-large-cased's performance is given in detail in the appendix, section g, figure 12 . experiment 1 figure 1 displays the effect of negation on prediction. the values shown are percentages of cases where the model predicted (one of) the act-token(s) to fill the mask in the final sentence. as mentioned, in general, repeating such an activity token is correct if the activities are not in the scope of a negation, but exactly wrong if they are in such a scope, as in example (6). in figure 1 , the red-to-reddish bars give the percentage at which the models wrongly predicted an act-token to fill the mask, even though it was excluded by a negation in the first sentence. the green bars show the percentage at which the models predicted an act-token that has not previously been excluded via negation (which is perfectly fine). in the first column of figure 1 , the results of neg-roberta-large are displayed. this model wrongly predicts one of the act-tokens to fill the mask in roughly 8% of cases if the first sentence is negated. the presence or absence of contrastive signals matter little. if the first sentence is not negated, the percentage goes up to some 52% on average, despite the fact that the lexical overlap is much smaller with positive templates. this yields a delta of 44% between negated and positive templates. such a high delta indicates a sensitivity of the model for negation. in contrast, if both scores are low, they might be low simply because the model is unable to retain any information and hence predicts something completely unrelated to the context, or even something ungrammatical. it is notable that fine-tuning does show a significant, albeit slightly unstable effect both regarding roberta-large and regarding bert-large-cased. furthermore, as mentioned previously, the effect is much stronger with xlnet-large, as the vanilla version was simply predicting gibberish (closing brackets, for instance), while the fine-tuned version shows very strong performance. figure 2 shows further results from experiment one. we are here only showing the performance on negated templates. this means that, gener-figure 1 : percentages of prediction of act-token(s) ("neg": negated sentences, "pos": positive sentences, "n": no additional markers, "d": contrastive "does", "c_d" contrastive does with contrastive conjunction, "i_d": implicative conjunction plus "does" for emphasis). these predictions are ok if there is no negation in the first sentence (greenish bars) and exactly wrong if the first sentence is negated (red-reddish bars). figure 2 clearly shows that the bert models (both large and base) react very strongly to high probability ranks: neg-bert-large's error rate drops from almost 40% to about 2% if the probability rank of the act token is lowered from 0 to 50, 100, or 200. xlnet, in contrast (and quite surprisingly), has a lower error rate with probability rank 0 tokens than with tokens of lower probability ranks. experiment 1 has also shown some differences in performance of plms depending on the gender of the templates. in particular, the robertas perform worse with male gender than with female gender. for details, see section f. experiment 2 figure 3 shows percentages of act-repetition depending on the misprime or additional sentence inserted (for the interpretation of the cleo-row, see below, experiment 3). overall, the results show that all models are confused by the misprimes, but notably, neg-roberta-large only really loses performance with the one random sentence inserted. furthermore, the results resemble the one presented above in figure 1 as far as the smaller models are performing worse, with distilbert being clearly at a loss. fine-tuned xlnet loses much precision with the misprime with a "but", indicating a lack of representation of logical structure (see above, section 5). ## discussion in the following, we first conduct a brief analysis of the predicted tokens, then we discuss four insights that flow from our results. ## conclusion in this paper, we have examined the extent to which contemporary transformer-based plms understand negation. we have done so by presenting the models with tailored masked language modelling tasks that are structured in a way that is pragmatically sound and that ensures that the known shallow heuristics are of no help. we have found that all but two models are clearly sensitive to negation. it seems justified to say that the best-performing model understands negation, as it erroneously repeats a negated token in only 12% of cases even when strong misprimes are used (with the exception of the questionable insertion of a random sentence, where the figure is 30%), and it shows clear sensitivity to changes in reference. our results complement and partly contrast earlier, semantics-based studies of plms' negation understanding.