Compositional and Lexical Semantics in R o BERT a, BERT and D istil BERT : A Case Study on C o QA (2020)

Abstract: Many NLP tasks have benefited from transferring knowledge from contextualized word embeddings, however the picture of what type of knowledge is transferred is incomplete. This paper studies the types of linguistic phenomena accounted for by language models in the context of a Conversational Question Answering (CoQA) task. We identify the problematic areas for the finetuned RoBERTa, BERT and DistilBERT models through systematic error analysis - basic arithmetic (counting phrases), compositional semantics (negation and Semantic Role Labeling), and lexical semantics (surprisal and antonymy). When enhanced with the relevant linguistic knowledge through multitask learning, the models improve in performance. Ensembles of the enhanced models yield a boost between 2.2 and 2.7 points in F1 score overall, and up to 42.1 points in F1 on the hardest question classes. The results show differences in ability to represent compositional and lexical information between RoBERTa, BERT and DistilBERT.

## introduction it has recently been recognized in the research community that neural network models generally do not exploit the compositionality of language, often relying on superficial features foot_0 . compositionality refers to the fact that linguistic constituents combine into phrases hierarchically to compose meaning. contextualized word embeddings (bert, @xcite @xcite can be expected to be limited in their ability to learn such complex aspects of language, since the models are usually trained with cloze filling and next sentence pre-diction objectives, and are not directly exposed to semantic relations between phrases. while larger models yield higher performance, they still lack generalization ability @xcite and are computationally expensive, which has led to an increasing interest in reducing model size. for instance, distilbert is built using the knowledge distillation technique @xcite on bert, which leads to a lighter and faster model that does not lose much in performance on the majority of the tested tasks. on the other hand, state-of-the-art models use vast amounts of training data -16gb for bert, 10 times more for roberta. this study tackles the question of what type of linguistic knowledge is missing from contextualized word embeddings, comparing models on the basis of their training set size (bert vs. roberta) as well as their model size (bert vs. distilbert). the tasks of machine reading comprehension (mrc) and dialogue are particularly fitting for this purpose, due to the fact that they require a system to interpret language within a context and perform semantic and pragmatic inference between sentences. the task in the conversational question answering dataset @xcite is mrc combined with dialogue -the input to the system is a context document and a dialogue of questions and answers about that text, which lead up to the question that the system is required to answer. an example from coqa follows. background: [...] at the time, the name did not describe a single political entity or a distinct population of people [...] question n-1: did the name describe a political body? answer n-1: no question n: did it describe a people group? answer n: no in order to answer question n without relying on superficial features, one needs to be able to interpret the logical operators "and" and "or" (underlined), and their scopes, as well as determine that the italicized phrases are synonymous. this study tackles such cases with linguistically enhanced models. our assumption in this paper is that if a model performs poorly on the classes of questionanswer (qa) pairs that require certain linguistic knowledge x (e.g. negation, disjunction and synonymy in the example above) for their solutions, and if its performance boosts when it explicitly learns x (e.g. through a multitask setting with an auxiliary linguistic task), it can be considered evidence for the original model's lack of linguistic representations of x. the main contributions of this paper can be summarized as: there has recently been much interest in diagnostic analysis of bert, studying what type of linguistic representations it learns. rogers et al. (2020) provide an overview of such papers under the name of bertology, showing what types of linguistic phenomena cause difficulty for bert. some such studies focus on compositional semantics in the form of negation, negative polarity items (npis) and semantic role labeling (srl). in testing npi licensing, @xcite perform a cloze task and compare whether bert predicts a higher probability for an npi in a licensed context or outside of such a span. they show that while bert is capable of detecting npi licensors (e.g. "don't") and npis themselves (e.g. "ever"), it only does so successfully in cases where the span of the npi appears in the canonical position with regard to its licensor. this suggests that the model relies on word order instead of parsing the syntactic dependencies. when it comes to interpreting negation, ettinger (2020) analyzes whether bert predicts a higher probability for sentences such as "robin is not a tree" and "robin is a bird" than "robin is a tree" and "robin is not a bird", and conclude that bert is not very sensitive to negation. this test, however, relies strongly on bert's ability to represent lexical semantics of the nouns and the lack of intersection of their typical meanings. it could be argued that it therefore is not a reliable test to tell whether bert can make logical deductions based on negation. instead, we argue that it should be tested in a context where "robin" can be anything, including a name of a tree, so that it can be determined whether bert can infer that in such a case "robin" would not be a bird. similarly, @xcite has also addressed the question of whether bert has the knowledge required to infer semantic roles from a text. for example, she tests bert's ability to assign a higher probability to the word "served" in a statement such as "the restaurant owner forgot which customer the waitress had served" than in "the restaurant owner forgot which waitress the customer had served". this test is analogous to the previous example with a robin, in the sense that it tests the model's ability to learn biases of common semantic roles that certain nouns manifest. the model can simply rely on the fact that one of these two word orders is more likely than the other, however this does not provide evidence that bert can make inferences about semantic roles. thus, it remains to be verified whether bert can abstract the semantic roles from any range of naturally occurring sentences, some of which exhibit uncommon semantic role occurrences (e.g. customers serving waiters). in a similar vein, previous research has shown that the embeddings of antonyms in models such as bert are not clearly distinguishable @xcite . this, similarly to issues with negation, shows that bert is not good at representing nonintersecting denotations. what is more, @xcite show that bert performs poorly on artificially constructed diagnostic items which test the model's ability to perform logical inference. nonetheless, they demonstrate that it is possible for bert to extrapolate the relevant linguistic phenomena quickly by finetuning the model on the same artificial data. pragmatics also plays a role in determining relations between sentences, however this field has been less explored with regard to contextualized word embeddings. some research has probed bert on its capabilities to infer pragmatic phenomena related to negation, such as factives, conditionals and questions @xcite . for instance, one has to make the pragmatic inference that a speaker would only utter "not a one of them realized i was not human" if their lack of humanity was already established as common knowledge. @xcite show that bert takes longer to learn such complex reasoning than negation. in contrast, some studies research what common sense knowledge and abstract reasoning that bert and other language models learn. @xcite show that there is a large gap between bert and roberta with regard to their inference abilities. for instance, since roberta is trained on significantly more data, it can determine which person is older based on their ages or dates of birth, while bert cannot. interestingly, however, even roberta is shown to rely on the range of examples seen at training time, as it is not able to generalize to the ages of people who are not born between 1920s and 2000s. this suggests that there is a need for a more abstract reasoning ability in models such as bert, which does not seem to be solved by an increased size of the training set. finally, @xcite show that even for the roberta-based abstractive model, which reached state-of-the-art results on coqa at the time, questions with numerical answers account for a disproportionately large fraction of errors. based on the studies conducted so far, one general trend appears to be pertinent. that is, while many studies have explored the linguistic knowledge of bert, it is still not clear whether bert is able to infer compositional structures from text as opposed to relying on biases. in addition, to the best of our knowledge, no probing tasks have been performed on bert in the conversational question domain, which is fitting for analyzing bert's behaviour in complex reasoning and inference. finally, while larger models such as roberta yield gains in performance, they still lack in generalization ability. thus, this paper aims to shed light on the less scrutinized aspects of bert's linguistic capabilities. ## dataset the coqa dataset foot_1 is used as a case study in this paper. it covers several domains and amounts to 127,000+ samples including a story, a qa pair and the dialogue history. the answers to the questions are based on the context document, however they can be paraphrases. the training data also contains rationales, which are the spans of the background text containing both the answer and the context required to determine the answer. the test set is composed of the reddit and science domains, while the rest of the domains are split between train, development and test (see ## baseline models the input to the model is a concatenation of the background story, the latest dialogue history of 64 tokens, and the current question. the length of the input is limited to 512 tokens. we build the baseline roberta, bert and distilbert base models for coqa as extractive models, within the framework of @xcite and following @xcite , who produce the highest results with a bert-based extractive model on coqa. an extractive model does not generate the answer as an abstractive model would, but selects the span in the document that best matches the gold answer. in order to train our extractive models, the substrings of the rationales which are most similar to the gold answers (as measured by f1) are selected as the training labels. following a standard procedure, a linear classifier head is added on top of bert with relu activation which classifies every token in the input sequence as start or end of the answer span. another linear classifier predicts whether each token in the input span falls within the rationale span or outside of it. finally, one more classifier predicts whether the example is freeform, has a yes/no answer or is unanswerable. yes/no/unanswerable answers are used instead of the predicted span if the model predicts the latter classes with higher confidence than the start and end tokens of the answer. models are trained for 4 epochs (taking a few hours on a single geforce gtx 1080 ti gpu) with a learning rate of 3e-5 and adamw optimizer @xcite . the same hyperparameters are used for all models trained in this work. ## baseline results and error analysis on the development set foot_2 , the roberta model gets 81.2 points f1 foot_3 , bert scores 76.9 f1 and falls two points short of the @xcite implementation, and distilbert scores 66.6 f1, which establishes a baseline as this is the first work using distilbert on coqa (see to resolve what types of linguistic inference are the hardest for the baseline models, several potentially difficult qa classes are analyzed. they are defined based on the findings of previous research as well as the observations of a qualitative evaluation of the errors made by the bert model. then, a quantitative evaluation of how the baseline models perform on each class is performed. there is ample variation in how the models score on various example classes (see the first expected source of error for the base-line models is the inability to count listed phrases. since the models are extractive, counting cannot fall within their capabilities. for example, the rationale below lists the characters in the background story: rationale: a poor man ti, his son dicky and their alien dog cj7 question: how many characters were there? answer: three in the current setting the models cannot chunk the text into noun phrases and then count the chunks to answer the question, as they are limited to extracting the answer from the background text. while the model performance is satisfactory on a wide range of questions with numerical answers (num), they fail consistently on questions with answers in the integer set between 1 and 5 (1-5). the num class is defined using a state-ofthe-art rule-based question classification system from madabushi and lee (2016), which evaluates each qa based on the question alone. the contrast between the scores on the two classes can be explained by the fact that while extracting numerical answers such as dates is easy for the models, they struggle on the task of counting linguistic objects, which are usually manifested in low value integers. the second expected problematic area is negation. negation cues are words ("not", "without") or morphemes ("dis-", "un-", "ab-"), which negate the context that they span over. the example below illustrates two ways that the model can fail in face of negation cues. rationale: something looked like a bird's belly [...] it was not a bird's belly [...] a bottle floated there question: what looked like a bird's belly? answer: a bottle wrong answer 1: a bird's belly wrong answer 2: not a bird's belly the most general type of error is neglecting the negation cue altogether and answering the question with wrong answer 1. this reflects on the model's inability to determine that the noun phrase "a bird's belly" falls under the scope of the negation cue "not". wrong answer 1 would be the correct answer if the phrase was not negated. the second and more rarely observed type of error reflects a lack of pragmatic knowledge as opposed to semantic or syntactic. in wrong answer 2 the model could be argued to have answered correctly as it is technically true that what looked like a bird's belly was not a bird's belly. however assuming grice's maxim of quantity, which states that one should be as informative as required @xcite ), the answer is not satisfactory. wrong answer 2 is not informative at all as it has already been implied by the question. we define the neg qa class as containing answers that are embedded under negation. for recognizing such answers, negation cues and their spans are detected with a bert-based model following @xcite and trained on the sherlock dataset @xcite . we reproduce the results on that dataset before using the model for detecting the negated spans in the background documents in the coqa dataset to find the neg type answers. our baseline models perform worse on the neg qa class than overall, and score much higher on questions with yes answers than no answers, which suggests that the models do not interpret negation correctly. the effect of negation on performance is particularly stark in the case of distilbert. furthermore, the ant class is composed of examples in which the rationale contains antonyms of the words in the question, using wordnet @xcite . here explicit negation is not necessarily involved, however the model's ability to reason over semantic polarity is tested in this qa class. our baseline results on class ant are in line with previous conclusions stating that bert is not good at representing antonymy, as it scores lower on this class than overall. yet interestingly, distilbert as well as roberta perform better on this subclass of questions than overall. we conjecture that lexical semantics is the strongest feat of bert, therefore it is likely that distilbert retains most of the lexical information such as antonymy through the process of distillation. on the other hand, roberta learns more about lexical features such as antonymy from the huge size of the training set. in addition, sent is a qa class in which the sen-timent of the sentence containing the rationale is different from the sentiment of the question. the class items are determined by sentence splitting @xcite and sentence-level sentiment classification @xcite . this class is intended to capture examples where the polarity between the question and the answer can be expressed not only by negation or antonymy but also any other means, for example pragmatics. however, a qualitative analysis of the examples of the sent class shows that the examples which contain contradictory sentiments between the question and the answer mostly do not require one to determine the sentiment in order to answer the question correctly. for instance, the question below has a slightly negative connotation about a long job hunt: rationale: nearly four years later, as obama seeks reelection, casillas has finally landed his first fulltime job, emerging out of the group known as the long-term unemployed. question: how much later did he get his next job? answer: nearly four years later in contrast, the rationale takes a more positive outlook. nonetheless, the answer is "four years", regardless of whether that is considered too long or not. there generally does not appear to be a relation between the sentiment values of the rationale and question and the model predictions. accordingly, neither of the baseline models struggle to answer sent questions. moreover, as stated in @xcite , the order of questions on the coqa dataset follows the natural order of text. that is, later questions refer, generally, to information presented towards the end of the background story. hence, the one answering the questions ought to make inferences about what has already been discussed and where in the story they are when a given question is posed. in some cases this knowledge can be crucial for reaching the correct answer. for instance, in the example below, one has to determine what time within the story the question refers to. background: [...] the hospital had been bombed and hans had made his way back into western germany on foot. [...] question: was he in the eastern or western part? answer: east germany that is, the answer differs depending whether the question refers to hans's location prior or post his journey, which is also reflected in the different answers that the human annotators provide to this question. in this case the answer is "east germany" even though that part of the country is never mentioned in the text, which makes the example very challenging with regard to pragmatic inference. in order to evaluate how our models perform with regard to following the dialogue flow, they are evaluated on items which do in fact follow the order of the document, so that the answer to question n in the text is subsequent to the answer to question n -1 (ord). it appears that all baseline models are able to infer this order to some extent and perform better on such questions than those that jump to previous passages in the text. furthermore, examples are classified with regard to whether the order of the semantic roles mentioned in the question is the same (srl+) or different (srl-) to the semantic role order in the sentence containing the rationale. srl is performed employing an allennlp @xcite model. to illustrate, figure 1 shows an example where the roles of agent (arg0) and patient (arg1) are reversed in the question by means of a passive voice. all three models fail more on such examples with different word order between the question and the rationale, scoring lower on the srl-class than overall or srl+. the results of the experiments show that the models find the correct answer more frequently when they can rely on the word order, avoiding the need to reason over semantic roles. finally, some of the observed issues are induced by the model choosing prominent entities as answers regardless of their actual relation to the question at hand. for instance, a document tells a fictional children's story wherein foods and utensils are anthropomorphised, as in the example below: rationale: cereal is winning the race in a bowl of milk question: who is a good swimmer? answer: cereal the baseline bert model chooses a human entity that is mentioned by name at the beginning of the text instead of the inanimate entity that takes up the agent position in the rationale. in contrast, if "cereal" is substituted with a common name such as "mark" in the background document, the model correctly chooses it as the answer. this suggests that the model relies on lexical semantics and biases about types of entities denoted by nouns more than analyze the semantic relations in the relevant sentence. therefore, we define a qa class where the rationale contains entities that have high entropy and are thus surprising given the rest of the sentence @xcite @xcite , like "cereal" in the above example. in order to detect such entities, proper nouns (as tagged by spacy, from @xcite are masked and bert is used to evaluate the likelihood of the original word being the filler for that mask. words that fall below the likelihood threshold of 5e-5 are then deemed to be surprising entities foot_4 . all three models perform worse on questions about surprising entities (surp) than overall, with distil-bert exhibiting the largest margin. moreover, the classes of human (hum), location (loc) or general entities (ent), as classified by madabushi and lee (2016), test the models' ability to answer questions about entity roles. roberta and bert's performance on these classes is higher than their overall performance. on the other hand, distilbert fails on hum and loc entity questions more than other qa types. for many hum and loc questions there are multiple entities in the text that fit the entity type. together with the results on the surp class, this is an indication that distilbert relies on entity type more than the larger models. the baseline results on the various classes corroborate most of the results of previous research on bert's shortcomings. moreover, the results show that distilbert mostly repeats the same mistakes and often more gravely, except for some cases of lexical semantics. distilbert appears to lose more of bert's already limited representations of the formal aspects of language and have stronger biases. finally, roberta also exhibits a lack of ability to perform compositional reasoning and reaches the highest scores on the more lexical qa types. 6 model enhancement ## enhanced model results the results of all the enhanced models on all qa classes on the development set are presented in f1 with the counting model on counting questions (base# on 1-5), while distilbert only improves on these questions remarkably with the ensemble model, requiring more auxiliary resources than the larger models for this level of abstraction. moreover, bert appears to learn formal aspects of semantics in the multitask setting. the srl# model improves on the qa class with semantic roles in a different order in the question and the answer (srl-), while the negation# model improves the results on the answers that require interpreting negation (neg and no). to illustrate, while the base# model fails to take into account the negative morpheme "dis-" and answers "yes" to the question below, the negation# model avoids such errors. rationale: some refer to tolstoy's disagreement with state-backed religion. question: did he agree with the states view on religion? answer: no this shows that the negation# model has learnt to recognize the negation spanning over the "agree" root, which plays a deciding role for determining the correct answer to the question. in the meantime, roberta does not improve on the qas in the negation or semantic role classes. one might say that roberta has learnt the abstract linguistic representations already, however its base results show that it makes many of the same mistakes as bert and distilbert on neg and srl-. in fact, bert outperforms roberta on the neg class when enhanced with the explicit information about negation (the negation# model). this, combined with the fact that roberta gets a big improvement on neg only when various linguistic features are combined into an ensemble, suggests that roberta mostly relies on better lexical representations for its higher scores, which is only outweighed when many compositional semantic cues are provided. similarly, distilbert only gains a small boost over the baseline on neg and no qa classes with negation# and also requires an ensemble to improve on srl-. on the other hand, bert and distilbert improve on the hum and loc classes with the ensemble models, demonstrating an ability to improve its lexical representations. roberta does not yield an improvement in this case, however even its base model performs relatively well on these classes. furthermore, bert and distilbert do not get a boost in the cases of pragmatics, namely sentiment# and order#. in contrast, roberta gets a boost over the ant class from the sentiment#, and gains the largest increases across almost all classes from order#. it appears that roberta can improve on its already high score on items containing antonymy relying on more pragmatic aspects of lexical semantics, and also is the most receptive to the pragmatic aspects of dialogue in coqa. moreover, the model trained on the dataset which was augmented through surprising word substitution (surprisal#) improves over base# on the class with surprising entities (surp) with bert and distilbert. this shows that the method helps the models generalize better to cover new examples with surprising entities and get rid of some of the biases about entities. for example, while the base# bert model answers the question below incorrectly, the model enhanced with surprisal# selects the name of the relevant character. the base# model simply selects the name that is more common. in contrast, the enhanced model detects the correct name of the person who is performing the role in the question. substituting the name in the original background document with a mask token shows that bert assigns a larger probability to the name "nat poole" than "link merwell". such examples stand to show that a bert model is biased towards more common entity names. nonetheless, the models are able to learn to abstract away from the biases of the connotations and lexical semantics of entity names and find the entities with the right semantic roles even for rare entities, given that the model has been exposed to both rare and common entities in the same contexts during training. interestingly, in the case of bert the largest boosts in the surp class are produced by the negation# and srl# models, showing that focusing on compositional information such as semantic roles and negation helps the model to be less biased towards very prominent lexical information of stereotypical entities as discussed in section 5. in contrast, in the case of roberta, surprisal# does not yield an improvement on the surp class. roberta requires all of the enhanced models to be combined into an ensemble in order to get rid of the biases, suggesting that its focus on (biased) lexical representations is even stronger than bert or distil-bert's. finally, the ensemble models perform better on virtually all classes and provide a better overall score. this is to be expected as the enhanced models, while performing at a similar level, make different errors and complement each other with their respective specializations. ## conclusion by and large, this paper provides additional evidence that models like bert lack linguistic abstraction abilities, often relying on superficial features such as entity name biases or word order to answer questions in the conversational question answering task. more precisely, we show that bert, roberta and distilbert models mostly fail on questions that require inference over the compositional aspects of language, such as semantic roles and negation. furthermore, we find that while roberta improves over bert's performance, a large portion of its gain comes from better lexical representations and it appears to fall short of solving the compositional semantic problems. what is more, we provide the first evaluation and analysis of distilbert on coqa, showing that distilbert, more so than bert, relies on lexical information most and lacks capacity to learn compositional representations. finally, we show that all the bertlike models tested can be enhanced to a varying extent by feeding them linguistic knowledge through a multitask approach. even a small amount of training data for linguistic information such as negation can provide a very large boost to the model performance on the qa classes which rely on that information.