What is AI vocabulary extension?
Vocabulary extension is an adaptation method adding new tokens, such as Turkish subwords or domain terms, to a trained language model's tokeniser, creating embedding rows for them and further training the model with the new vocabulary.
Unlike continued pre-training, which keeps training on new data with the existing vocabulary, vocabulary extension first changes the tokeniser. New token embeddings start meaningless, so continued pre-training usually follows.
- Topic
- Natural language processing and Turkish
- Also known as
- Vocabulary expansion
How AI vocabulary extension works
- A new tokeniser is trained on target language or domain text and frequent tokens missing from the vocabulary are selected.
- These are added; the model's input embedding and output layers grow with new rows.
- New rows are initialised, for example by averaging the embeddings of the token's pieces under the old tokeniser.
- The model undergoes continued pre-training on target language data, then instruction tuning if needed.
In more detail
When large-vocabulary models still need extension
In current multilingual models with 128K to 256K token vocabularies, general Turkish is already encoded much more efficiently than in older 32K English-centric models. Consequently, vocabulary extension is most worthwhile for narrow vertical domains (medical, financial or proprietary internal codes) or when adapting compact older-vocab models.
Replay data against catastrophic forgetting
Adding new tokens shifts the data distribution and can cause catastrophic forgetting of reasoning, coding and instruction-following skills learned in the original language. Mixing some general or English replay data into the target-language corpus during continued pre-training and also training the embedding and output layers when LoRA is used reduce this risk.
Merge rules and regression tests on the source language
Simply appending strings to a BPE vocabulary without updating its merge table can leave new tokens unreachable; the tokeniser splits text using old merges before ever seeing the new whole token. Moreover, changing a BPE dictionary can inadvertently alter tokenisation boundaries for code or English words, so fertility and benchmark regressions should be measured on both target and source languages.
Commonly confused terms
| Term | How it differs |
|---|---|
| Instruction tuning | Instruction fine-tuning (SFT) teaches a model conversational formatting and task following using relatively small curated prompt and response pairs without changing the tokeniser; vocabulary extension alters the input and output token space and requires broad unsupervised corpus training before or alongside SFT. |
| Vocabulary pruning | Vocabulary pruning (or trimming) removes unused foreign or rare tokens from a large multilingual vocabulary to shrink an on-device model's memory footprint without adding new tokens, whereas vocabulary extension adds new tokens to improve encoding efficiency. |
Why AI vocabulary extension matters for on-premises AI
In an English-centric model Turkish text splits into many pieces, making inference costlier and context shorter; vocabulary extension encodes the same text in fewer tokens. One study added 20,000 Chinese tokens to a model with secondary pre-training, improving Chinese encoding efficiency and understanding. Another, on building language-specific models, found simple extension plus continued pre-training easily improves efficiency in most models and the simplest embedding initialisation works well. Untrained new tokens can hurt quality.
Adapting an open-weight model to Turkish banking correspondence, a bank adds frequent Turkish subwords and product terms to the tokeniser, runs continued pre-training on its own archive and measures fewer tokens per word.
Common questions
Is vocabulary extension always needed?
No. If the model already encodes the target language efficiently it is unnecessary; consider it when tokens per word are high.
How are new tokens learned?
Their embeddings are initialised and the model is further trained on target language data. Without training, new tokens stay meaningless.
Related terms
Sources
- Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca, 2023
- Exploring Design Choices for Building Language-Specific LLMs, 2024
In the glossary: Glossary, R to Z