Can Pretrained Language Models Derive Correct Semantics from Corrupt Subwords under Noise?
Year: 2023

Abstract:
For Pretrained Language Models (PLMs), their susceptibility to noise has recently been linked to subword segmentation. However, it is unclear which aspects of segmentation affect their understanding. This study assesses the robustness of PLMs against various disrupted segmentation caused by noise. An evaluation framework for subword segmentation, named Contrastive Lexical Semantic (CoLeS) probe, is proposed. It provides a systematic categorization of segmentation corruption under noise and evaluation protocols by generating contrastive datasets with canonical-noisy word pairs. Experimental results indicate that PLMs are unable to accurately compute word meanings if the noise introduces completely different subwords, small subword fragments, or a large number of additional subwords, particularly when they are inserted within other subwords.

heading: 1 Introduction
text: The capability to understand the meaning of noisy words through character arrangements is a crucial aspect of human cognitive abilities (Rawlinson, 2007). This capability is highly sought after in practical applications such as machine translation and sentiment analysis (Belinkov and Bisk, 2018). However, despite their success in in-distribution test data with standardized word forms, Pretrained Language Models (PLMs), which serve as the backbone models, tend to perform poorly on rare or noisy words (Kumar et al., 2020; Baron, 2015). These noisy words may be caused by accidental typos (Belinkov and Bisk, 2018) or spelling variants on social media (Ritter et al., 2010).
Prior studies show that most subword-based PLMs perform poorly under noise largely due to subword segmentation (Zhuang and Zuccon, 2022), while character-based PLMs show more robustness (El Boukkouri et al., 2020). Examining the impact of subword segmentation factors on PLMs is also crucial for defending against the adversarial attacks
that leverage the sensitivity of subword segmentation to noise (Liu et al., 2022). However, rare work has investigated how the subword segmentation from noisy words affects the word meaning.
To help address this question, we design and develop a contrastive framework (CoLes) to assess the robustness of PLMs in the face of various forms of segmentation corruption. As subword segmentation can be influenced by noise in various ways, such as adding extra subwords or losing original subwords, we systematically categorize the ways into four main categories and two additional subcategories based on three subword sets, as exemplified in Table 1. Two types of noise models are proposed to effectively generate all the types of corruption except missing corruption, and a contrastive dataset consisting of noisy and standard word pairs is created. This framework enables us to evaluate the significance of preserved subwords and the impact of subwords added by noise.
The experimental results provide the following insights: 1) complete corruption: the PLMs struggle to infer meaning accurately if no subwords from the original segmentation are retained. The worst performance is observed when the meaning of original words is stored in the embedding; 2) partial corruption: preserving larger subword chunks can aid the understanding of PLMs, whereas retaining smaller subword pieces tend to be ineffective; and 3) additive corruption: even with all original subwords, however, the addition of subwords can harm the meaning of words, particularly when they are placed within other subwords. The more additive subwords, the greater the deviation in word semantics. All the results are consistent on the three PLMs with different vocabularies and segmentation algorithms.

heading: 2 Contrastive Lexical-Semantic Probe
text: The CoLeS probe framework has segmentation corruption and noise models that produce noisy
165
words leading to different types of segmentation corruption. These noisy words, along with their corresponding canonical forms, are organized in a contrastive lexical dataset Dcontrastive 1. An evaluation protocol is designed to examine the effect of various corruption types.

heading: 2.1 Segmentation Corruption under Noise
text: A PLM consists of a tokenizer Seg(·), which segments a given word w into a sequence of subwords, i.e., Seg(w) = (w̃1, ..., w̃K), and a PLM encoder Enc(·), which takes Seg(w) and outputs a word representation. Formally, the segmentation of a canonical word Seg(w) can be represented as a set S, while the segmentation of a noisy word Seg(w̃) can be represented as set S̃ = {w̃1, ..., w̃K}. We can then utilize set operations to define the overlap set (consisting of retained subwords), the missing set, and the additive set (comprising additional tokens that are not present in S) as O = S ∩ S̃, M = S−O and A = S̃−O, respectively.
The set data structure cannot count duplicated tokens, which frequently occur in additive corruption scenarios, such as the additive (affix) corruption example presented in Table 1. Hence, we utilize a multiset implementation of S and S̃ since such a data structure also stores the frequencies of elements, helping us assess the impact of duplicated tokens. Since the multiset implementation only includes unique elements without considering their order of appearance, we further differentiate the two types of additive corruption by iteratively comparing elements from two queue implementations of Seg(w) and Seg(w̃).
In this study, we distinguish a unique category of 1Sentiment lexicon used is from https://www.
cs.uic.edu/~liub/FBS/sentiment-analysis. html#lexicon.
corruption referred to as “intact corruption” from complete corruption, as the canonical words in this category (with whole-word vectors) remain unchanged. In total, there are six different types of corruption, as outlined in Table 1.
Identification of corruption types. During the evaluation, we need to filter each word pair according to its corruption type. First, we segment each word pair in Dcontrastive by a model-specific tokenizer Seg(·) into subwords (S, S̃). We then identify the corruption type according to the following conditions: 1) Complete corruption: S and S̃ are disjoint, i.e., O = ∅. If the length of the missing set M is 1, this noise leads to intact corruption; 2) Partial corruption: the corruption only occurs to one of the subwords (i.e., the one in M), and the other subwords (i.e., those in O) are not affected. The prerequisite is that there exist more than one subwords in the original segmentation set S. We can find such word pairs satisfy M,O,A ̸= ∅; 3) The conditions for additive corruption and missing corruption are S ∈ S̃ (or M = ∅) and S̃ ∈ S (or A = ∅), respectively. 2

