Tokenization with Factorized Subword Encoding

David Samuel, Lilja Øvrelid

Abstract

Traditional subword tokenization methods like Byte-Pair Encoding (BPE) create massive, unstructured vocabularies that lead to significant parameter bloat and a lack of morphological awareness. This paper introduces FACTORIZER, a novel method that decomposes subwords into a compact triplet of indices using a Vector-Quantized Variational Auto-Encoder (VQ-VAE). By shifting from a flat vocabulary to a factorized representation, FACTORIZER reduces embedding layer parameters by over 97% while improving performance on morphological tasks across diverse languages and increasing robustness to textual noise.

1. Introduction

In current Large Language Model (LLM) architectures, text is typically converted into numerical representations using methods like BPE or WordPiece. While effective, these methods treat every subword in a vocabulary (often 30,000+ entries) as an independent entity. This approach suffers from three primary flaws:

  1. Parameter Bloat: In models like BERT-base, the embedding layer can consume over 20% of total parameters (approx. 23 million weights) simply to store subword mappings.
  2. Morphological Blindness: Standard tokenizers do not inherently recognize that orthographically similar words (e.g., "melon" and "melons") share semantic or functional roots.
  3. Fragility: Models struggle with "long-tail" rare subwords and are highly sensitive to typos or character-level noise.

2. The FACTORIZER Method

FACTORIZER addresses these issues by replacing the standard flat lookup table with a structured, factorized encoding scheme.

2.1 VQ-VAE Backbone

The core of FACTORIZER is a VQ-VAE trained on subword strings represented as UTF-8 bytes. The VQ-VAE learns to map each subword to a triplet of discrete indices, each drawn from a small codebook of 256. This allows for a theoretical vocabulary of over 16 million combinations ($256^3$) while only requiring the model to store $3 \times 256$ embedding vectors.

2.2 Integration and Tokenization

To convert full sentences into these triplets, the authors utilize a Directed Acyclic Word Graph (DAWG) and Dijkstra’s algorithm to find the "shortest path" (the most probable sequence of subwords). Within the Transformer architecture, these three indices are embedded separately, summed, and passed through a GeLU non-linearity, making FACTORIZER a seamless drop-in replacement for traditional embedding layers.

3. Experimental Setup

The researchers evaluated FACTORIZER across seven typologically diverse languages: Arabic, Chinese, Czech, English, Norwegian, Scottish Gaelic, and Turkish. Pretraining was conducted on the mC4 (Multilingual C4) corpora. Evaluation focused on Universal Dependencies (UD) treebanks, specifically targeting morpho-syntactic tasks such as Part-of-Speech (POS) tagging, dependency parsing, and lemmatization.

4. Key Results and Insights

4.1 Parameter Efficiency

By shrinking the embedding layer from 23 million parameters to just 0.6 million, FACTORIZER allows the "parameter budget" to be reallocated to self-attention layers—the components responsible for actual reasoning and context processing.

4.2 Morphological Awareness

Because the VQ-VAE is trained on character sequences, words that look alike end up sharing indices in their triplets. This design choice provides the model with inherent hints about morphological relationships. Consequently, FACTORIZER outperformed BPE on 6 out of 7 languages in lemmatization (measured by BLEX scores), showing particular strength in morphologically rich languages like Turkish and Czech.

4.3 Robustness to Noise and Scarcity

FACTORIZER demonstrated significantly higher robustness than BPE when subjected to random character noise (simulated typos). Furthermore, the model proved highly effective in data-scarce environments, maintaining performance even when trained on as little as 1/1024th of the original corpus. This makes it a superior choice for low-resource languages like Scottish Gaelic.

5. Limitations and Future Work

Despite its advantages, FACTORIZER introduces new trade-offs:

  • Storage: The vocabulary file on disk is larger (115MB vs. 1MB for BPE) due to the complex DAWG structure required for fast tokenization.
  • Semantics: On the GLUE benchmark, which focuses on high-level semantics rather than morphology, FACTORIZER performed comparably to BPE but did not show a clear advantage.
  • Inference Speed: The shortest-path search in tokenization is computationally heavier than the greedy approach used by BPE.

6. Conclusion

FACTORIZER represents a significant step toward more efficient and linguistically aware tokenization. By factorizing the subword space, it achieves massive parameter savings and improved robustness, particularly for morphologically complex and low-resource languages, without sacrificing performance on downstream tasks.

Summary updated

BibTeX
@inproceedings{samuel2023tokenization,
  author = {David Samuel and Lilja Øvrelid},
  title = {{Tokenization with Factorized Subword Encoding}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.890},
}
Figure