Attention-based Contextual Language Model Adaptation for Speech Recognition

Richard Diehl Martinez, Scott Novotney, Ivan Bulyko, Ariya Rastrow, Andreas Stolcke, Ankur Gandhe

Introduction

Traditional Automatic Speech Recognition (ASR) systems often operate in a "context-blind" manner, calculating the probability of the next word based solely on preceding linguistic tokens. However, human speech is inherently situated in a specific environment. For instance, a request for "Christmas recipes" is significantly more probable in December than in April. While static context integration has been explored, researchers at Amazon Alexa have introduced a dynamic attention mechanism that allows language models (LMs) to selectively weight non-linguistic metadata—such as time and location—at each step of an utterance.

By teaching models to "pay attention" to relevant context only when needed, this approach achieves up to a 9% improvement in predicting rare, "long-tail" phrases, significantly enhancing the accuracy of voice assistants in real-world scenarios.

Architecture and Methods

The proposed architecture builds upon Recurrent Neural Network Language Models (RNN-LMs), which remain a standard for low-latency streaming ASR. The core innovation is the introduction of an attention mechanism that dynamically modulates how context influences the model's hidden states and word predictions.

Adaptation Strategies

The researchers evaluated the attention mechanism across two primary adaptation strategies:

  1. Concatenation-based: Context vectors are appended directly to the word embeddings.
  2. Factorization-based: Context is used to dynamically shift the weights of the neural network layers.

Dynamic Contextual Attention

Unlike previous methods that apply a fixed context vector to an entire sentence, this model uses a "query" to look at a set of context embeddings (e.g., Month, Week, Day, Hour). The query can be either the current word embedding or the RNN's current hidden state. For every word processed, the attention mechanism calculates a score for each piece of metadata, allowing the model to focus on the "Month" when hearing seasonal terms or the "Hour" for time-sensitive commands like "alarm."

Dynamic attention weights for specific words across context types.

Experimental Setup and Datasets

The study utilized a massive, de-identified dataset comprising over 5,000 hours of transcribed English utterances from the Alexa platform. Each utterance was paired with local datetime metadata. To evaluate the model's robustness, the researchers partitioned the data into:

  • Head Data: The top 5% most frequent requests.
  • Tail Data: Unique or rare requests where contextual clues are most critical for disambiguation.

Analysis of Dynamic Context

A key insight from the study is that context does not matter equally for every word in a sequence. In an utterance like "play me best christmas songs," the "Month" context is statistically irrelevant for the word "play" but becomes the dominant signal for the word "christmas."

Visual analysis of the attention weights confirms that the model learns these intuitive relationships. For example, the probability of the word "snooze" was found to spike specifically between 5:00 AM and 6:00 AM, demonstrating that the model successfully leveraged the "Hour" metadata to refine its predictions.

Dynamic attention weights for specific words across context types.

Key Results

The attention-based models consistently outperformed both standard LMs and static contextual adaptation baselines across multiple metrics:

  • Perplexity Reduction: The dynamic attention method reduced perplexity by 7.0% on the full dataset and 9.0% on long-tail (Tail) data. The researchers found that using the current word as the attention query was both more effective and more computationally efficient than using the RNN hidden state.
  • Word Error Rate (WER): When integrated into a full ASR pipeline, the model achieved a 1.1% to 1.2% relative reduction in actual transcription errors (WERR).
  • Robustness: To verify that the model was truly utilizing the metadata signal, the researchers conducted a "shuffling" experiment where the model was provided with incorrect time data. The resulting significant drop in performance proved the model was not merely memorizing patterns but was actively using the contextual signal.

Limitations and Future Work

While highly effective, the current research focuses on RNN architectures due to their dominance in low-latency production environments. As the industry shifts toward Transformers, future work will involve integrating this attention mechanism into Transformer-based ASR. Additionally, while the study focused on datetime, the architecture is extensible to other metadata like geographic geo-hashes and dialogue state, though scaling to a high number of context types will require further optimizations to maintain real-time performance.

Summary updated

BibTeX
@inproceedings{martinez2021attention,
  author = {Richard Diehl Martinez and Scott Novotney and Ivan Bulyko and Ariya Rastrow and Andreas Stolcke and Ankur Gandhe},
  title = {{Attention-based Contextual Language Model Adaptation for Speech Recognition}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.findings-acl.175},
}
Figure