heading: 2.2 Creation of Contrastive Dataset
text: Most prior noisy datasets added noise to sentences, not individual words (Belinkov and Bisk, 2018; Kumar et al., 2020; Warstadt et al., 2019; Hagiwara and Mita, 2020). Besides, as contrastive datasets containing both the original and noisy form of a word are not readily available, we create our own lexical dataset which includes both forms. Examples of the generated dataset can be found in Table 2.
2See https://github.com/xinzhel/word_ corruption/blob/main/word_corruption.py for concrete implementation.
Noise models. Two sources of noise models are used to generate the lexical dataset. Findings given in Appendix E indicate that both types of noise models have comparable effects on model performance.
1) Naturally and frequently occurring typos. Users often type neighboring keys due to mobile penetration across the globe and fat finger problem (Kumar et al., 2020), while typing quickly may result in swapping two letters Belinkov and Bisk (2018). We refer to them as Keyboard and Swap typos, respectively. Our implementation of these typos is based on Wang et al. (2021). Specifically, for Keyboard, we only use letters in the English alphabet within one keyboard distance as the substitute symbols. Further, we avoid unrecognizable word forms (e.g., “bad→bqd” or “top → tpp”) by selecting words with more than four characters.
According to the psycholinguistic study (Davis, 2003), to make noisy words recognizable for humans, we only apply noise to the middle characters and keep characters at the beginning and the end. Besides such a constraint, Swap typo also requires at least two distinct characters in the middle for swapping. However, words like “aggressive” can still be transformed into the same word by swapping “ss”, so we transform them until we get a distinct word. Finally, we set a one-edit constraint for typos.
2) Non-standard orthography. We gather words with letter reduplication from 1.6 million tweets (Go et al., 2009). To create the canonical and noisy word pairs, we match specific noisy word forms (e.g. words with repeated letters for emphasis) to their corresponding canonical forms (a sequence of definite characters). We use simple regular expression patterns to search for words with repeated letters 3. Examples in Table 3 show how effective these types of noise are in triggering different types of segmentation corruption.
3For example, pattern “\bb+a+d+” for “bad” matches “badddddddd”.
Data-generating process. We create a contrastive dataset, Dcontrastive, by applying the noise models to the lexical dataset Dcanonical, which contains words in their canonical form. The noise models are applied to each word in Dcanonical to create two misspelled words. Additionally, a random number of noisy words is extracted from the collection of 1.6 million tweets. As for the lexical dataset, Dcanonical, we choose adjectives from a sentiment lexicon that, by definition, provides positive or negative sentiment labels for use with downstream classifiers.
Evaluation. To assess the extent to which the meanings of noisy words diverge from the standard word forms, we calculate the cosine similarity between Enc(S) and Enc(S̃). For words that consist of multiple subwords, we aggregate their vectors into a single representation by averaging the token embeddings obtained from the PLMs. It is important to note that the output embedding spaces of PLMs exhibit varying levels of anisotropy (Ethayarajh, 2019; Yan et al., 2021; Gao et al., 2019). Thus, the similarity scores cannot be directly compared across different models. It is necessary to set a baseline by computing the similarity between Enc(S) and a random embedding (we use the embedding of token “the”, i.e., Enc(the)).
Additionally, we fine-tune downstream classifiers denoted as y = Cls(x), where y represents an arbitrary semantic dimension and x corresponds to the encoded representation obtained from the PLMs Enc(Seg(·)). We focus on sentiment classification as individuals frequently use sentiment words creatively on social media to express their emotions. To conduct our experiments, the sentiment of each word and its noisy variations is derived from the sentiment lexicon.
To gauge the semantic deviation caused by noise, we measure the accuracy of the noisy counterparts of words that are accurately classified in their original form.

