MultiTok: Variable-Length Tokenization for Efficient LLMs Adapted from LZW Compression

Noel Elias, Homa Esfahanizadeh, Kaan Kale, Sriram Vishwanath, Muriel MédardarXiv 2024 · DOI

Abstract

Training Large Language Models (LLMs) is computationally expensive, largely due to the massive volume of tokens in training datasets. We present MultiTok, a novel tokenization method inspired by Lempel-Ziv-Welch (LZW) compression. MultiTok identifies and encodes repetitive multi-word phrases as single, variable-length tokens. Our evaluation shows that MultiTok can reduce data volume by up to 33% and accelerate training by up to 2.5x while maintaining accuracy competitive with standard tokenizers like BERT and GPT-2.

Introduction

The primary bottleneck in training LLMs is the sheer quantity of data the model must process. Current tokenization schemes, such as Byte Pair Encoding (BPE), break text into sub-word units but often fail to fully exploit higher-level repetitive patterns. By representing common multi-word sequences as single tokens, we can significantly shorten input sequences, thereby reducing the total computational work required per training epoch.

Methods: The MultiTok Framework

MultiTok leverages the principles of LZW compression to build a dynamic dictionary of variable-length tokens.

  1. Dictionary Construction: The algorithm scans the training corpus using a look-ahead window to identify the longest known sequences. New sequences are iteratively added to the dictionary.
  2. Frequency-Based Pruning: To ensure the model learns robust embeddings, MultiTok employs a pruning step. Tokens that appear too infrequently are decomposed into their constituent parts. This prevents the "rare token" problem, where the model fails to learn meaningful representations for unique phrases.
  3. Cascaded Integration: MultiTok can function as a standalone tokenizer or as a secondary compression layer applied on top of existing outputs from BERT or GPT-2 tokenizers.
Overview of the MultiTok dictionary building and frequency analysis process.

Experimental Evaluation

We evaluated MultiTok across three text classification benchmarks: IMDB, sst2, and AG-News. To isolate the impact of tokenization, models were trained using random vector embeddings.

Key Results

  • Training Speedup: MultiTok-based models converged significantly faster. As shown in our analysis, configurations like MultiTok-100%, 2-2, <2 reduced the average training time from 20 epochs to just 8 epochs—a 2.5x speedup.
  • Data Compression: MultiTok achieved a compression ratio as low as 0.57, representing a 43% reduction in the total number of tokens compared to uncompressed text.
  • Accuracy Benchmarks: On the IMDB dataset, MultiTok achieved an accuracy of 0.743, outperforming the BERT baseline (0.738) despite the reduced sequence length.
Comparison of compression ratios and average training time (epochs) across different tokenization strategies.

Discussion and Future Work

MultiTok demonstrates that sequence length is a critical driver of training efficiency. By bridging data compression and deep learning, we show that more efficient data representation leads to more efficient learning.

Current limitations include a focus on discriminative tasks (classification) rather than generative ones. Future research will explore MultiTok's performance in generative LLM contexts and its interaction with pre-trained embeddings. Additionally, the LZW-inspired approach holds potential for other data modalities, such as video, where temporal redundancy is high.

Summary updated

BibTeX
@misc{elias2024multitok,
  author = {Noel Elias and Homa Esfahanizadeh and Kaan Kale and Sriram Vishwanath and Muriel Médard},
  title = {{MultiTok: Variable-Length Tokenization for Efficient LLMs Adapted from LZW Compression}},
  year = {2024},
  eprint = {2410.21548},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.21548},
}
Figure