NGPU-LM: GPU-Accelerated N-Gram Language Model for Context-Biasing in Greedy ASR Decoding

Vladimir Bataev, Andrei Andrusenko, L. A. Grigoryan, Aleksandr Laptev, Vitaly Lavrukhin, Boris Ginsburg

TL;DR

This paper introduces NGPU-LM, a novel GPU-accelerated n-gram language model designed for fast, context-biased decoding in Automatic Speech Recognition (ASR). By rethinking data structures for parallel GPU processing, NGPU-LM significantly closes the accuracy gap between slow beam search and fast greedy decoding, achieving substantial improvements for out-of-domain scenarios with minimal overhead.

What Problem Does This Paper Address?

Modern Automatic Speech Recognition (ASR) systems, particularly end-to-end models, often struggle with out-of-domain (OOD) data, leading to degraded accuracy. While context-biasing techniques can mitigate this by incorporating external information, traditional methods like shallow fusion with n-gram language models (LMs) typically rely on beam search decoding. Beam search, while effective, is computationally expensive and significantly slows down inference, making it impractical for many real-world applications. Existing GPU-accelerated LMs are often neural and require extensive training data, while CPU-based n-gram LMs like KenLM, though efficient in terms of data requirements, don't scale well with parallel processing. This creates a trade-off between accuracy (achieved with beam search and LMs) and speed (achieved with greedy decoding without LMs).

Methods

The core innovation is NGPU-LM, a GPU-accelerated n-gram language model. The authors re-architect the n-gram data structure to enable fast, batched queries suitable for GPU processing. Key aspects include:

  • Universal Trie-based Data Structure: This structure is optimized for parallel computing, allowing for efficient retrieval of probabilities for a large number of tokens simultaneously.
  • Custom Kernel in Triton: The implementation leverages a custom kernel written in Triton, a Python-based language for writing efficient GPU code. This kernel is designed to maintain the clarity of the algorithm while significantly improving speed, overcoming the limitations of CPU-bound loop conditions in standard PyTorch implementations.
  • Shallow Fusion in Greedy Decoding: NGPU-LM is integrated into greedy decoding pipelines for various ASR architectures (CTC, Transducers, AED). This allows context-biasing to be applied during the fast greedy decoding process, rather than requiring the slower beam search.
  • Architecture-Specific Adaptations:
    • Transducers: A two-stage token selection algorithm is introduced to handle the "blank" symbol, preventing it from negatively impacting LM scores.
  • CTC: Similar to transducers, but with an additional distinction for "blank," "repeated token," and "other tokens."
    • Attention Encoder-Decoder (AED): Pre-computation of final weights is performed to accelerate decoding.

Datasets

  • Training:
    • Large corpus: ~24k hours of English speech (various open sources).
  • Low-resource scenario: 960-hour Librispeech dataset.
  • Evaluation (Out-of-Domain):
    • SLURP (command-focused).
  • SPGISpeech (finance-related).
  • WSJ eval92 (used with LibriSpeech training).
  • Language Model Training: Token-level 10-gram LMs were built using KenLM for SLURP and SPGI domains. For a specific internal keyword recognition dataset, a 10-gram LM was built on a list of 200 keywords.

Key Insights and Ideas

  • Greedy Decoding Can Be Accurate: The paper demonstrates that with the right LM integration, greedy decoding can achieve accuracy levels previously only attainable with beam search, effectively bridging the speed-accuracy gap.
  • GPU Parallelism is Key for N-grams: Traditional n-gram models are CPU-bound. By redesigning the data structures and leveraging GPU parallelism, NGPU-LM unlocks significant speedups and enables their use in fast decoding pipelines.
  • Architecture-Specific Fusion Matters: The authors found that a naive fusion of LM scores with transducer predictions could lead to issues (e.g., increased deletion rate). Tailoring the fusion strategy to the specific ASR architecture (like the two-stage selection for transducers) is crucial for optimal performance.
  • Minimal Overhead for Major Gains: The proposed NGPU-LM approach achieves substantial accuracy improvements with less than 7% computational overhead, making it highly practical for deployment.

Key Results

  • Accuracy Improvements: NGPU-LM integrated into greedy decoding achieved relative Word Error Rate (WER) reductions ranging from 5.9% to 10.6% across different ASR architectures and datasets, particularly for out-of-domain scenarios.
  • Closing the Gap: For the RNN-T model in a low-resource scenario, NGPU-LM recovered over 87% of the accuracy gap between greedy and beam search.
  • Speed: The approach maintains the speed advantage of greedy decoding, with minimal computational overhead (less than 7%).
  • Beam Search Comparison: Beam search without an LM often failed to provide significant accuracy improvements and, in some cases, led to performance degradation, highlighting the necessity of LM fusion.

Limitations and Future Work

  • Limitations: The paper notes that while the PyTorch implementation is available as a fallback, the Triton kernel is preferred for performance. The authors also mention that the implementation is open-sourced in the NeMo toolkit.
  • Future Work: The authors plan to explore deeper integration of NGPU-LM into various beam search algorithms to further enhance decoding efficiency and accuracy.

Summary updated

BibTeX
@misc{bataev2025ngpu,
  author = {Vladimir Bataev and Andrei Andrusenko and L. A. Grigoryan and Aleksandr Laptev and Vitaly Lavrukhin and Boris Ginsburg},
  title = {{NGPU-LM: GPU-Accelerated N-Gram Language Model for Context-Biasing in Greedy ASR Decoding}},
  year = {2025},
  eprint = {2505.22857},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.22857},
}
Figure