TL;DR
This paper introduces Multi-Word Tokenizers (MWTs) that represent frequent multi-word expressions as single tokens, leading to shorter and more informative sequences for Large Language Models (LLMs). This approach significantly reduces computational costs and improves robustness to sequence length reduction, enabling faster inference with minimal performance degradation.
What Problem Does This Paper Address?
Large Language Models (LLMs) have revolutionized Natural Language Processing (NLP), but their immense size comes with a substantial computational cost. This cost hinders their widespread adoption in industrial applications. While traditional model compression techniques like distillation, pruning, and quantization focus on shrinking model architecture or reducing operations, this paper addresses the computational burden imposed by the input sequences themselves. As LLMs become more capable, there's a growing trend towards using longer, more detailed prompts to elicit better performance. This, in turn, exacerbates the computational cost. The paper highlights that existing tokenization methods, particularly for languages other than English, can result in unnecessarily long sequences, further increasing processing demands.
Methods
The core innovation is the Multi-Word Tokenizer (MWT). This approach extends standard tokenizers by incorporating frequent multi-word expressions (n-grams) as single tokens. The process involves:
- N-gram Selection: Identifying the top-K most frequent n-grams (specifically bigrams in this work) from a reference training corpus. These n-grams are then added to the tokenizer's vocabulary.
- N-gram Merging: During tokenization, these learned n-grams are merged from left to right, effectively treating them as single units.
- Fast Vocabulary Transfer (FVT): When new tokens (the multi-word expressions) are added to the tokenizer, their embeddings need to be integrated into the language model. To avoid costly retraining, the paper employs FVT, a technique that assigns embeddings to new tokens by combining existing token embeddings. This is followed by a brief Masked-Language Modeling (MLM) fine-tuning step to help the model adapt to these new embeddings.
This method is presented as complementary to existing compression techniques.
Datasets
The paper evaluates its approach on three text classification datasets:
- ADE (Adverse Drug Event): A sentence classification dataset for identifying adverse drug events.
- LEDGAR (Legal Document Classification): A document classification dataset of contracts from the US Securities and Exchange Commission, focusing on identifying contract provision topics. This dataset is part of the LexGLUE benchmark.
- PATENT (Patent Classification): A document classification dataset of US patent applications, categorizing them based on the Cooperative Patent Classification (CPC) code.
Key Insights and Ideas
- Tokenization is a Bottleneck: The paper strongly emphasizes that tokenization itself can be a significant contributor to LLM computational costs, especially with longer sequences.
- MWTs Offer Dual Benefits: MWTs not only compress sequences (leading to faster inference) but also make them more informative by encoding common phrases as single units. This can lead to improved performance, particularly when sequence length is constrained.
- Robustness to Truncation: MWTs demonstrate remarkable robustness to sequence length reduction. As sequences are truncated, the performance of models using MWTs degrades more gracefully than those using standard tokenizers.
- Synergy with Domain Adaptation: Combining MWTs with domain-adapted tokenizers (tokenizers specifically tuned for a particular domain) yields even greater compression and speedups, especially in specialized domains like medical and legal text.
- Compatibility with Distillation: MWTs work effectively alongside knowledge distillation, allowing for substantial speedups even with highly compressed models like DistilBERT.
Key Results
- Sequence Length Reduction: MWTs, even with just the top 1000 bigrams, achieved sequence length reductions of around 20%. When combined with domain-adapted tokenizers, reductions of up to 50% were observed on the ADE dataset.
- Inference Speedup: The MWT approach led to natural inference speedups ranging from approximately 1.1x to 1.4x compared to a generic tokenizer. With domain adaptation, speedups of up to 1.8x were achieved.
- Robustness to Truncation: In extreme truncation scenarios (e.g., 8x reduction), MWTs showed significantly less performance degradation than generic tokenizers, especially on ADE and LEDGAR. This robustness allows for substantial speedups (up to ~9.4x) by enabling early sequence truncation.
- Distillation Integration: For DistilBERT on LEDGAR, extreme truncation to 64 tokens with MWTs resulted in an ~18.1x speedup with only a 2.7% drop in performance.
Limitations and Future Work
- Limitations:
- The paper acknowledges that while MWTs work well for text classification, their application to generative tasks is not experimentally demonstrated, though no inherent limitations are foreseen.
- A specific challenge is identified for token classification tasks, where labeling fused multi-word tokens becomes ambiguous.
- Future Work:
- The authors suggest extending their analysis to other language models and tasks, particularly language generation, to explore the full potential of MWTs for sequence compression.
Summary updated