Vocabulary Customization for Efficient Domain-Specific LLM Deployment
Christian Herold, Michael Kozielski, Nicholas Santavas, Yannick Versley, Shahram Khadivi
TL;DR
This work tackles tokenization inefficiency when applying autoregressive LLMs to domain-specific text by introducing a deterministic vocabulary-extension algorithm that adds domain tokens without increasing the maximum token count per input. The approach augments the Llama-3.1 tokenizer with domain-focused merges, initializes new embeddings by averaging related vectors, and fine-tunes the extended model, achieving up to 20% shorter inputs and 20–30% throughput gains while preserving overall quality. Experiments on a multilingual, production-grade e-commerce task suite show the model widely adopts the new tokens (≈98% usage on longer inputs) and that the extension is orthogonal to other efficiency techniques like quantization. The method provides a practical, backward-compatible pathway to faster, domain-tuned LLM deployment with potential applicability to other domains and model families.
Abstract
When using an LLM to process text outside the training domain(s), an often overlooked factor is vocabulary mismatch, where the general-domain tokenizer fails to capture frequent domain-specific terms, leading to higher token fertility and thus a decrease in processing speed due to suboptimal sub-word splits. We address this limitation by augmenting the pretrained vocabulary with a set of domain-specific tokens. To this end, we design an algorithm that extends an existing tokenizer while guaranteeing it never decreases tokenization efficiency: every input sequence is segmented into at most the same number of tokens as before. Evaluated on real-world e-Commerce use-cases, the augmented tokenizer significantly shortens input sequences by up to 20% and reduces inference latency on downstream tasks while preserving predictive quality. We further analyze secondary effects, such as the impact on forward pass speed and the rate at which the model adopts the newly introduced tokens, to illustrate the broader benefits of vocabulary adaptation.
