Skip to content

Commit

Permalink
Update script for ngram rnnt and hat beam search decoding (#6370)
Browse files Browse the repository at this point in the history
* add rnnt ngram beamsearch script

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* add return encoding embedding option

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* update script

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* add rnnt and hat ngram decoding script

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* add some parameters

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add return_encoder_embeddings parameter to RNNTDecodingConfig

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* replace return_encoder_embeddings parameter

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* generalization of scipt behavior

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove return_encoder_embeddings parameter

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* remove return_encoder_embeddings parameter

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* add manual encoder_embeddings calculation

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix beam_width value to 8

Signed-off-by: Andrei Andrusenko <52885736+andrusenkoau@users.noreply.github.com>

* fix rescoring description

Signed-off-by: Andrei Andrusenko <52885736+andrusenkoau@users.noreply.github.com>

---------

Signed-off-by: andrusenkoau <andrusenkoau@gmail.com>
Signed-off-by: Andrei Andrusenko <52885736+andrusenkoau@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Somshubra Majumdar <titu1994@gmail.com>
  • Loading branch information
3 people authored Apr 21, 2023
1 parent 2822ff3 commit 244ba8d
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 174 deletions.
23 changes: 23 additions & 0 deletions docs/source/asr/asr_language_modeling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,29 @@ For instance, the following set of parameters would results in 2*1*2=4 beam sear
beam_beta=[1.0,0.5]
Beam search ngram decoding for Transducer models (RNNT and HAT)
===============================================================

The similar script to evaluate an RNNT/HAT model with beam search decoding and N-gram models can be found at
`scripts/asr_language_modeling/ngram_lm/eval_beamsearch_ngram_transducer.py <https://github.com/NVIDIA/NeMo/blob/stable/scripts/asr_language_modeling/ngram_lm/eval_beamsearch_ngram_transducer.py>`_

.. code-block::
python eval_beamsearch_ngram_transducer.py nemo_model_file=<path to the .nemo file of the model> \
input_manifest=<path to the evaluation JSON manifest file \
kenlm_model_file=<path to the binary KenLM model> \
beam_width=[<list of the beam widths, separated with commas>] \
beam_alpha=[<list of the beam alphas, separated with commas>] \
preds_output_folder=<optional folder to store the predictions> \
probs_cache_file=null \
decoding_strategy=<greedy_batch or maes decoding>
maes_prefix_alpha=[<list of the maes prefix alphas, separated with commas>] \
maes_expansion_gamma=[<list of the maes expansion gammas, separated with commas>] \
hat_subtract_ilm=<in case of HAT model: subtract internal LM or not (True/False)> \
hat_ilm_weight=[<in case of HAT model: list of the HAT internal LM weights, separated with commas>] \
.. _neural_rescoring:

****************
Expand Down
1 change: 1 addition & 0 deletions nemo/collections/asr/models/rnnt_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def transcribe(
"""
if paths2audio_files is None or len(paths2audio_files) == 0:
return {}

# We will store transcriptions here
hypotheses = []
all_hypotheses = []
Expand Down
Loading

0 comments on commit 244ba8d

Please sign in to comment.