Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using OpenFst to compile HLG. #606

Merged
merged 3 commits into from
Dec 9, 2022

Conversation

csukuangfj
Copy link
Collaborator

It is to avoid OOM in determinizing LG when G is very large.

See also

@Jarvan-Wang @wwx007121 Could you help test this PR? It should be able to handle large LMs and won't throw OOM as long as it does not throw OOM in kaldi as it is also using OpenFst to build LG.


I have tested the generated HLG with the pretrained model from
https://huggingface.co/Zengwei/icefall-asr-librispeech-lstm-transducer-stateless3-2022-09-28

It produces identical WER as the HLG generated by the master code for the first 30 utterances of test-clean and test-other.

One thing to note is that the file size of the resulting HLG is much smaller.

-rw-r--r-- 1 kuangfangjun root 806M Oct  8 10:51 data/lang_bpe_500/HLG.pt
-rw-r--r-- 1 kuangfangjun root 583M Oct  8 21:03 data/lang_bpe_500/HLG_fst.pt

HLG.pt is generated by the master code, while HLG_fst.pt is generated by this PR.

You have to install kaldifst to use this PR.

pip install kaldifst

or

conda install -c kaldifst kaldifst

The documentation for kaldifst is available at
https://k2-fsa.github.io/kaldifst/

@csukuangfj csukuangfj merged commit 4501821 into k2-fsa:master Dec 9, 2022
@csukuangfj csukuangfj deleted the hlg-openfst branch December 9, 2022 08:46
@wangtiance
Copy link
Contributor

Glad that I found this. Would it further help reducing the size of HLG if I do determinize and minimize after composing H with LG?

@wwx007121
Copy link
Contributor

Glad that I found this. Would it further help reducing the size of HLG if I do determinize and minimize after composing H with LG?

This is caused by the size of the FST itself, and the smaller the FST will affect the recognition effect. So It is better to use Lattice instead of H to be composed with LG, if you want to decode with phone-level modeling/wfst

@wangtiance
Copy link
Contributor

@wwx007121 I thought after minimizing the FST is equivalent as before, so it shouldn't affect recognition result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants