{"id":18439532,"url":"https://github.com/idiap/pkwrap","last_synced_at":"2025-08-14T18:42:38.374Z","repository":{"id":38241609,"uuid":"284044462","full_name":"idiap/pkwrap","owner":"idiap","description":"A pytorch wrapper for LF-MMI training and parallel training in Kaldi","archived":false,"fork":false,"pushed_at":"2022-06-08T12:10:26.000Z","size":949,"stargazers_count":73,"open_issues_count":4,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-23T01:02:38.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiap.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-31T13:35:46.000Z","updated_at":"2024-07-17T13:15:46.000Z","dependencies_parsed_at":"2022-08-24T14:27:18.992Z","dependency_job_id":null,"html_url":"https://github.com/idiap/pkwrap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fpkwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fpkwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fpkwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Fpkwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiap","download_url":"https://codeload.github.com/idiap/pkwrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247732713,"owners_count":20986910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T06:25:17.913Z","updated_at":"2025-04-07T21:32:33.937Z","avatar_url":"https://github.com/idiap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n**UPDATE (2021-02-03)**: See [changelog](./CHANGELOG.md) for the latest updates to the code\n\nThis is a (yet another!) python wrapper for Kaldi. The main goal is to be able to train acoustic models in Pytorch\nso that we can\n\n1. use MMI cost function during training\n2. use NG-SGD for affine transformations, which enables multi-GPU training with SGE\n\n------------------------------------\nTable of Contents\n------------------------------------\n\n\u003c!--ts--\u003e\n   * [Table of contents](#table-of-contents)\n   * [Motivation](#motivation)\n   * [Installation](#installation)\n   * [Usage](#usage)\n   * [Works based on Pkwrap](#works-based-on-pkwrap)\n   * [References and citation](#references-and-citation)\n\u003c!--te--\u003e\n\n------------------------------------\nMotivation\n------------------------------------\nThe main motivation of this project is to run MMI training in Pytorch. The idea is to use existing\nfunctionality in Kaldi so that we don't have to re-implement anything.\n\n### Why not use the existing wrappers?\n\n**Pykaldi** is good for exposing high-level functionalties. However, many things are still not possible (e.g.\nloading NNet3 models and having access to the parameters of the model). Modifying Pykaldi requires us to have\ncustom versions of Kaldi and CLIF. Moreover, if one simply wanted to converting Tensors in GPU to Kaldi CuMatrix\nwas not efficient (the general route afaik would be Tensor GPU -\u003e Tensor CPU -\u003e Kaldi Matrix CPU -\u003e Kaldi Matrix GPU).\n\n**Pykaldi2** provides a version of LF-MMI training, which uses Pykaldi functions.\n\n------------------------------------\nInstallation\n------------------------------------\nPkwrap has been tested with the following pytorch and CUDA libraries\n\n| Pytorch | CUDA       |\n| ------- | ---------- |\n| 1.6     | 9.2, 10.2  |\n| 1.7     | 10.2       |\n| 1.8     | 10.2, 11.1 |\n\n1. Activate your pytorch environment.\n2. Install requirements with ``pip install -r requirements.txt``\n3. Compile Kaldi with `CXXFLAGS=\"-D_GLIBCXX_USE_CXX11_ABI=0\"`.\n4. Set ``KALDI_ROOT`` and optionally ``MKL_ROOT`` in the environment. Note: in the future this will be made easier with autoconf.\n5. Run ``make``\n\n### Known Issues / Common Pitfalls\n\n- the g++ version of pytorch, kaldi and pkwrap should match!\n\n------------------------------------\nUsage\n------------------------------------\nBefore importing do check if Kaldi libraries used to compile the package are accessible in your environment.\nOtherwise, it should be added to ``$LD_LIBRARY_PATH`` as follows\n\n```\nLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KALDI_ROOT/src/lib\n```\n\nCurrently there are recipes for conventional LF-MMI training with\npkwrap\n\n- [Minilibrespeech recipe](egs/mini_librespeech/s5/README.md)\n- [Switchboard](egs/switchboard/v1/README.md)\n- [Librispeech](egs/librispeech/v1/README.md)\n\nFor flatstart LF-MMI training there is a recipe in [Librispeech](egs/librispeech/v1/README.md).\n\nFor experiments related to quantization of acoustic models trained in Kaldi see ``egs/librispeech/quant`` in ``load_kaldi_models`` branch.\n\n------------------------------------\nWorks based on Pkwrap\n------------------------------------\nFollowing list of works are based on this repository and might be of interest:\n\n1.Lattice-Free MMI Adaptation Of Self-Supervised Pretrained Acoustic Models\n  - Paper: [https://arxiv.org/abs/2012.14252](https://arxiv.org/abs/2012.14252)\n  - Code: [Adaptation of Pretrained Acoustic Models (APAM)](https://github.com/idiap/apam)\n\n------------------------------------\nReferences and Citation\n------------------------------------\nThe technical report is now available [here](https://arxiv.org/abs/2010.03466). The report can\nbe cited as in the following bibtex example:\n\n```\n@article{madikeri2020pkwrap,\n  title={Pkwrap: a PyTorch Package for LF-MMI Training of Acoustic Models},\n  author={Madikeri, Srikanth and Tong, Sibo and Zuluaga-Gomez, Juan and Vyas, Apoorv and Motlicek, Petr and Bourlard, Herv{\\'e}},\n  journal={arXiv preprint arXiv:2010.03466},\n  year={2020}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fpkwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiap%2Fpkwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Fpkwrap/lists"}