Table of Contents
Fetching ...

Achieving Tokenizer Flexibility in Language Models through Heuristic Adaptation and Supertoken Learning

Shaurya Sharthak, Vinayak Pahalwan, Adithya Kamath, Adarsh Shirawalmath

TL;DR

Tokenization in pretrained LLMs is tightly bound to the original vocabulary, hindering cross-domain and multilingual adaptation. The authors introduce TokenAdapt, a model-agnostic tokenizer transplantation framework, complemented by Supertokens for learned multi-word units, to reduce fragmentation and retraining costs. TokenAdapt initializes new token embeddings with a hybrid of local compositional signals and global semantic neighbors in an auxiliary embedding space, formalized as $e_{new} = (1 - w_{glob}) e_{local} + w_{glob} e_{glob}$. Empirical results show lower zero-shot perplexity ratios for TokenAdapt compared to baselines like ReTok and TransTokenizer across base models, with Supertokens delivering notable compression gains, and a counterintuitive finding that removing a similarity threshold in the global step can improve performance.

Abstract

Pretrained language models (LLMs) are often constrained by their fixed tokenization schemes, leading to inefficiencies and performance limitations, particularly for multilingual or specialized applications. This tokenizer lock-in presents significant challenges. standard methods to overcome this often require prohibitive computational resources. Although tokenizer replacement with heuristic initialization aims to reduce this burden, existing methods often require exhaustive residual fine-tuning and still may not fully preserve semantic nuances or adequately address the underlying compression inefficiencies. Our framework introduces two innovations: first, Tokenadapt, a model-agnostic tokenizer transplantation method, and second, novel pre-tokenization learning for multi-word Supertokens to enhance compression and reduce fragmentation. Tokenadapt initializes new unique token embeddings via a hybrid heuristic that combines two methods: a local estimate based on subword decomposition using the old tokenizer, and a global estimate utilizing the top-k semantically similar tokens from the original vocabulary. This methodology aims to preserve semantics while significantly minimizing retraining requirements. Empirical investigations validate both contributions: the transplantation heuristic successfully initializes unique tokens, markedly outperforming conventional baselines and sophisticated methods including Transtokenizer and ReTok, while our Supertokens achieve notable compression gains. Our zero-shot perplexity results demonstrate that the TokenAdapt hybrid initialization consistently yields lower perplexity ratios compared to both ReTok and TransTokenizer baselines across different base models and newly trained target tokenizers. TokenAdapt typically reduced the overall perplexity ratio significantly compared to ReTok, yielding at least a 2-fold improvement in these aggregate scores.

Achieving Tokenizer Flexibility in Language Models through Heuristic Adaptation and Supertoken Learning

TL;DR

Tokenization in pretrained LLMs is tightly bound to the original vocabulary, hindering cross-domain and multilingual adaptation. The authors introduce TokenAdapt, a model-agnostic tokenizer transplantation framework, complemented by Supertokens for learned multi-word units, to reduce fragmentation and retraining costs. TokenAdapt initializes new token embeddings with a hybrid of local compositional signals and global semantic neighbors in an auxiliary embedding space, formalized as . Empirical results show lower zero-shot perplexity ratios for TokenAdapt compared to baselines like ReTok and TransTokenizer across base models, with Supertokens delivering notable compression gains, and a counterintuitive finding that removing a similarity threshold in the global step can improve performance.

Abstract

Pretrained language models (LLMs) are often constrained by their fixed tokenization schemes, leading to inefficiencies and performance limitations, particularly for multilingual or specialized applications. This tokenizer lock-in presents significant challenges. standard methods to overcome this often require prohibitive computational resources. Although tokenizer replacement with heuristic initialization aims to reduce this burden, existing methods often require exhaustive residual fine-tuning and still may not fully preserve semantic nuances or adequately address the underlying compression inefficiencies. Our framework introduces two innovations: first, Tokenadapt, a model-agnostic tokenizer transplantation method, and second, novel pre-tokenization learning for multi-word Supertokens to enhance compression and reduce fragmentation. Tokenadapt initializes new unique token embeddings via a hybrid heuristic that combines two methods: a local estimate based on subword decomposition using the old tokenizer, and a global estimate utilizing the top-k semantically similar tokens from the original vocabulary. This methodology aims to preserve semantics while significantly minimizing retraining requirements. Empirical investigations validate both contributions: the transplantation heuristic successfully initializes unique tokens, markedly outperforming conventional baselines and sophisticated methods including Transtokenizer and ReTok, while our Supertokens achieve notable compression gains. Our zero-shot perplexity results demonstrate that the TokenAdapt hybrid initialization consistently yields lower perplexity ratios compared to both ReTok and TransTokenizer baselines across different base models and newly trained target tokenizers. TokenAdapt typically reduced the overall perplexity ratio significantly compared to ReTok, yielding at least a 2-fold improvement in these aggregate scores.
Paper Structure (19 sections, 1 equation, 4 figures, 3 tables, 2 algorithms)

This paper contains 19 sections, 1 equation, 4 figures, 3 tables, 2 algorithms.

Figures (4)

  • Figure 1: Core logic of the Local Heuristic.
  • Figure 2: Core logic of the Global Heuristic.
  • Figure 3: Core logic of the Local and Global Heuristics respectively. This diagram illustrates the two main pathways (Local and Global) for generating components of a new token's embedding, which are then combined via Hybrid Integration.
  • Figure 4: Comparison of word count distributions for unique token types utilized by the Supertoken (ST, Red) and Baseline (Base, Blue) tokenizers across different domain corpora (10k samples each). Subplots show results for (a) English, (b) Hindi, (c) Math, and (d) Code. The Y-axis represents the log count of unique token types observed containing the specified number of words (X-axis).