Language Modeling with Gated Convolutional Networks

Yann N. Dauphin, Angela Fan, Michael Auli, David Grangier

TL;DR

This paper challenges the long-standing dominance of Recurrent Neural Networks (RNNs) in language modeling by introducing a stacked convolutional approach equipped with a novel Gated Linear Unit (GLU). By processing sequences hierarchically rather than sequentially, the model achieves state-of-the-art perplexity on major benchmarks while allowing massive parallelization, resulting in a 20x speedup in sequence processing latency.

The Bottleneck of Recurrent Neural Networks

For years, RNNs (and specifically LSTMs) have been the go-to architecture for language modeling. Their hidden state allows them to theoretically capture infinitely long context, which is crucial for predicting the next word in a sequence. However, this sequential dependency—where token $t$ cannot be processed until token $t-1$ is finished—creates a massive computational bottleneck. It prevents parallelization across the tokens of a sequence, making training and inference slow.

The authors tackle this inefficiency by asking a fundamental question: do we really need unbounded context, or can a highly parallelizable, finite-context convolutional network do the job just as well, provided it is deep enough?

Methods: Gated Convolutional Networks

The authors replace recurrent connections with stacked 1D convolutions. To prevent the model from "peeking" at future words during training, they use shifted zero-padding (often called causal convolutions).

Architecture of the Gated Convolutional Network for language modeling.

The standout contribution of the paper is the Gated Linear Unit (GLU). Instead of traditional LSTM-style gating (which uses a $\tanh$ activation multiplied by a sigmoid gate), a GLU computes a linear projection of the input and multiplies it by a sigmoid gate:

$$h_l(X) = (X * W + b) \otimes \sigma(X * V + c)$$

This creates a linear path for gradients to flow through the network. It effectively acts as a multiplicative skip connection that prevents the vanishing gradient problem in deep stacks of convolutional layers, while retaining non-linear modeling capabilities.

To further optimize the architecture, the authors utilize:

  • Bottleneck residual blocks to keep computational costs low by reducing and then increasing dimensionality.
  • Adaptive softmax to efficiently handle massive vocabularies by assigning higher capacity to frequent words and lower capacity to rare ones.
  • Weight normalization and gradient clipping to stabilize and drastically speed up training convergence.

Datasets

The models were trained and evaluated on two large-scale benchmarks:

  • Google Billion Word (GBW): A massive dataset of ~1 billion tokens and an 800K vocabulary. It consists of shuffled, independent sentences, meaning the maximum context is relatively short (averaging 20 words).
  • WikiText-103: A dataset of over 100 million tokens and a 200K vocabulary. Unlike GBW, it retains document structure (entire Wikipedia articles), making it ideal for testing long-range dependencies (averaging 4,000 words per sequence).

Key Insights and Ideas

  • Infinite context is overrated: The model proves that a finite context window (built hierarchically via stacked convolutions) is sufficient for language modeling. The authors found that performance gains severely diminish after a context size of about 40 words, even on document-level datasets like WikiText-103.
  • GLUs beat GTUs and ReLUs: The linear gradient path provided by GLUs leads to significantly faster convergence and lower perplexity compared to standard $\tanh$, ReLU, or LSTM-style $\tanh$ gates (GTUs).
Test perplexity over epochs comparing different activation functions, highlighting the faster convergence of GLUs.
  • Parallelization unlocks responsiveness: Because CNNs don't rely on the previous timestep's hidden state, computations for all words in a sequence can be performed simultaneously. This drastically reduces the latency (responsiveness) of processing a single sentence, making it highly attractive for real-time production systems.

Key Results

  • WikiText-103 (Long Context): The Gated CNN (GCNN) achieved a SOTA perplexity of 37.2, significantly outperforming a comparable LSTM baseline (48.7). This proved the model could handle long-range dependencies.
  • Google Billion Word (Short Context): A single-GPU GCNN reached 38.1 perplexity, outperforming a comparable LSTM (39.8). A larger 8-GPU GCNN model pushed this down to 31.9.
  • Computational Efficiency: While overall throughput (tokens processed per second across large batches) was similar to highly optimized LSTMs, the GCNN improved responsiveness (the time to process a single sequence sequentially) by a staggering 20 times.

Limitations and Future Work

  • Small Datasets: The authors note that the GCNN tends to overfit on smaller datasets like the Penn Treebank compared to LSTMs. The architecture is explicitly better suited for large-scale problems where data sparsity is less of an issue.
  • Hardware Optimization: At the time of publication, 1D convolutions in cuDNN were not fully optimized compared to the heavily optimized LSTM implementations. The authors suggest the GCNN's speed advantage could grow even larger with better low-level software support.
  • Future Directions: The authors suggest further improvements could be made by integrating mixtures of experts (MoE) or ensembling these convolutional models to push perplexity even lower.

Summary updated

BibTeX
@inproceedings{dauphin2017language,
  author = {Yann N. Dauphin and Angela Fan and Michael Auli and David Grangier},
  title = {{Language Modeling with Gated Convolutional Networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2017},
}
Figure