Noisy Text Data: Achilles’ Heel of BERT (2020)

Abstract: Owing to the phenomenal success of BERT on various NLP tasks and benchmark datasets, industry practitioners are actively experimenting with fine-tuning BERT to build NLP applications for solving industry use cases. For most datasets that are used by practitioners to build industrial NLP applications, it is hard to guarantee absence of any noise in the data. While BERT has performed exceedingly well for transferring the learnings from one use case to another, it remains unclear how BERT performs when fine-tuned on noisy text. In this work, we explore the sensitivity of BERT to noise in the data. We work with most commonly occurring noise (spelling mistakes, typos) and show that this results in significant degradation in the performance of BERT. We present experimental results to show that BERT’s performance on fundamental NLP tasks like sentiment analysis and textual similarity drops significantly in the presence of (simulated) noise on benchmark datasets viz. IMDB Movie Review, STS-B, SST-2. Further, we identify shortcomings in the existing BERT pipeline that are responsible for this drop in performance. Our findings suggest that practitioners need to be vary of presence of noise in their datasets while fine-tuning BERT to solve industry use cases.

## introduction pre-trained contextualized language models such as bert (bidirectional encoder representations from transformers) @xcite , which is the focus of this work, has led to improvement in performance on many natural language processing (nlp) tasks. without listing down all the tasks, bert has improved the state-of-the-art for a number of tasks including tasks such as summarization, name-entity recognition, question answering and machine translation @xcite . buoyed by this success, machine learning teams in industry are actively experimenting with finetuning bert on their data to solve various industry use cases. these include use cases such as chatbots, sentiment analysis systems, automatically routing and prioritizing customer support tickets, ner systems, machine translation systems to name a few. many of these use cases require practitioners to build training and test datasets by collecting text data from data sources & applications such as chats, emails, discussions from user forums, social media conversations, output of machine translation systems, automatically transcribing text from speech data, automatically recognized text from printed or handwritten material, etc. owing to these sources & applications, the text data is known to be noisy. in some sources such discussions from user forums & social media conversations, the noise in the data can be significantly high. it is not very clear how the pre-trained bert performs when fine-tuned with noisy text data and if the performance degrades then why so. these two questions are the focus of this paper. though the datasets used in industry are varied, many of them have a common characteristicnoisy text. this includes spelling mistakes, typographic errors, colloquialisms, abbreviations, slang, internet jargon, emojis, embedded metadata (such as hashtags, urls, mentions), non standard syntactic constructions and spelling variations, grammatically incorrect text, mixture of two or more languages (a.k.a code mix) to name a few. this makes cleaning and preprocessing text data a key component of nlp pipeline for industrial applications. however, despite extensive cleaning and preprocessing, some degree of noise often remains. owing to this residual noise, a common issue that nlp models have to deal with is out of vocabulary (oov) words. these are words that are found in test and production data but are not part of train-ing data. in this work we find that bert fails to properly handle oov words (due to noise). we show that this negatively impacts the performance of bert on fundamental tasks in nlp when finetuned over noisy text data. this work is motivated from the business use case where we are building a dialogue system over whatsapp to screen candidates for blue collar jobs. our candidate user base often comes from underprivileged backgrounds, many of them are not even college graduates. this coupled with fat finger problem 1 over a mobile keypad leads to a lot of typos and spelling mistakes in the responses sent to our dialogue system. hence, for the purpose of this work, we focus on spelling mistakes as the noise in the data. while this work is motivated from our business use case, our findings are applicable to other use cases that deal with noisy text data. ## previous work we now present some of the relevant work viz the following related areas viz. (1) robustness of bert, (2) degradation in performance of nlp models due to noise in text data. ## experiments we evaluate the state-of-the-art model bert 2 on two fundamental nlp tasks: sentiment analysis and textual similarity. for sentiment analysis we use popular datasets of imdb movie reviews @xcite and stanford sentiment treebank (sst-2) @xcite ; for textual similarity we use semantic textual similarity (sts-b) @xcite . both sts-b and sst-2 datasets are a part of glue benchmark @xcite tasks. on these benchmark datasets we report the system's performance both -with and without noise. ## analysis to understand the reason behind the drop in bert's performance in presence of noise, we need to understand how bert processes input text data. a key component of bert's pipeline is tokenization of input text. it first performs whitespace tokenization followed by wordpiece tokenization @xcite . while whitespace tokenizer breaks the input text into tokens around the whitespace boundary, the wordpiece tokenizer uses longest prefix match to further break the tokens 3 . the resultant tokens are then fed as input to the bert model. when it comes to tokenizing the noisy text data, we see a very interesting behaviour from bert's pipeline. first whitespace tokenization is applied. now, when the wordpiece tokenizer encounters these words, owing to the spelling mistakes, these words are not directly found in bert's dictionary. so, wordpiece tokenizer tries to tokenize these (noisy) words into subwords. however, it ends up breaking the words into subwords whose meaning can be very different from the meaning of the original word. this can change the meaning of the sentence completely, therefore leading to substantial dip in the performance. to understand this better let us look at two examples -one each from the imdb and sts-b datasets respectively, as shown in example 1 and example 2. in each example, (a) is the sentence as it appears in imdb 0 (i.e. original dataset) while (b) is the corresponding sentence after adding 5% noise (imdb 5 ). for legibility the misspelled characters are highlighted with italics. the sentences are followed by their corresponding output after applying whitespace and wordpiece tokenizer on them. in the output, ## represents subwords. in example 1(a), bert's tokenization splits communicates into communicate and ##s based on longest prefix matching because there is no exact match for communicates in pre-trained bert's vocabulary. this results in two tokens communicate and s, both of which are present in bert's vocabulary. we have contextual embeddings for both communicate and ##s. by using these two embeddings, one can get an approximate embedding for communicates. however, this approach goes for a complete toss when the word gets misspelled. in example 1(b), the word natuee('nature' is misspelled) is split into tokens nat, ##ue, ##e (based on the longest prefix match). by combining the embeddings for these three tokens, one cannot approximate the embedding of 'nature'. this is because the word nat has a very different meaning (it means 'a person who advocates political independence for a particular country'). this misrepresentation in turn impacts the performance of downstream sub-components of bert bringing down the overall performance of bert model. this is why as we introduce more errors, the quality of output of the tokenizer degrades further, resulting in the overall drop in performance. we further experimented with different tokenizers other than wordpiece tokenizer. for this we used character n-gram tokenizer @xcite and stanfordnlp whitespace tokenizer @xcite . for character ngram tokenizer, we work with @xmath0. the results of these experiments on sts-b dataset are given in please note that in our experimental setup, we are not training bert from scratch. instead, we simply replaced the existing wordpiece tokenizer with other tokenizers while feeding tokens to bert's embedding layer during the fine-tuning and testing phases. ## conclusion and future work we studied the effect of synthetic noise (spelling mistakes) in text data on the performance of bert. we demonstrated that as the noise increases, bert's performance drops drastically. we further show that the reason for the performance drop is how bert's tokenizer (wordpiece) handles the misspelled words. our results suggest that one needs to conduct a large number of experiments to see if the findings hold across other datasets and popular nlp tasks such as information extraction, text summarization, machine translation, question answering, etc. it will also be interesting to see how bert performs in presence of other types of noise. one also needs to investigate how other models such as elmo, roberta, and xlnet which use character-based, byte-level bpe, and sentencepiece tokenizers respectively. it also remains to be seen if the results will hold if the noise was restricted to only frequent misspellings. to address the problem of drop in performance, there are 2 ways -(i) preprocess the data to correct spelling mistakes in the dataset before fine-tuning bert on it (ii) make changes in bert's architecture to make it robust to noise. from a practitioner's perspective, the problem with (i) is that in most industrial settings this becomes a separate project in itself. we leave (ii) as future work.