In the early days of neural machine translation and language modeling, researchers hit a wall known as the Softmax Bottleneck. To predict the next word in a sentence, a model must calculate a probability distribution over the entire vocabulary. If your vocabulary has 50,000 words, this is manageable. But as vocabularies grow to hundreds of thousands or millions of words, calculating that final "softmax" layer becomes the most computationally expensive part of the entire network.
The cost of the softmax function is proportional to the vocabulary size $V$. For every single training example, the model must compute a score for every word in the dictionary just to normalize the probability of the one "correct" word. Kyunghyun Cho, Sébastien Jean, and Yoshua Bengio identified this as the "Large Vocabulary Problem" in their foundational work, On Using Very Large Target Vocabulary for Neural Machine Translation.
The solution that has emerged across a decade of research is sampling-based training: instead of looking at every word in the dictionary, we only look at a tiny, representative subset.
The Intuition of Importance Sampling
Imagine you are teaching a student to identify a specific type of bird, say a "Peregrine Falcon," out of a book containing a million different species. To help them learn, you don't need to show them every single other bird in the book and say "it's not this one" for every page. Instead, you show them the falcon (the positive example) and a handful of other birds—some random, some that look similar (the negative examples).
In neural models, this is formalized as Importance Sampling. As Sébastien Jean and the MILA team demonstrated in Montreal Neural Machine Translation Systems for WMT'15, we can approximate the full softmax by selecting a small subset of the vocabulary for each training batch. This subset typically includes:
- All the target words that actually appear in the current batch.
- A set of "noise" words sampled from the rest of the vocabulary.
By calculating the loss only over this subset, the computational complexity becomes independent of the total vocabulary size. This allows models to scale to millions of words while keeping training times manageable.
Refining the Sample
Not all sampling methods are created equal. Researchers have developed several variations to make the approximation more accurate:
- BlackOut: Shihao Ji and colleagues introduced BlackOut, which uses a weighted sampling strategy to speed up Recurrent Neural Networks. By updating only a fraction of the output weights, they made it possible to train models with million-word vocabularies on modest hardware.
- Noise Contrastive Estimation (NCE): This approach re-frames the problem. Instead of trying to predict which word is correct out of $V$ possibilities, the model learns to distinguish the "real" target word from "noise" samples. Yingbo Gao and Hermann Ney showed in On Sampling-Based Training Criteria for Neural Language Modeling that while NCE and Importance Sampling seem different, they are mathematically related. As long as you apply a "correction" factor to the model's output to account for the sampling bias, most of these methods yield nearly identical performance.
Beyond Translation
While these techniques started in machine translation, they have become essential across the AI landscape wherever the "output space" is massive.
In Recommendation Systems, the "vocabulary" is the set of all possible items (books, movies, products). Daria Tikhonovich and Aleksandr V. Petrov utilized sampled softmax in eSASRec to handle the long-tail distribution of items, allowing their model to outperform complex industrial systems.
In Computer Vision, specifically remote sensing, Jiancheng Pan used dynamic vocabulary sampling in Locate Anything on Earth to detect objects across a massive range of categories that exceed the limits of standard text encoders.
Returning to Full Words
For years, the standard way to avoid the Large Vocabulary Problem was to use "subwords" (like BPE or WordPiece), breaking "unbelievable" into "un-believ-able." However, subwords can lose semantic nuance.
With modern sampling techniques, researchers are returning to full-word models. Zhangyin Feng and Duyu Tang developed WordBERT, which uses a vocabulary of one million full words. By employing dynamic negative sampling, WordBERT outperforms standard BERT on tasks involving rare words and complex reasoning, proving that with the right sampling strategy, we no longer need to compromise on vocabulary size for the sake of efficiency.