An Analysis of Incorporating an External Language Model into a Sequence-to-Sequence Model

Anjuli Kannan, Yonghui Wu, Patrick Nguyen, Tara N. Sainath, Zhifeng Chen, Rohit Prabhavalkar

Abstract

Attention-based sequence-to-sequence models for automatic speech recognition (ASR) jointly train an acoustic model, language model, and alignment mechanism. Consequently, the internal language model component is typically trained only on transcribed audio-text pairs, limiting its linguistic breadth. This research investigates "Shallow Fusion"—a method of log-linear interpolation with a separately trained, large-scale external language model at each step of the beam search. We evaluate this approach across various language models, decoding units, and tasks. On the Google Voice Search task, we demonstrate that shallow fusion with a wordpiece-based neural LM yields a 9.1% relative word error rate reduction (WERR) over a competitive baseline, effectively obviating the need for computationally expensive second-pass rescoring.

Introduction

Modern ASR has transitioned from modular systems—comprising separate acoustic, pronunciation, and language models—to integrated "Sequence-to-Sequence" (Seq2Seq) architectures like Listen, Attend, and Spell (LAS). While these end-to-end models are elegant, they face a data bottleneck: their internal language modeling is constrained by the relatively small amount of available transcribed audio. In contrast, traditional language models (LMs) can leverage billions of words from text-only web corpora. This paper explores how to effectively inject this "web-scale" linguistic knowledge into Seq2Seq models to improve transcription accuracy without sacrificing the benefits of end-to-end training.

Methodology: Shallow Fusion

The primary technique explored is Shallow Fusion, which integrates an external LM during the inference (decoding) process rather than during training.

Architecture of the Seq2Seq model with an external Language Model (LM) integrated via Shallow Fusion.

Log-Linear Interpolation

During beam search, the system calculates a score for each candidate sequence based on a weighted sum of the log-probabilities from both the Seq2Seq model and the external LM. This allows the external LM to guide the search toward more probable linguistic sequences.

Coverage Penalty

To address a common failure mode where Seq2Seq models terminate sequences prematurely, the authors implement a coverage penalty. This mathematical constraint ensures the model has sufficiently "attended" to the majority of the input audio frames before finalizing an output.

Decoding Units and LM Types

The study compares two types of decoding units: Graphemes (individual characters) and Wordpieces (sub-word units). Wordpieces allow for a more compact representation, reducing the number of steps the LM must predict and enabling it to capture broader context. Furthermore, the researchers compared traditional $n$-gram models against Recurrent Neural Network (RNN) LMs, which utilize a hidden state to maintain a memory of the entire preceding sentence.

Experimental Setup

The models were evaluated on two distinct benchmarks:

  • Wall Street Journal (WSJ): A standard, smaller dataset used for initial configuration and unit testing.
  • Google Voice Search: A large-scale, real-world dataset consisting of 15 million anonymized English utterances (~12,500 hours).

External LMs were trained on massive text corpora containing billions of sentences from web documents and search queries.

Results and Key Insights

Experiments across both datasets provided several key insights into the behavior of integrated language models.

RNNs vs. $n$-grams

RNN LMs consistently outperformed $n$-gram models. Despite the industry-standard status of $n$-grams for their speed, RNNs provided superior error reduction and were more memory-efficient. For example, a 1.1GB RNN LM outperformed a massive 80GB $n$-gram model.

The Wordpiece Advantage

Wordpieces proved to be the superior decoding unit. By reducing the sequence length (e.g., from 27 steps for graphemes to 5 steps for wordpieces in a sample phrase), the language model's task is significantly simplified, leading to better performance.

Performance comparison on Google Voice Search across different systems and LM sizes.

As shown in the results for Google Voice Search, shallow fusion with a wordpiece-level RNN LM achieved a 9.1% relative Word Error Rate Reduction (WERR). This high level of first-pass accuracy suggests that complex second-pass rescoring stages can be eliminated, reducing overall system latency and complexity.

Conclusion

This analysis confirms that Shallow Fusion is a highly effective method for enhancing Seq2Seq ASR models with external linguistic knowledge. The combination of RNN LMs and wordpiece units provides significant accuracy gains that scale to massive, real-world datasets. Future research will explore more sophisticated methods for interpolating diverse data sources within neural language models and optimizing these architectures for real-time streaming applications.

Summary updated

Abstract

Attention-based sequence-to-sequence models for automatic speech recognition jointly train an acoustic model, language model, and alignment mechanism. Thus, the language model component is only trained on transcribed audio-text pairs. This leads to the use of shallow fusion with an external language model at inference time. Shallow fusion refers to log-linear interpolation with a separately trained language model at each step of the beam search. In this work, we investigate the behavior of shallow fusion across a range of conditions: different types of language models, different decoding units, and different tasks. On Google Voice Search, we demonstrate that the use of shallow fusion with an neural LM with wordpieces yields a 9.1% relative word error rate reduction (WERR) over our competitive attention-based sequence-to-sequence model, obviating the need for second-pass rescoring.
BibTeX
@inproceedings{kannan2018analysis,
  author = {Anjuli Kannan and Yonghui Wu and Patrick Nguyen and Tara N. Sainath and Zhifeng Chen and Rohit Prabhavalkar},
  title = {{An Analysis of Incorporating an External Language Model into a Sequence-to-Sequence Model}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2018},
  url = {https://openreview.net/forum?id=jnzB1F4UNTd},
}
Figure