Spelling convention sensitivity in neural language models (2023)

Abstract: We examine whether large neural language models, trained on very large collections of varied English text, learn the potentially long-distance dependency of British versus American spelling conventions, i.e., whether spelling is consistently one or the other within model-generated strings. In contrast to long-distance dependencies in non-surface underlying structure (e.g., syntax), spelling consistency is easier to measure both in LMs and the text corpora used to train them, which can provide additional insight into certain observed model behaviors. Using a set of probe words unique to either British or American English, we first establish that training corpora exhibit substantial (though not total) consistency. A large T5 language model does appear to internalize this consistency, though only with respect to observed lexical items (not nonce words with British/American spelling patterns). We further experiment with correcting for biases in the training data by fine-tuning T5 on synthetic data that has been debiased, and find that finetuned T5 remains only somewhat sensitive to spelling consistency. Further experiments show GPT2 to be similarly limited.

## introduction the probabilities that neural language models (lms) assign to strings can be used to assess how effectively they capture linguistic dependencies found in their training data. much as in psycholinguistic experiments on human language speakers, we can present lms with strings both with and without agreement in key dependencies and measure the assigned probabilities to determine whether the model has learned these linguistic generalizations or not (see e.g., @xcite . for example, sentences both with and without subject/verb number agreement (but otherwise identical) can be used to assess whether the model accounts for that particular dependency, even over long distances. various long-distance dependencies have been investigated in this manner, from purely linguistic phenomena such as syntactic dependencies (e.g., @xcite to extralinguistic phenomena such as socio-cultural biases (e.g., @xcite . in this paper, we examine dependencies based on orthographic cues to language variety. many lms are trained on large corpora scraped from the web, and data from different language varieties are often combined. for example, lms trained on webscraped english (e.g., the webtext corpus of @xcite encounter british english, north american english, and multiple world englishes. likewise, spanish web corpora may include several distinct varieties of latin american spanish, as well as iberian spanish (e.g., @xcite . here we use differences between british and american english spelling conventions to ask whether lms trained on large and diverse collections of english learn to apply these conventions consistently within the same span of text. for example, if the british spelling of the word labour appears in a sentence prefix, will the lm assign higher probabilities to continuations that maintain british spelling conventions (e.g., organisation) over those that have american-spelled forms (organization)? to the extent that such models are used within response generation systems or for next word prediction in virtual keyboards, maintaining such consistency would be strongly desirable so users receive results appropriate for their locale. of course, as with any such dependencies, models can only learn generalizations that are present in the data, so we also look at the degree to which corpora used to train the large lms (llms) that we investigate (as well as a few others) demonstrate spelling convention consistency. assessing whether syntactic or semantic generalizations are learned by models trained on noisy, errorful and inconsistent data is complicated by the difficulty in quantifying the actual degree of consistency of the dependency in the data itself. in contrast to structural linguistic generalizations or other implicit information, the explicitness of spelling conventions permits straightforward corpus analysis in addition to model probing, providing another avenue for explaining model performance. the results of our data analysis are presented in §4. we find that relevant web-scraped english text used to train llms unsurprisingly does not provide perfect consistency -and further that it is heavily skewed towards american spelling conventions -but that it provides as much or more consistency than some curated corpora such as the british national corpus @xcite . we then present methods, in §5, to measure the degree to which two neural llms -t5 @xcite (both with and without additional finetuning) and gpt2 -exhibit spelling variation consistency. we find that t5 without finetuning demonstrates a general preference for consistency, but that this preference is weaker for british than american english and does not extend robustly to nonce words. finetuning t5 on a synthetically modified portion of the british national corpus reduces the preference for american english. we then modify our conditional probability calculations to allow demonstration of similar patterns of model behavior for gpt2, a very differently architectured and trained llm @xcite . lastly, in §6, we take a slightly deeper dive into the kinds of (and reasons for) spelling convention inconsistencies in some corpora analyzed in §4. overall, we demonstrate that, while t5 and gpt2 display some sensitivity to spelling convention differences, this cannot be relied on to produce consistent generated output. if reliable spelling consistency is an application requirement, additional post-processing may need to be applied to llm output. this paper makes several key contributions. first, we provide methods for straightforwardly assessing the ability of llms to capture certain wellattested long-distance dependencies in english, and demonstrate the strengths and shortcomings of two well-known models in doing so. this opens up the possibility of exploratory studies in languages where such conventions are less well documented. in contrast to the most heavily investigated types of long-distance dependencies (e.g., syntactic), the (previously unexplored) dependency of spelling convention consistency is directly observable in the surface string and hence is relatively easy to assess in both models and data. as a result, it can be seen as a useful task for assessing lm learning in general. we also document the degree to which web-scraped corpora exhibit spelling consistency, making clear that the models have plenty of room for improvement. however, american english is shown to be far more heavily represented in the training corpora than british english, to the point that performance for british english is demonstrably far worse than for american english, something that language generation or word prediction systems must address for equitable performance. ## data and models to assess the spelling convention consistency of data and models, we use a list of british and american english spelling differences that is part of the open-source american british english translator. 1 we used the 1706 word pairs in the data/american _ spellings.json file at that site. this list includes american and british spelling variants for words with common differences such as -or/-our (e.g., vapor/vapour), -ize/-ise (realize/realise), consonant doubling (modeling/modelling), -er/-re (liter/litre), along with some number of term-specific spelling differences (aluminum/aluminium). we use this list to create prompts for probing the language models and to establish the consistency of usage within corpora, i.e., whether strings found in this list consistently follow one convention or the other when they co-occur. for model probing, we examine t5 @xcite , a general purpose encoder-decoder model. we use the t5-large architecture variant on the t5x codebase, foot_1 which has approximately 770m parameters. for english, t5 is (pre-)trained using a span corruption objective on the colossal clean crawled corpus (c4), an english language collection derived from common crawl @xcite . 3 we also examine gpt2, for which we use the open-source huggingface implementation @xcite . unlike t5, gpt2 is a purely autoregressive language model rather than an encoderdecoder sequence-to-sequence model. it is trained to perform next-word prediction rather than fill in corrupted spans of text. gpt2 is built on openai's webtext corpus @xcite , of which there is an open-source variant available. 4 we examine c4 and openai's webtext corpus for spelling convention consistency, along with several other corpora: english wikipedia (downloaded 06-21-2020); the billion word benchmark @xcite , which is a collection of newswire text; and the british national corpus (bnc consortium, 2007), foot_4 which is a balanced corpus of both written and spoken material. foot_5 ## training corpora consistency to examine spelling consistency in training data, we made use of the list of spelling variants and the five corpora mentioned in section 3: c4, the openwebtext corpus (owt), english wikipedia (engwiki), the billion word benchmark (bwb), and the british national corpus (bnc). we convert all strings in each corpus to lowercase, and treat all characters outside of the a-z range as whitespace for tokenization. we look for exact matches of list items in the resulting whitespace-delimited tokens. let us be the us spelling variants foot_6 of the words in the list and uk the uk spelling variants. for each corpus , @xmath0. . . | | represent the th string in the corpus, consisting of | | words. we extract all pairs of words ( , ) from such @xmath1, ∈ us uk . each extracted pair ( , ) is placed into one of three classes: the pair is (1) us-matched if , ∈ us ; having established that the level of mismatch in the c4 corpus used to train t5 is at the lower end observed in the data we examined, foot_8 we now move on to examine whether the trained models pick up on these dependencies. ## language model consistency from the dictionary presented in section 3, we kept only the words that can be described by a small number of rules, e.g., the variation between -ize and -ise, etc, leaving us with 1266 options. for efficiency, we sample ≈16k prompt-target pairs (16028) from all possible 1266 2 combinations. to eliminate all sources of variation besides the pair of words being tested, we created several template sentences into which we can insert pairs of words. the full set of templates is presented in first and most obviously, we need to ensure that all tokens in a template are variety-neutral. this ensures that the probability of any of our test words being british or american will not be swayed by any regional bias in the template. while neutrality is difficult to enforce perfectly within a single frame, we hope that by using multiple different templates, we can mitigate unknown sources of bias via averaging. second, we need templates that will be syntactically and semantically acceptable, regardless of the inserted tokens. llms may assign low probability to tokens that result in grammatically unacceptable or semantically unlikely sentences, and we want to avoid introducing this source of variation. this is challenging, since the tokens we are testing include different parts of speech and come from very different semantic domains, hence there are few contexts where all tokens would be acceptable. fortunately, this problem has an analogue in linguistics: linguists interested in detailed phonetic description often elicit tokens in set contexts to eliminate extraneous sources of acoustic variation @xcite . the approach these linguists often take is to use a template that mentions the tokens in question rather than using them. we follow this approach, and use templates similar to (1), which contain a list of word mentions. my preferred words are ..., ..., and tree. we then substitute pairs of words from our dictionary into the spaces marked with ellipses, both with consistent and inconsistent spelling conventions. in other words, given the pair of dictionary entries realize/realise and center/centre, we use the template above to generate the four test sentences: we use t5 to score the probability of generating the second bolded word, as shown in example (2), given the first. in the above template, the two words are adjacent in the string. we also include a non-adjacent condition, which augments the templates by adding ten variety-neutral tokens between the bold-face words. for the above sample, the non-adjacent variant would be: since t5 is a seq2seq model trained on a spancorruption objective, we present a prompt that includes a priming word and a blank span token representing the second word: ## further analysis of corpora we now return to a slightly more detailed examination of two of the corpora presented in english wikipedia and the british national corpus, both of which had relatively high levels of mismatch compared to the other corpora. wikipedia is an interesting case, since the documents are collectively edited by potentially a large number of contributors, which may lead to higher expected mismatch than in other corpora. for example, one version of the article on air lock used both us-spelling of the word vapor and the uk-spelling (vapour). this is explained via three versions of the introductory sentence to the page, shown in the amount of mismatch in the british national corpus is perhaps more surprising, given the provenance of the materials and intent of the collection. however the diversity of sources, which include things such as journal articles and edited volumes, likely leads to similar issues to those found in wikipedia, along with simple human error and/or inconsistency. ## conclusion and future work we have presented results showing that t5 does tend towards consistency in spelling, but not to the degree that could be relied upon should such consistency be desired in generated text. we show that this general preference for consistency reflects the data that the model is trained on, which also is mostly consistent, but with a significant proportion of exceptions. the model's behavior is also shown to be affected by the relative frequency of language varieties in the training data. we took advantage of the explicit and surface-accessible nature of these dependencies to attribute some model performance to the training data, while also demonstrating that modeling improvements should be possible, since the training data itself is substantially more consistent than the models. these results suggest several possible avenues for future work. first, methods for addressing bias in training data should yield improvements for british spelling consistency in these models. we also intend to extend these results to languages other than english and investigate how spelling variation in other language situations is learned by llms. some of the methods we used here rely on the fact that english spelling variation is quite thoroughly catalogued. extending this work to less-documented cases of language variation will require us to either (1) collect data about spelling variation from language informants or data, or (2) develop methods that require less prior knowledge. in the interest of finding methods that are extensible to the greatest number of cases, we intend to pursue path (2), working on methods to mine information about language variation from large corpora and llms that have been trained on them.