Generation with Dynamic Vocabulary

Yanting Liu, Tao Ji, Changzhi Sun, Yuanbin Wu, Xiaoling Wang

TL;DR

This paper introduces a "dynamic vocabulary" framework that allows language models to incorporate arbitrary text spans (phrases) as atomic generation blocks on the fly. By bypassing the constraints of traditional static tokenizers, this plug-and-play approach simultaneously boosts text fluency, increases generation diversity, and reduces decoding latency by up to 20%.

What Problem Does This Paper Address?

Standard autoregressive language models rely on a fixed, pre-trained tokenizer (like BPE or WordPiece) that maps text to a static vocabulary. Once set, this vocabulary cannot easily adapt to new domains, handle multi-word technical terms efficiently, or generate exact verbatim references (like inline citations) as single units.

Previous attempts to expand vocabulary dynamically usually split phrases back into individual tokens at the input layer, causing a representation mismatch and slowing down generation. The authors tackle this by treating arbitrary text spans as atomic "bricks" in both the input and output layers without requiring a full retraining of the base language model.

Figure 1: Generation with dynamic vocabulary. The model’s vocabulary dynamically changes based on the input text, with phrases serving as basic blocks both for input and output.

Methods

The authors introduce a framework consisting of three core components:

  1. Dynamic Phrase Encoder: Instead of fine-tuning the entire language model for every new phrase set, the authors build a lightweight, parametric encoder using a causal Transformer decoder. It maps any arbitrary text span into the existing embedding space of the language model.
  2. Atomic Input/Output Integration: The expanded vocabulary ($V' = V \cup P$) is seamlessly integrated into both the input and output embedding matrices, allowing the model to read and write phrases in a single decoding step.
  3. Informative Negative Sampling: Training a model to switch between standard tokens and dynamic phrases introduces decoding ambiguity (e.g., distinguishing the phrase "Mark Ravenhill" from its prefix "Mark" or its continuation "Mark Ravenhill wrote"). The authors introduce a robust training regime using four negative sampling strategies: pre-batch, corpus-retrieval, self-retrieval, and generation-based continuation.
  4. Alignment Loss: A specialized loss function combines standard language modeling loss with a KL-divergence alignment loss to ensure the model maintains its base generation capabilities while learning to utilize the dynamic phrases.
Figure 2: The overall architecture of our proposed dynamic vocabulary. During training, there are four sources of negative phrases: pre-batch, corpus-retrieval, self-retrieval, and generation. Phrases are embedded by the dynamic phrase encoder with an additional linear layer. The hidden layer of the last token serves as the phrase embedding. In the model input layer, phrases are treated as a basic brick without splitting into tokens.

Datasets

The framework was evaluated across three distinct tasks using the following datasets:

  • WikiText-103: Used for evaluating open-ended language generation and basic language modeling performance.
  • LawMT: An English-German translation dataset in the legal domain, utilized here to test training-free domain adaptation.
  • ASQA: A long-form question-answering dataset used to evaluate the model's ability to generate text with precise, reliable inline citations.

Key Insights and Ideas

  • Phrases as First-Class Citizens: Unlike prior work that only used dynamic phrases at the output layer, this method treats phrases as atomic units at both the input and output stages, maximizing sequence compression and generation speed.
  • The Ambiguity Trap: Standard in-batch negative sampling fails because the model struggles to transition smoothly between tokens and phrases. Introducing informative negatives (like prefixes and successor tokens) is the secret sauce that makes the phrase encoder learn effectively.
  • Interleaving is Key: To prevent the model from becoming heavily biased toward either purely static tokens or purely dynamic phrases, phrases must be carefully interleaved with at least a five-token gap during training.

Key Results

  • Efficiency & Quality Boost: On WikiText-103, the dynamic vocabulary model improved the MAUVE score (a metric for human-likeness) by roughly 25% (from 20.47 to 25.69) and reduced generation latency by up to 20% compared to a standard Transformer.
  • Zero-Shot Domain Adaptation: When tested on the legal domain (LawMT) using a model trained only on WikiText-103, the plug-and-play dynamic vocabulary outperformed a standard Transformer that was explicitly fine-tuned on the legal data.
  • Accurate Citations: In the ASQA question-answering task, the model dramatically improved citation recall (from 0.62 to 9.76) and precision (from 1.54 to 29.30) by treating document-linked phrases as dynamic tokens.

Limitations and Future Work

  • Generation-Only Compression: The model does not modify the underlying tokenizer for the initial input prompt or question; it only compresses and accelerates the subsequently generated text.
  • Overhead: Running the dynamic phrase encoder introduces additional memory allocation and minor computational overhead during the initial setup phase.
  • External Dependencies: The system relies heavily on external tools, such as document retrievers and chunking algorithms, to extract candidate phrases before generation can begin.

Summary updated

BibTeX
@inproceedings{liu2024generation,
  author = {Yanting Liu and Tao Ji and Changzhi Sun and Yuanbin Wu and Xiaoling Wang},
  title = {{Generation with Dynamic Vocabulary}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1053},
}
Figure