heading: 3 Experimental Results
text: Experiments are performed on three widely used PLMs: BERTBASE, RoBERTaBASE and ALBERTBASE (See Appendix A for details). BERT (Devlin et al., 2019) accepts inputs from a Wordpiece tokenizer (Schuster and Nakajima, 2012), while RoBERTa (Liu et al., 2019), another popular frequent-based segmentation scheme, uses BPE (Sennrich et al., 2016). For comparison, we include ALBERT (Lan et al., 2020) with a probabilistic tokenizer called Sentencepiece (Kudo and Richardson, 2018).
Subwords retention is important for maintaining the correct semantics. Table 4 shows the severity of semantic deviation for each type of corruption. Generally, the more subwords the segmentation retains, the better the semantics are maintained (additive corruption > partial corruption > complete and intact corruption). Under additive corruption, the PLMs can always maintain more semantics from noisy words than random words (the baseline), while only RoBERTa has similarity score higher than the baseline under partial corruption. All the PLMs cannot infer word meaning from complete corruption.
What subwords, if retained, would enhance the comprehension of PLMs? We find that partial corruption can preserve word meaning if it retains a significant portion of the words, such as “upset” for “upsetting” or “phenomena” for “phenomenal” (See Appendix B). This is backed up by the finding that PLMs have the capability of learning morphological information, where stems contain more semantic meaning in a word compared to smaller components such as inflectional morphemes (Hofmann et al., 2021).
Are words more impacted by noise under complete corruption if their meaning is stored in the embeddings? According to Hofmann et al. (2021), if a word is represented as a single vector, PLMs can access its meaning directly from the em-
bedding (referred to as the “storage route”) instead of deducing it from the combination of subwords (known as the “computation route”). We presume that PLMs struggle to maintain the original meaning of these words when exposed to noise. We classify this type of corruption as “intact corruption”, which is a particular variation to complete corruption. To validate our assumption, we evaluate the performance of PLMs on words under intact corruption. Results show that words with intact corruption consistently perform worse than those with complete corruption, despite both having completely distinct subwords. Although intact corruption consistently yields the lowest similarity score, the PLMs may still be able to better infer some semantic dimensions, such as sentiment, under intact corruption compared to complete corruption. (Appendix C).
Presence of additive subwords can damage the meaning of words, particularly when they are inserted in the middle of other subwords. In some cases, words under additive corruption (keeping all subwords) can perform worse than those under partial corruption (keeping only some subwords), as seen in the letter reduplication experiment (Appendix C). The finding suggests that the retention of subwords is not the only factor impacting the performance of PLMs. To uncover other factors affecting the word meaning, we analyzed 10 worst and best instances for each corruption type based on similarity scores (Appendix B). All the poorly performing cases have incorrect predictions, further highlighting the damaging impact on semantic meaning. The results show that the number of additive tokens (i.e., the cardinality of A) is a distinct feature between good and bad instances. All the good cases have only 1 additive token, while the bad cases have at least 2 additive tokens (3.8 for partial corruption and 8.7 for additive corruption on average).
Thus, our hypothesis is that as the number of additive subwords increases, PLMs will have dif-
ficulty determining the correct meaning of words. We test the hypothesis by examining the performance of PLMs on both additive and intact corruption, where the missing and overlap sets remain constant. For additive corruption, we limit our experiments to only one unique additive subword and vary its frequency. We find 23 words with at least 3 noisy versions, each creating an additive set with the same element but different multiplicities. Take “amazing” as an example: one of its noisy instances (“amazinggggggg”) has the multiplicity of 3 according to its additive set A = {“gg”, “gg”, “gg”} while “gg” only appears twice in another instance (“amazinggggg”). We sort every collection of noisy words in either of two ways, depending on the similarity scores or the multiplicities of additive tokens. In 17 out of 23 collections, these two sorting criteria produce identical results. This discovery also holds true for intact corruption, where the subwords within an additive set are typically diverse. Figure 1 illustrates a strong negative correlation between the number of additive tokens and the average similarity of noisy words for all the three models under intact corruption, where the sizes of missing sets and overlap sets are fixed to 1 and 0.
Besides, as shown in Table 5, additive subwords placed within subwords cause more harm than those that act as suffixes.

