Incrementally Learning the Hierarchical Softmax Function for Neural Language Models

Hao Peng, Jianxin Li, Yangqiu Song, Yaopeng Liu

Abstract

This paper introduces a novel method for incrementally updating Neural Language Models (NNLMs) that utilize hierarchical softmax. By performing prefix matching between old and new Huffman trees and employing a specialized gradient-based update rule, the authors achieve up to a 30x speedup in training time compared to retraining from scratch. Critically, this efficiency gain is achieved while maintaining nearly identical model accuracy and semantic quality in downstream tasks.

Introduction

Neural Language Models (NLMs), such as word2vec, are typically trained on static corpora. However, real-world applications like news processing or social media analysis involve constantly evolving data. The standard approach—combining new data with old and retraining from scratch—is computationally expensive and inefficient for large-scale applications.

The challenge is particularly acute for models using Hierarchical Softmax (HS). HS employs a Huffman tree to organize the vocabulary, where frequent words have shorter paths to the root. When new data alters word frequencies, the tree structure often changes. Since internal nodes represent model parameters, structural shifts typically invalidate previously learned weights, making simple fine-tuning impossible.

Methodology

The authors propose a framework to "inherit" knowledge from the old tree and update it efficiently through three primary mechanisms:

1. Tree Reconstruction and Prefix Matching

When new data arrives, a new Huffman tree ($T'$) is built for the combined corpus. The algorithm compares paths from the root to each leaf (word) in the old tree ($T$) and the new tree ($T'$).

2. Node Inheritance

For any word, the segment of the path that remains identical between the old and new trees (the "common prefix") inherits its parameter vectors directly. New nodes or nodes that have shifted positions are initialized (often to zero). This process is visualized in Figure 1.

Figure 1: Comparison between the original (a) and updated (b) Huffman trees, illustrating node inheritance and path changes.

3. Stochastic Gradient Adjustment

To avoid full retraining, the authors utilize a dual-gradient approach:

  • Ascent: Standard stochastic gradient ascent is applied for new paths in the updated tree.
  • Descent: For nodes that were moved or removed, stochastic gradient descent is used to "un-learn" or subtract the influence of the old paths.

This allows the model to approximate the state it would have reached via full retraining without processing the entire combined corpus traditionally.

Experimental Setup

The models were initially trained on 2GB of English Wikipedia (approx. 474 million tokens). Update corpora ranged from 10KB to 1GB to test scaling. Evaluation included 13 standard word similarity datasets (e.g., WS-353, SimLex-999) and dependency parsing (DP) using the CoNLL-X shared task data.

Key Results

The incremental method provides massive speedups. For the Skip-gram model, incremental training was up to 30 times faster than global retraining, while the CBOW model saw up to a 10-fold improvement.

Figure 4: Training speedup of the incremental method compared to full retraining for Skip-gram and CBOW models across different incremental data sizes.

The Mean Square Error (MSE) between incrementally updated vectors and fully retrained vectors was extremely low (around $10^{-3}$), indicating high approximation fidelity. Furthermore, on word similarity and dependency parsing tasks, the incremental models performed as well as—and occasionally slightly better than—models retrained from scratch.

Conclusion

This research demonstrates that hierarchical softmax models can be updated incrementally with high efficiency and minimal loss in accuracy. By leveraging structural stability in the Huffman tree and a novel "un-learning" gradient trick, the proposed method offers a scalable solution for dynamic language modeling. Future work includes extending this logic to more complex architectures like RNNs or LSTMs.

Summary updated

BibTeX
@inproceedings{peng2017incrementally,
  author = {Hao Peng and Jianxin Li and Yangqiu Song and Yaopeng Liu},
  title = {{Incrementally Learning the Hierarchical Softmax Function for Neural Language Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2017},
  doi = {10.1609/aaai.v31i1.10994},
}
Figure