Training Multilingual Pre-trained Language Model with Byte-level Subwords

Junqiu Wei, Qun Liu, Yinpeng Guo, Xin JiangarXiv 2021

Abstract

Multilingual pre-trained language models (PLMs) often struggle with the "unknown word" ([UNK]) problem and inefficient vocabulary allocation when using character-level tokenization. This paper proposes Byte-Level Byte Pair Encoding (BBPE) for multilingual Natural Language Understanding (NLU). By operating on UTF-8 bytes, the model achieves a lossless vocabulary that eliminates [UNK] tokens and improves cross-lingual subword sharing. Evaluation on the XNLI benchmark shows that BBPE-based models outperform mBERT and standard BPE models, particularly in low-resource and character-rich languages like Thai and Arabic, while using a significantly smaller vocabulary.

Introduction: The Limitations of Character-Level Vocabularies

Most existing multilingual models, such as Google’s mBERT, rely on character-level vocabularies. This approach presents two significant challenges:

  1. The [UNK] Problem: With over 14 million characters in Unicode, a fixed-size vocabulary cannot cover every script, leading to "unknown" tokens that the model cannot process.
  2. Vocabulary Waste: These models often allocate slots to thousands of rare characters that appear infrequently, wasting parameters on tokens that are never effectively learned.
Subword frequency distribution comparing mBERT and BBPE, highlighting the efficiency of byte-level encoding.

The authors propose a "lossless" and compact vocabulary using Byte-Level BPE (BBPE) to encourage better subword sharing across languages and scripts.

Methodology: Byte-Level Byte Pair Encoding (BBPE)

The proposed BBPE pipeline adapts techniques from models like GPT-2 for multilingual contexts. The process involves:

  • UTF-8 Conversion: Raw text is converted into its UTF-8 byte representation. Since there are only 256 possible byte values, a vocabulary containing these base bytes can represent any string without [UNK] tokens.
  • BPE Clustering: The algorithm iteratively merges the most frequent byte pairs into subwords.
  • Boundary Distinction: To preserve semantic clarity, the model distinguishes between subwords at the start of a word and those in the middle or end (using a ## prefix).
  • CJK and Punctuation Handling: Chinese, Japanese, and Korean (CJK) characters and punctuation are treated as "maximum units" to prevent nonsensical merges across different scripts or whitespace.
Comparison of tokenization results between the proposed BBPE method and Google's mBERT approach.

The underlying architecture for these experiments is NEZHA, a BERT-style model utilizing functional relative positional encoding.

Experimental Results

The models were pre-trained on Wikipedia datasets across 11 to 14 languages and evaluated on the XNLI (Cross-lingual Natural Language Inference) benchmark.

Performance and Efficiency

NEZHA (BBPE) with a 100k vocabulary achieved an average XNLI score of 78.3%, significantly outperforming mBERT (75.3%) and a vanilla NEZHA model using standard BPE (77.6%). Notably, a BBPE model with only a 50k vocabulary still outperformed the 120k vocabulary mBERT, demonstrating superior parameter efficiency.

Low-Resource Language Gains

The benefits were most pronounced in character-rich or low-resource languages. In Thai (Th), for instance, the BBPE model reached 71.5% accuracy, compared to 67.1% for mBERT. This is attributed to the BBPE tokenizer producing fewer tokens per sentence in these languages, allowing the model to process more context within the same sequence length.

Conclusion and Future Work

Byte-level subwords provide a universal and efficient representation for multilingual PLMs, finding common patterns even across disparate scripts. While highly effective for NLU, future research is needed to ensure that generative models using BBPE do not produce invalid UTF-8 sequences. Scaling these benefits to hundreds of languages remains a key area for future exploration.

Summary updated

BibTeX
@misc{wei2021training,
  author = {Junqiu Wei and Qun Liu and Yinpeng Guo and Xin Jiang},
  title = {{Training Multilingual Pre-trained Language Model with Byte-level Subwords}},
  year = {2021},
  eprint = {2101.09469},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.09469},
}
Figure