heading: 4 Conclusion
text: We proposed the CoLeS framework which can evaluate how corrupt segmentation under noise affects
PLMs’ understanding. The experimental results show that three challenges can impair the PLMs’ understanding of noisy words: insertion of additive subwords (especially within existing subwords), loss of original subwords, and incapacity of computing the word meanings through the aggregation of smaller subword units.
Reproducibility. Data and source code for noisy data generation, corruption types identification and PLMs’ performance evaluation are released on Github 4.
Limitations
The omission of missing corruption from the evaluation process is justified due to its infrequent occurrence in real-world scenarios (refer to Appendix D for elaboration). Nevertheless, further investigation into rare instances of missing corruption may be warranted for research purposes. Our evaluation of language models was limited to auto-encoders based on the BERT architecture. Future studies are anticipated to expand the scope of PLMs under
4https://github.com/xinzhel/word_ corruption
consideration 5.

heading: A Fine-tuning Pretrained Language Models
text: All the PLMs use BERT-based architecture, i.e., the encoding part of the transformer (Vaswani et al., 2017). BERTBASE (110M parameters) and RoBERTaBASE (125M parameters) are pretrained on BookCorpus and Wikipedia as masked language models. Only the pretraining of ALBERTBASE (11M parameters) includes extra news and web data (Wolf et al., 2020). They are then fine-tuned for sentiment classification on the SST-2 dataset. All the models are publicly available on the Huggingface Hub website https: //huggingface.co/textattack. Some configurations are shown as below. The BERT and RoBERTa models are fine-tuned using a learning rate of 2e−5 with no scheduling employed. The batch size is set to 32, and the training process spans 3 epochs, maintaining a gradient norm of 1. ALBERT is fined-tuned with a learning rate of 3e−5, a batch size of 32, and a total of 5 training epochs.

heading: B Good and Bad Cases
text: Figure 2 shows the good and bad cases of partial and additive corruption under letter reduplication.

heading: C PLM Robustness to Segmentation Corruption under Different Types of Noise
text: Table 6 displays the robustness of PLMs to segmentation corruption under various forms of noise. The results are largely consistent with those seen in Table 4. However, we notice that for letter reduplication, PLMs may perform worse with additive corruption than with partial corruption. Additionally, the accuracy of intact corruption can be better than that of complete corruption, despite they consistently having the lowest similarity score.

heading: D Noisy words for Missing Corruption
text: As per the findings of Heath et al. (Heath, 2018), English word recognition by humans is predominantly influenced by consonants. Consequently, our investigation aims to identify abbreviations that disregard vowels and certain consonants when examining tweets. To be precise, an abbreviation is considered acceptable if its first letter and arbitrary consonants appear in a sequence that adheres to canonical words. For instance, the pattern of regular expression for term “sorry” can be “\bsr?r?y?” in such cases. However, we find that even humans have difficulties in recognizing all these abbreviations. While the inclusion of all consonants may enhance human recognition, we contend that assessing this form of corruption is
superfluous. This assertion stems from our demonstration in Table 7 that such aggressive search criteria are improbable to produce missing corruption.
Provided below is a comprehensive inventory of the canonical words and their corresponding noisy counterparts responsible for inducing missing corruption. It is worth noting that these noisy words are completely imperceptible to human cognition.
• 24 word pairs under RoBERTa: enthral-enth, upgradable-upgr, abysmal-abys, chintzy-chzy, emphaticemph, enslave-ensl, extraneous-extr, implacable-impl, implausible-impl, implicate-impl, imprudentimpr, inflame-infl, instable-inst, intransigent-intr, irksomeness-irks, obscenity-obsc, obtrusive-obtr, ungrateful-ungr, unscrupulous-unsc, unsteadily-unst, unsteadiness-unst, unsteady-unst, unsteadyunsty, untruthful-untr;
• 23 word pairs under BERT: enthral-enth, exemplar-expl, exemplar-empl, idyllic-idyl, stylish-styl, abysmal-abys, brutish-brsh, crummy-crmy, enslave-ensl, hysteric-hyst, impenitent-impt, incognizantinct, inconstant-inct, inexplainable-inpl, infamy-inmy, inflame-infl, irksomeness-irks, obscenity-obsc, obtrusive-obtr, unscrupulous-unsc, unspeakable-unsp, untrue-untr, untruthful-untr;
• 2 word pairs under ALBERT: enthral-enth, exemplar-exmp.

heading: E Performance of PLMs under Different Noise
text: We compare the effect of two noise models “Naturally and frequently occurring typos” and “Non-standard orthography” with both the lexicon dataset and two sentential datasets. For a fair comparison, we constrain
the length of letter-reduplication to 1. The accuracy of the noisy data and their standard deviation are reported in Table 8 and Table 9, respectively. It can be seen that the types of noise models in our experiments have no much distinction on model performance, except for the Swap.

heading: Future Work
text: Future studies are anticipated to expand the scope of PLMs under
4https://github. com/xinzhel/word_ corruption
consideration 5