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

Add fast beam search emformer #68

Merged
merged 6 commits into from
Jul 21, 2022

Conversation

ezerhouni
Copy link
Collaborator

@ezerhouni ezerhouni commented Jul 20, 2022

This PR adds fast_beam_search_one_best to the following models :

  • pruned_stateless_emformer_rnnt2

  • conv_emformer_transducer_stateless

@ezerhouni ezerhouni requested review from csukuangfj and pkufool July 20, 2022 13:18
sherpa/bin/pruned_stateless_emformer_rnnt2/decode.py Outdated Show resolved Hide resolved
if decoding_method == "greedy_search":
decoder_out_list = []
hyp_list = []
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please refactor it in a way that makes it easier to support other decoding methods.

return parser.parse_args()


@torch.no_grad()
def run_model_and_do_greedy_search(
def run_model_and_do_search(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest refactoring it into two functions:

  • run_model_and_do_greedy_search
  • run_model_and_do_fast_beam_search

It makes the code more readable and more maintainable, I think.

If we want to support another decoding method, we can just create a new function to do that.


It is just a suggestion. You can leave it as it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It make sense, I will finish first the work of conv_emformer at first

@ezerhouni ezerhouni mentioned this pull request Jul 21, 2022
2 tasks
@csukuangfj
Copy link
Collaborator

Could you also update GitHub CI for https://github.com/k2-fsa/sherpa/blob/master/.github/workflows/run-streaming-conv-emformer-test.yaml#L36

to include

decoding: ["greedy_search", "fast_beam_search"]

--decoding-method ${{ matrix.decoding }} \

You can apply a label to this PR with the name ready to trigger GitHub actions.

@ezerhouni
Copy link
Collaborator Author

Should be all good @csukuangfj !

@ezerhouni ezerhouni changed the title [WIP] Add fast beam search emformer Add fast beam search emformer Jul 21, 2022
@csukuangfj
Copy link
Collaborator

Should be all good @csukuangfj !

Thanks! Let us wait for the CI. Will merge after all tests pass.

Thanks again!

@csukuangfj csukuangfj merged commit 12915bf into k2-fsa:master Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants