Skip to content

Commit

Permalink
Update CTC decoder docs (#2443)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #2443

Reviewed By: nateanl

Differential Revision: D36909822

Pulled By: carolineechen

fbshipit-source-id: ef3ab2345e7a4666cf29dd02c83d03504e8aa62c
  • Loading branch information
Caroline Chen authored and facebook-github-bot committed Jun 4, 2022
1 parent 41082eb commit 3229fc5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions torchaudio/models/decoder/_ctc_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class CTCHypothesis(NamedTuple):
r"""Represents hypothesis generated by CTC beam search decoder :py:func`CTCDecoder`.
r"""Represents hypothesis generated by CTC beam search decoder :py:func:`CTCDecoder`.
:ivar torch.LongTensor tokens: Predicted sequence of token IDs. Shape `(L, )`, where
`L` is the length of the output sequence
Expand All @@ -46,15 +46,14 @@ class CTCDecoder:
"""
.. devices:: CPU
Lexically contrained CTC beam search decoder from *Flashlight* [:footcite:`kahn2022flashlight`].
CTC beam search decoder from *Flashlight* [:footcite:`kahn2022flashlight`].
Note:
To build the decoder, please use factory function
:py:func:`ctc_decoder`.
To build the decoder, please use the factory function :py:func:`ctc_decoder`.
Args:
nbest (int): number of best decodings to return
lexicon (Dict or None): lexicon mapping of words to spellings, or None for lexicon free decoder
lexicon (Dict or None): lexicon mapping of words to spellings, or None for lexicon-free decoder
word_dict (_Dictionary): dictionary of words
tokens_dict (_Dictionary): dictionary of tokens
lm (_LM): language model
Expand Down Expand Up @@ -211,20 +210,19 @@ def ctc_decoder(
unk_word: str = "<unk>",
) -> CTCDecoder:
"""
Builds lexically constrained CTC beam search decoder from
*Flashlight* [:footcite:`kahn2022flashlight`].
Builds CTC beam search decoder from *Flashlight* [:footcite:`kahn2022flashlight`].
Args:
lexicon (str or None): lexicon file containing the possible words and corresponding spellings.
Each line consists of a word and its space separated spelling. If `None`, uses lexicon free
Each line consists of a word and its space separated spelling. If `None`, uses lexicon-free
decoding.
tokens (str or List[str]): file or list containing valid tokens. If using a file, the expected
format is for tokens mapping to the same index to be on the same line
lm (str or None, optional): file containing language model, or `None` if not using a language model
nbest (int, optional): number of best decodings to return (Default: 1)
beam_size (int, optional): max number of hypos to hold after each decode step (Default: 50)
beam_size_token (int, optional): max number of tokens to consider at each decode step.
If None, it is set to the total number of tokens (Default: None)
If `None`, it is set to the total number of tokens (Default: None)
beam_threshold (float, optional): threshold for pruning hypothesis (Default: 50)
lm_weight (float, optional): weight of language model (Default: 2)
word_score (float, optional): word insertion score (Default: 0)
Expand Down

0 comments on commit 3229fc5

Please sign in to comment.