The Fixed-Size Ordinally-Forgetting Encoding Method for Neural Network Language Models

Shiliang Zhang, Hui Jiang, Mingbin Xu, Junfeng Hou, Li-Rong DaiACL 2015

Abstract

In this paper, we propose the new fixedsize ordinally-forgetting encoding (FOFE) method, which can almost uniquely encode any variable-length sequence of words into a fixed-size representation. FOFE can model the word order in a sequence using a simple ordinally-forgetting mechanism according to the positions of words. In this work, we have applied FOFE to feedforward neural network language models (FNN-LMs). Experimental results have shown that without using any recurrent feedbacks, FOFE based FNNLMs can significantly outperform not only the standard fixed-input FNN-LMs but also the popular recurrent neural network (RNN) LMs.

Introduction

In Natural Language Processing (NLP), researchers have traditionally faced a trade-off between two primary architectures. Feedforward Neural Networks (FNNs) are efficient and easy to train but typically only consider a fixed window of previous words, making them blind to long-term context. Conversely, Recurrent Neural Networks (RNNs) utilize internal loops to capture long-term dependencies but are notoriously difficult to train due to vanishing gradients and the computational complexity of Back-Propagation Through Time (BPTT).

The Fixed-Size Ordinally-Forgetting Encoding (FOFE) method addresses this fundamental challenge by providing a simple feedforward network with the "memory" of an RNN without the associated training complexity. By using a recursive forgetting mechanism to encode variable-length sequences into fixed-size vectors, FOFE-based models significantly outperform both standard FNNs and popular RNN/LSTM models on language modeling benchmarks.

Methodology: The FOFE Mechanism

Instead of feeding a sliding window of words into a network, FOFE encodes an entire sequence of words into a single, fixed-size vector. It operates using a simple recursive formula:

$$z_t = \alpha \cdot z_{t-1} + e_t$$

Where $e_t$ is the "one-hot" vector for the current word, $\alpha$ is a "forgetting factor" between 0 and 1, and $z_t$ is the resulting FOFE code. As the sequence progresses, older words are repeatedly multiplied by $\alpha$, causing their influence to decay exponentially. Because each word's position corresponds to a unique power of $\alpha$, the resulting vector represents both the identity and the order of the words in the sequence.

The authors also explore "2nd-order" versions of this architecture, where the network receives both the current FOFE code ($z_t$) and the previous one ($z_{t-1}$) to provide richer contextual information to the hidden layers.

Architecture of a 2nd-order FOFE-FNNLM, illustrating how current and previous FOFE codes are integrated.

Experimental Setup

The FOFE method was evaluated on two standard benchmarks:

  • Penn Treebank (PTB): A classic corpus of about 1 million words with a 10k vocabulary.
  • Large Text Compression Benchmark (LTCB): A much larger dataset based on Wikipedia (enwik9), containing 160 million words and an 80k vocabulary.

Key Insights and Ideas

  • The "Almost Unique" Property: FOFE can encode any variable-length sequence into a fixed-size vector with almost no collisions. If $\alpha \le 0.5$, the encoding is mathematically unique. For $0.5 < \alpha < 1.0$, collisions are practically non-existent in real-world language data.
  • Order without Recurrence: FOFE captures word order through the magnitude of values in the vector; more recent words maintain higher values than those appearing earlier in the sequence.
  • GPU Efficiency: Unlike RNNs, which require sequential processing, FOFE can be implemented as a series of matrix multiplications. This makes it highly parallelizable and significantly faster to train on modern hardware.
  • The Sweet Spot for $\alpha$: Experimental results showed that the best performance occurs when $\alpha$ is between 0.5 and 0.8. Too small, and the model forgets too quickly; too large, and the historical context becomes a muddled signal.

Key Results

FOFE-based FNNs consistently outperformed standard FNNs and often surpassed state-of-the-art recurrent models. On the PTB dataset, a 2nd-order FOFE-FNN achieved a test perplexity of 108, outperforming standard RNNLMs (123) and high-performing LSTMs (117).

Comparison of test perplexity on the Penn Treebank (PTB) dataset across various models.

On the larger LTCB dataset, FOFE models reached a perplexity of 107, consistently outperforming higher-order n-gram FNNs and slightly edging out popular RNN-based models. These results were achieved using standard backpropagation, avoiding the stability issues and slow speeds associated with BPTT in recurrent models.

Conclusion

FOFE offers a compelling "third way" in neural architecture, combining the structural simplicity of feedforward networks with the long-term context of recurrent ones. While highly effective for language modeling, future work may explore its application to broader NLP tasks like machine translation and question answering, as well as its scalability to extremely large vocabularies.

Summary updated

BibTeX
@inproceedings{zhang2015fixed,
  author = {Shiliang Zhang and Hui Jiang and Mingbin Xu and Junfeng Hou and Li-Rong Dai},
  title = {{The Fixed-Size Ordinally-Forgetting Encoding Method for Neural Network Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2015},
  url = {https://openreview.net/forum?id=SkEv3jldZH},
}
Figure