NN-grams: Unifying neural network and n-gram language models for Speech Recognition

Babak Damavandi, Shankar Kumar, Noam Shazeer, Antoine Bruguier

Introduction

In Automatic Speech Recognition (ASR), Language Models (LMs) are critical for disambiguating acoustically similar phrases. Traditionally, researchers have relied on two distinct paradigms: N-gram models, which are highly scalable and fast but lack generalization, and Neural Network LMs (NNLMs), which generalize well through word embeddings but suffer from high computational latency due to the "softmax bottleneck."

This paper introduces NN-grams, a hybrid architecture designed to combine the memorization capacity of n-grams with the semantic intelligence of neural networks. By integrating n-gram counts directly as input features and utilizing Noise Contrastive Estimation (NCE) for training, NN-grams achieve state-of-the-art performance with significantly fewer parameters than traditional models.

The NN-gram Architecture

The core innovation of NN-grams lies in its input structure. Unlike standard NNLMs that rely solely on word embeddings, NN-grams utilize a dual-input stream:

  1. Word Embeddings: Continuous vector representations that capture semantic relationships.
  2. N-gram Counts: Raw frequency statistics of word sequences from the training corpus.
The NN-gram architecture processes word embeddings and n-gram counts through separate ReLU layers before concatenation.

As shown in Figure 1, these inputs are processed through independent ReLU layers (ReLU A and ReLU B) before being concatenated and passed through a final hidden layer (ReLU C). This structure allows the model to learn a non-linear mapping that balances raw statistical evidence with broader contextual patterns.

Efficient Training with Noise Contrastive Estimation (NCE)

To avoid the computational cost of a full softmax layer over a large vocabulary, the authors employed Noise Contrastive Estimation (NCE). Instead of predicting the next word from the entire vocabulary, the model is trained to distinguish between "true" target words from the training data and "noise" samples.

Instead of asking the model to calculate a probability distribution across millions of words, NCE frames the task as a binary classification problem: "Is this word from the real training data, or is it random noise?" This approach significantly reduces training and inference latency.

Experimental Results

The model was evaluated on a massive dataset of 26 billion words of Italian text, focusing on two tasks: Voice-Search (VS) and Dictation (DTN).

Comparison of Word Error Rate (WER) between a baseline 6-gram model and the proposed NN-grams across Voice-Search and Dictation tasks.

As illustrated in Figure 5, NN-grams consistently outperformed the 6-gram baseline. On the Dictation task, the model reduced the Word Error Rate (WER) from 8.8% to 8.2%, representing a 7% relative improvement. Notably, the NN-gram model achieved these results with only 517 million parameters, compared to the 9.6 billion parameters required by the 6-gram model.

Key insights from the study include:

  • Counts as Features: Treating n-gram counts as first-class citizens allows the neural layers to focus on generalizing to unseen contexts rather than simple memorization.
  • Task Specificity: N-gram counts are the most important feature for short, "telegraphic" speech (Voice Search), while word embeddings provide the most gain for long-form dictation where grammar matters more.

Conclusion

NN-grams represent a significant step toward efficient, high-performance language modeling for production ASR. By treating n-gram counts as first-class features, the model "hard-codes" the strengths of traditional statistics into a neural framework. Future work will explore integrating these models into the first pass of recognition to further reduce latency.

Summary updated

BibTeX
@inproceedings{damavandi2016nn,
  author = {Babak Damavandi and Shankar Kumar and Noam Shazeer and Antoine Bruguier},
  title = {{NN-grams: Unifying neural network and n-gram language models for Speech Recognition}},
  booktitle = {Interspeech},
  year = {2016},
}
Figure