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

Enable stateful decoding of RNNT over multiple transcribe calls #3037

Merged
merged 16 commits into from
Oct 25, 2021

Conversation

titu1994
Copy link
Collaborator

@titu1994 titu1994 commented Oct 21, 2021

Changelog

  • Enable transcribe method to store hypothesis and reuse them for stateful multi step predictions
  • RNNT transcribe now takes partial_hypotheses as optional input, provided in returned hypothesis from previous transcribe call
  • Add abstract batch_concat_states and batch_copy_states support for RNNT models to abstract away state management.
  • Force all greedy and beam inference to pack results into Hypothesis objects. They now contain by default the
    • y_sequence : tensor form of int ids of tokens
    • dec_state : CPU tuple of decoder states
    • score: logprob score of current y_sequence
    • (optional) alignments: 2d dangling matrix of token alignments

Example

model = EncDecRNNTModelBPE.restore_from(...)

decoding= model.cfg.decoding
decoding.strategy = 'greedy'
model.change_decoding_strategy(decoding)

# First transcription, stateless
part_hyp, _ = model.transcribe([path to audio files], batch_size=4, return_hypotheses=True)

# Second transcription, restored state
hyp, _ = model.transcribe([path to continuation of audio files], return_hypotheses=True, partial_hypothesis=part_hyp)

@lgtm-com
Copy link

lgtm-com bot commented Oct 22, 2021

This pull request introduces 3 alerts when merging d7598fc into 1f36f32 - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Unused import

@titu1994 titu1994 requested review from VahidooX and jbalam-nv and removed request for VahidooX October 22, 2021 00:10
@lgtm-com
Copy link

lgtm-com bot commented Oct 22, 2021

This pull request introduces 3 alerts when merging 6318e3f into 1f36f32 - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Oct 24, 2021

This pull request introduces 3 alerts when merging 4b235eb into 9405273 - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Unused import

Copy link
Collaborator

@jbalam-nv jbalam-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jbalam-nv jbalam-nv merged commit 2439704 into NVIDIA:main Oct 25, 2021
@titu1994 titu1994 deleted the rnnt_stateful_decoding branch October 25, 2021 15:57
titu1994 added a commit to titu1994/NeMo that referenced this pull request Oct 26, 2021
…IA#3037)

* Start on stateful external decoding

Signed-off-by: smajumdar <[email protected]>

* Prepare connectors

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy sample decoding to use Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy batch first mode for Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Update second case of greedy batch decoding

Signed-off-by: smajumdar <[email protected]>

* Start stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Add guards for stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Fix state management when no states is provided

Signed-off-by: smajumdar <[email protected]>

* Create

Signed-off-by: smajumdar <[email protected]>

* Correct logging

Signed-off-by: smajumdar <[email protected]>

* Begin support for stateful beam decoding

Signed-off-by: smajumdar <[email protected]>

* Update streaming utils with method 2

Signed-off-by: smajumdar <[email protected]>

* Initiate stateful beam implementation

Signed-off-by: smajumdar <[email protected]>

* Reset changes

Signed-off-by: smajumdar <[email protected]>

* Fix style

Signed-off-by: smajumdar <[email protected]>

Co-authored-by: Jagadeesh Balam <[email protected]>
PeganovAnton pushed a commit that referenced this pull request Oct 31, 2021
* Start on stateful external decoding

Signed-off-by: smajumdar <[email protected]>

* Prepare connectors

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy sample decoding to use Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy batch first mode for Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Update second case of greedy batch decoding

Signed-off-by: smajumdar <[email protected]>

* Start stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Add guards for stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Fix state management when no states is provided

Signed-off-by: smajumdar <[email protected]>

* Create

Signed-off-by: smajumdar <[email protected]>

* Correct logging

Signed-off-by: smajumdar <[email protected]>

* Begin support for stateful beam decoding

Signed-off-by: smajumdar <[email protected]>

* Update streaming utils with method 2

Signed-off-by: smajumdar <[email protected]>

* Initiate stateful beam implementation

Signed-off-by: smajumdar <[email protected]>

* Reset changes

Signed-off-by: smajumdar <[email protected]>

* Fix style

Signed-off-by: smajumdar <[email protected]>

Co-authored-by: Jagadeesh Balam <[email protected]>
Signed-off-by: PeganovAnton <[email protected]>
jfsantos pushed a commit to jfsantos/NeMo that referenced this pull request Nov 19, 2021
…IA#3037)

* Start on stateful external decoding

Signed-off-by: smajumdar <[email protected]>

* Prepare connectors

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy sample decoding to use Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Refactor greedy batch first mode for Hypothesis

Signed-off-by: smajumdar <[email protected]>

* Update second case of greedy batch decoding

Signed-off-by: smajumdar <[email protected]>

* Start stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Add guards for stateful decoding

Signed-off-by: smajumdar <[email protected]>

* Fix state management when no states is provided

Signed-off-by: smajumdar <[email protected]>

* Create

Signed-off-by: smajumdar <[email protected]>

* Correct logging

Signed-off-by: smajumdar <[email protected]>

* Begin support for stateful beam decoding

Signed-off-by: smajumdar <[email protected]>

* Update streaming utils with method 2

Signed-off-by: smajumdar <[email protected]>

* Initiate stateful beam implementation

Signed-off-by: smajumdar <[email protected]>

* Reset changes

Signed-off-by: smajumdar <[email protected]>

* Fix style

Signed-off-by: smajumdar <[email protected]>

Co-authored-by: Jagadeesh Balam <[email protected]>
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

2 participants