[Paper Review] Pkwrap: a PyTorch Package for LF-MMI Training of Acoustic Models
Pkwrap is a PyTorch package that enables end-to-end LF-MMI training of acoustic models by wrapping Kaldi's LF-MMI framework, exposing the cost function as a PyTorch autograd function and supporting both alignment-based and flat-start training. It achieves WERs comparable to Kaldi across multiple datasets, including a 5.7% relative WER improvement on Switchboard CH with 4-gram LM.
We present a simple wrapper that is useful to train acoustic models in PyTorch using Kaldi's LF-MMI training framework. The wrapper, called pkwrap (short form of PyTorch kaldi wrapper), enables the user to utilize the flexibility provided by PyTorch in designing model architectures. It exposes the LF-MMI cost function as an autograd function. Other capabilities of Kaldi have also been ported to PyTorch. This includes the parallel training ability when multi-GPU environments are unavailable and decode with graphs created in Kaldi. The package is available on Github at https://github.com/idiap/pkwrap.
Motivation & Objective
- Enable flexible acoustic model design in PyTorch while retaining Kaldi's state-of-the-art LF-MMI training framework.
- Support both alignment-based and flat-start LF-MMI training to match Kaldi's training paradigms.
- Provide NG-SGD parallel training support in PyTorch for multi-GPU and non-multi-GPU environments.
- Facilitate seamless model loading and decoding using Kaldi-compatible data and decoding graphs.
- Simplify recipe-based training and decoding workflows for researchers and practitioners.
Proposed method
- Expose Kaldi's LF-MMI objective function as a PyTorch autograd function via the KaldiChainObjfFunction class.
- Implement a PyTorch-compatible NG-SGD optimizer by wrapping Kaldi's NaturalGradientAffineTransform and NGState for natural gradient updates.
- Use pybind11 to bind essential Kaldi C++ functions, enabling low-overhead memory transfer between Kaldi and PyTorch tensors.
- Support bidirectional conversion between Kaldi matrices and PyTorch tensors for model loading and interoperability.
- Provide recipe scripts that handle data preparation, feature extraction, egs generation, and decoding using Kaldi tools via subprocess calls.
- Integrate model merging and learning rate decay with exponential scheduling, mirroring Kaldi's default behavior.
Experimental results
Research questions
- RQ1Can a PyTorch wrapper achieve comparable WER performance to Kaldi in LF-MMI acoustic model training?
- RQ2To what extent can PyTorch's model flexibility be combined with Kaldi's robust LF-MMI training pipeline?
- RQ3How effective is the integration of Kaldi's NG-SGD optimizer in PyTorch for distributed and non-distributed training?
- RQ4Can the wrapper support both alignment-based and flat-start LF-MMI training with minimal user intervention?
- RQ5How well does the package interoperate with existing Kaldi recipes for decoding and model evaluation?
Key findings
- Pkwrap achieved a WER of 19.3% on Minilibrispeech, compared to Kaldi's 20.7%, demonstrating competitive performance on a small-scale dataset.
- On Switchboard, Pkwrap achieved a 5.7% relative WER improvement on the CH subset and 4.9% on the SWBD subset using a 4-gram LM.
- For multilingual BABEL, Pkwrap achieved WERs within 1% of Kaldi across all four languages, with a 3.5% relative improvement on Swahili (36.4% vs. 37.7%).
- On Librispeech 100h, Pkwrap achieved a 5.1% WER on dev-clean and 5.9% on test-clean, matching Kaldi's 5.5% and 6.0% respectively, with a 5.5% relative improvement on dev-other.
- The package successfully enabled training with Adam optimizer and exponential learning rate decay, achieving results consistent with Kaldi's NG-SGD baseline.
- Model loading from Kaldi into PyTorch was supported via the load_kaldi_models branch, enabling cross-framework model reuse.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.