Pre-training Data Quality and Quantity for a Low-Resource Language: New Corpus and BERT Models for M altese (2022)

Abstract: Multilingual language models such as mBERT have seen impressive cross-lingual transfer to a variety of languages, but many languages remain excluded from these models. In this paper, we analyse the effect of pre-training with monolingual data for a low-resource language that is not included in mBERT – Maltese – with a range of pre-training set ups. We conduct evaluations with the newly pre-trained models on three morphosyntactic tasks – dependency parsing, part-of-speech tagging, and named-entity recognition – and one semantic classification task – sentiment analysis. We also present a newly created corpus for Maltese, and determine the effect that the pre-training data size and domain have on the downstream performance. Our results show that using a mixture of pre-training domains is often superior to using Wikipedia text only. We also find that a fraction of this corpus is enough to make significant leaps in performance over Wikipedia-trained models. We pre-train and compare two models on the new corpus: a monolingual BERT model trained from scratch (BERTu), and a further pretrained multilingual BERT (mBERTu). The models achieve state-of-the-art performance on these tasks, despite the new corpus being considerably smaller than typically used corpora for high-resourced languages. On average, BERTu outperforms or performs competitively with mBERTu, and the largest gains are observed for higher-level tasks.

## introduction language models have become a core component in many natural language processing (nlp) tasks. these models are typically pre-trained on unlabelled texts, and then further fine-tuned using labelled data relevant to the target task. transformerbased @xcite contextual models such as bert @xcite have gained success since the fine-tuning step is relatively inexpensive, while attaining state-of-the-art results in various syntactic and semantic tasks. while the bulk of work with the bert family of models focuses on english, there have been some monolingual models developed for other languages as well @xcite @xcite @xcite ; inter alia). these monolingual models have been trained on large volumes of data, typically amounting to billions of tokens. in contrast, it is challenging to find publicly available corpora of this size for low-resource languages. the evaluation benchmarks for downstream tasks on these languages are also limited, and tend to be dominated by low-level structural tagging tasks. to counteract the lack of large volumes of monolingual corpora for low-resource languages, a number of multilingual models have been released, such as mbert @xcite and xlm-r @xcite . these multilingual models were pre-trained on more than one language at a time by combining corpora from different languages, usually sourced from wikipedia. several works have demonstrated the efficacy of these multilingual models, especially for languages without a language-specific model @xcite . benchmark results have improved for many languages by leveraging cross-linguistic features learnt by these multilingual models @xcite . however, the gains with multilingual models may vary depending on the language being considered. the "curse of multilinguality" limits the language-specific features that these models can learn, since the limited model capacity has to be shared between multiple languages @xcite . models such as mbert use wordpiece tokenisation @xcite , which splits words into various sub-tokens, thereby reducing the number of unknown tokens. however, the vocabulary representations for multilingual models tend to be sub-optimal for specific languages, because words tend to be split into a higher number of sub-tokens @xcite . moreover, these models may still be biased in favour of overrepresenting sub-tokens common to a certain subset of languages over others. due to the data imbalance across languages, lower-resourced languages tend to be disadvantaged, as there is relatively less pre-training data available compared to the other languages considered in the multilingual model @xcite . apart from the tension between languages in a multilingual model, other factors are at play as well. most prominently, many languages are never seen by these multilingual models @xcite , since these are typically trained on the largestavailable corpora (e.g. mbert was pre-trained on the 104 languages with the greatest wikipedia presence). such criteria exclude many of the world's languages, including maltese, the focus of this paper. this issue is exacerbated even further when the language uses a script which is either different to its closely related languages @xcite , or which is never seen during pre-training, thereby encoding most of the input with out-of-vocabulary tokens @xcite . in fact, @xcite show that the language transfer capability of a multilingual model to an unseen language is dependent on the degree to which the target language is related to languages already included in the multilingual model. in this work we focus on the maltese language, an official eu language spoken primarily in malta and in some small communities around the world @xcite . it is the only semitic language written exclusively with a latin script, containing a few additional characters with diacritic marks (ċ, ġ, h, ż). the language also has strong influences from romance languages such as italian, as well as english. the semitic influence is largely exhibited in the grammatical structure through complex morphological characteristics, whilst the non-semitic aspect is predominantly observed in its vocabulary, with extensive lexical borrowing from italian and english. in the context of nlp, maltese is a low-resource language @xcite and is not part of the languages covered by either mbert or xlm-r. @xcite find that mbert underperforms non-contextual baselines on maltese, but benefits when pre-trained further on raw maltese data. similarly, @xcite further pre-train mbert but impute the 99 unused tokens present in the model with language specific tokens, yielding better results. this confirms previous findings by @xcite , who also extend mbert's vocabulary to accommodate unseen languages, but do so by extending the vocabulary and model dimensionality, hence increasing its footprint. motivated by the limitations of existing multilingual models and the deficiency of publicly available corpora for maltese, we set out to pre-train a new monolingual language model for maltese and compare it to the alternative strategy of further pre-training an existing multilingual model. we study, in particular, the impact that the pre-training data size and domain has on the performance in downstream tasks. the main contributions of this work are as follows: we make this new corpus, the newly pre-trained language models, and the code publicly available foot_0 . ## corpus in this work, we build a new unlabelled text corpus, which we call the korpus malti v4.0 (km). this builds on and extends an existing corpus, korpus malti v3.0 foot_1 , which is approximately half the size. rather than scraping the web randomly for maltese text, we collect text data from specific sources, including both online and offline. although this does incur additional effort in data collection, and results in a smaller dataset compared to large-scale web-scraping initiatives, it has the benefit of resulting in a less noisy dataset, while offering greater control over sources. for comparison, the maltese portion of the oscar data @xcite , which is sourced entirely from the web, contains texts which, to a native speaker, suggest that they are automatically generated through the use of a low-quality machine translation system, a common pitfall of web-scraping for low-resource languages @xcite . we also expect to find a small proportion of code-switched texts, as this is a pre-dominant phenomenon for maltese in domains such as social media or transcribed speech. in addition, the data is separated into different domains, and the source for each document is available as part of the metadata. this allows data users to select data subsets which are more appropriate for their particular use-case, such as domain-adaptive pre-training @xcite ; inter alia), whilst enabling tracing back to the original source, or omission in case unforeseen ethical or privacy issues come to light. in short, the goal was to build a good quality training dataset, while avoiding at least some of the pitfalls identified with opportunistic, web-scale data initiatives @xcite . data is collected from a variety of sources, including online news sources, legal texts, transcripts of speeches and debates, blogs, wikipedia, etc. before texts are included in the corpus, we filter non-maltese sentences using language identification using lid @xcite , and perform de-duplication using onion @xcite . the resulting data, split into 19 different domains, is summarised by to the best of our knowledge, there is no corpus of this size available for maltese. we also note that this data is a significant increase over wikipedia data, which is what is usually available and used in low-resource scenarios. the wikipedia data makes up less than 1% of the entire corpus in terms of both tokens and sentences. despite this substantial increase in data, we emphasise that a corpus of under 500m tokens is still substantially smaller than is typically used for higher-resourced languages. for example, @xcite pre-train bert using a combined corpus of 3.3b words for english (approximately 16gb). larger models have since exceeded these pre-training sizes by a wide margin -for example, roberta is pre-trained on 161gb of text @xcite . monolingual models for languages other than english, typically use smaller corpora than english models, but their size is still significantly larger than ours -for example arabert was pre-trained on a corpus of 24gb @xcite and bertje was pre-trained on a corpus of 12gb @xcite . ## language models using this new corpus, two new language models are pre-trained for maltese: a monolingual model (bertu) and a multilingual model (mbertu). in both cases, pre-training is performed using the masked language modelling objective (mlm) only, since the next sentence prediction (nsp) objective was found to be detrimental to downstream performance @xcite . other than that, pre-training largely follows the pre-training setup of bert @xcite . this allows for a better comparison with already available models. the pre-training data from all domains is combined, shuffled, and split into 85% and 15% for training and validation sets respectively. bertu we pre-train a monolingual bert model from scratch on the new unlabelled data, using the bert base architecture with 12 transformer layers, a hidden size of 768, and 12 attention heads. the vocabulary is initialised with 52k tokens. pretraining is done across 1m steps, with a sequence length of 128 for the first 90% of the steps and a sequence length of 512 for the remaining 10% steps. a batch size of 512 is used, which amounts to approximately 30 epochs in total, and a warmup of 1% of the total number of steps. we use mixedprecision training to ease memory requirements. training was performed on 8 a100 gpus for the first 90% steps and 16 a100 gpus for the remaining 10% steps, taking approximately 53 hours. ## evaluation an evaluation for the language models described in section 3 is presented here. mbert without any additional pre-training is used as one of the baselines. in addition, we pre-train two language models on the maltese wikipedia data as additional baselines. this allows us to analyse the limitations that could be faced when following the common practice of using wikipedia data, for the specific case of low-resource languages with a comparatively small wikipedia footprint. following the same setup of the main models, a monolingual model (bertu wiki) and a multilingual model (mbertu wiki) are pre-trained. the same hyper-parameters described in section 3 are used, but the batch size and number of steps are decreased to prevent overfitting due to the smaller data size. to this end, the batch size is set to 64 and the total number of steps set to 30 500 and 7 600 steps for the monolingual and multilingual models, respectively. this was deemed appropriate since it would amount to the same number of epochs as the models pre-trained on the entire corpus. ## analysis in this section we build on the results presented in section 4.2, and analyse the effect that the pretraining data has on performance on the downstream tasks. ## conclusion in this work we analyse the impact of pre-training data on downstream task performance in a lowresource setting, specifically focusing on maltese. we present a newly developed corpus of around 500m tokens, which allows us to study how the pre-training data size and domain translates in downstream performance differences. using bert as our architecture, we compare a monolingual language model, pre-trained from scratch, to a further pre-trained multilingual model, in a number of pretraining configurations. we conduct an evaluation on a both syntactic and semantic tasks. in line with previous findings on domain pretraining @xcite ; inter alia), we find that matching the pre-training domain to the target task domain, results in improvements. moreover, we demonstrate that pre-training language models with varied domains is often beneficial over pre-training solely with wikipedia. these adjustments were in certain cases enough to surpass mbert, underlining the importance of having pretraining data more suited to the target task, even at a small scale. whilst we show that further pre-training data does improve downstream performance, the gains are linear with exponential increases in data. in fact, substantial improvements are observed with a small proportion of the pre-training data, over language models trained with wikipedia-sized data. this echoes the findings made by @xcite with a small pre-training subset, although our reduced data setup is considerably smaller. using the whole corpus, we also pre-train two new language models: bertu, a monolingual bert model, trained from scratch, and mbertu, which is the result of further pre-training mbert. these models demonstrate state-of-the-art results in dependency parsing, part-of-speech tagging, named-entity recognition, and sentiment analysis. moreover, we show that in general, bertu performs better than mbertu, as well as other baselines. through this, we also demonstrate that language-specific pre-training is most beneficial for higher-level tasks. despite these considerable improvements, the pre-training setups used in this work are as close as possible to the baselines, to allow for a more controlled comparison. hence, in the future, we plan to experiment with more language-specific tuning to push the state-of-the-art even further. even though this new corpus will undoubtedly improve the state of resources available for maltese, the language is by no means a highly-resourced one. the corpus we use is significantly smaller than typically used corpora for higher-resourced languages. we also remark that the quantity of labelled data is still scarce, and at times non-existent for certain tasks. although we include a semantically-oriented task in our evaluation, future work should investigate the efficacy of these models in more complex natural language understanding scenarios. we make this corpus and the models publicly available to foster further work and improvements for various nlp applications for maltese. we also hope that this work inspires work in other lowresource languages, since we show that the amount of data needed to achieve considerable improvements, does not need to be overly ambitious. shijie wu and mark dredze. 2020. are all languages created equal in multilingual bert? in proceedings of the 5th workshop on representation learning for nlp, pages 120-130, online. association for computational linguistics.