Abstract
Standard Skip-gram with Negative Sampling (SGNS) models are inherently multi-pass, requiring a full dataset scan to determine word frequencies before training begins. This paper introduces an incremental SGNS algorithm designed for streaming data. By utilizing the Misra-Gries algorithm for dynamic vocabulary management and a reservoir-based sampling technique for the unigram table, the proposed method allows for single-pass training and efficient model updates. We provide theoretical guarantees of convergence and demonstrate that the incremental approach achieves a 10x speedup over batch retraining while maintaining equivalent embedding quality on standard benchmarks.
Introduction
Word embedding models like SGNS have become fundamental in natural language processing. However, their reliance on global word counts for negative sampling creates a bottleneck in dynamic environments, such as news feeds or social media streams. Adding new data typically necessitates reprocessing the entire corpus to update the noise distribution and restart optimization. This paper addresses this limitation by proposing a truly incremental SGNS framework that processes data in a single pass.
Methodology
The core of the incremental SGNS model lies in overcoming the static nature of the vocabulary and the noise distribution.
Dynamic Vocabulary Management
Instead of a fixed vocabulary, the model employs the Misra-Gries algorithm to approximately track the top-$m$ most frequent words in the stream. This allows the vocabulary to evolve dynamically, incorporating new terms as they gain prominence without requiring a prior pass over the data.
Adaptive Unigram Table via Reservoir Sampling
In batch SGNS, a unigram table is constructed to sample negative examples proportional to their frequency. Rebuilding this table for every new word is computationally prohibitive ($O(|W|)$). The authors introduce a reservoir-based algorithm that updates the table in $O(1)$ time per word. This ensures that the negative sampling distribution remains accurate and up-to-date as word counts change throughout the stream.
Theoretical Convergence
A critical contribution of this work is the mathematical proof that the objective function of Incremental SGNS converges to the same optimal solution as Batch SGNS as the data size $n$ increases. Using Taylor expansions to account for the "smoothed" noise distribution (where frequencies are raised to the power of $\alpha$), the authors show that the difference between the batch and incremental objectives decreases at a rate of $O(\frac{\log n}{n})$.
Experimental Evaluation
The model was trained on the English Gigaword corpus and evaluated on five standard benchmarks, including similarity tasks (WordSim353, MEN, SimLex-999) and analogy tasks (Google and MSR analogy datasets). Convergence was empirically verified using 10,000 subsets of varying sizes from the Gigaword corpus.
Key Results
The incremental approach demonstrates performance parity with traditional batch methods while offering significant computational advantages.
Embedding Quality
On analogy benchmarks, Incremental SGNS performed virtually identically to Batch SGNS and the original word2vec implementation. This confirms that the single-pass approximation does not sacrifice the semantic integrity of the learned embeddings.
Computational Efficiency
The primary advantage of the incremental model is its speed. When updating an existing model with $10^6$ new words (added to a base of $10^7$), the incremental approach was 10 times faster than batch retraining and 7.3 times faster than the standard word2vec implementation. Furthermore, the Misra-Gries algorithm effectively managed memory by limiting vocabulary size without degrading performance.
Conclusion
Incremental SGNS provides a robust and efficient solution for training word embeddings on streaming data. By replacing global frequency calculations with dynamic, single-pass approximations, the model achieves massive speedups and theoretical convergence, making it highly suitable for real-time NLP applications. Future work may explore extending these incremental techniques to other embedding architectures like GloVe.
Summary updated