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

Vladimir Bataev, Andrei Andrusenko, Lilit Grigoryan, Aleksandr Laptev, Vitaly Lavrukhin, Boris Ginsburg · DOI

Abstract

Modern Automatic Speech Recognition (ASR) systems often struggle with domain-specific vocabulary during greedy decoding. While "shallow fusion" with an external language model (LM) can mitigate this, it typically requires computationally expensive beam search. NGPU-LM addresses this bottleneck by introducing a GPU-accelerated n-gram LM designed for greedy decoding. By rethinking trie-based data structures as parallelizable tensors, NGPU-LM achieves up to a 10.6% relative improvement in Word Error Rate (WER) with less than 7% computational overhead, effectively bridging the gap between greedy and beam search performance.

The Challenge of Domain Bias in ASR

ASR models frequently encounter "domain bias," where performance degrades on specialized vocabulary (e.g., medical terminology or proper names) not well-represented in the training data. Shallow fusion—combining an external LM with the ASR model during inference—is a standard solution. However, traditional LM implementations like KenLM are CPU-optimized, forcing a choice between the speed of greedy decoding and the accuracy of beam search combined with an external LM. NGPU-LM aims to provide both speed and accuracy by moving the LM component entirely onto the GPU.

Methodology: Tensor-Based N-Gram Modeling

The core innovation of NGPU-LM is the transformation of traditional pointer-heavy trie structures into a GPU-native format.

Tensor-Based Trie

Instead of traversing memory pointers, NGPU-LM represents the n-gram model using flat tensors: arcs, weights, and backoff_weights. This structure allows the GPU to utilize high-throughput "index-select" operations to query probabilities for an entire vocabulary in parallel.

N-Gram LM representation transitioning from ARPA format to a state-machine trie structure.

Iterative Backoff and Triton Kernels

The inference algorithm traverses the n-gram tree to find the optimal context match. Given that n-gram orders are typically small (3–10), the number of iterations remains low, making it highly efficient for GPU execution. To further minimize overhead, the authors implemented custom Triton kernels compatible with CUDA graphs, reducing CPU-to-GPU launch latency.

Integration with ASR Architectures

NGPU-LM is designed to work across various architectures, including Transducers (RNN-T), CTC, TDT, and AED. A critical discovery was the handling of the "blank" symbol in Transducers and CTC. Directly adding LM scores to all outputs often leads to increased deletion errors. NGPU-LM employs a "two-stage" selection process: it first checks for the "blank" symbol and only applies LM rescoring to non-blank tokens, ensuring stability and maintaining low WER.

Experimental Results

The approach was evaluated on diverse datasets including SLURP (voice commands), SPGISpeech (financial), and WSJ (Wall Street Journal), using 10-gram models built with KenLM.

Accuracy and Efficiency

NGPU-LM demonstrates significant accuracy gains with minimal impact on latency. On the SLURP dataset, it provides up to a 10.6% relative WER improvement. Crucially, this is achieved with less than 7% computational overhead compared to standard greedy decoding.

Comparison of WER and Real-Time Factor (RTFx) across various ASR architectures and decoding strategies.

As shown in the results, NGPU-LM biased greedy decoding is approximately 11x faster than traditional beam search with an LM in RNN-T models, while recovering a substantial portion of the accuracy gap.

Conclusion

NGPU-LM successfully demonstrates that GPU-native data structures can bring the benefits of external language modeling to high-speed greedy decoding. By narrowing the performance gap between greedy and beam search, it offers a practical solution for real-time, domain-specific ASR applications. Future work will explore integrating these GPU-accelerated LMs into beam search algorithms and developing more sophisticated keyword boosting techniques. The implementation is currently available in the NVIDIA NeMo toolkit.

Summary updated

BibTeX
@misc{bataev2025ngpu,
  author = {Vladimir Bataev and Andrei Andrusenko and Lilit 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