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 relative positional encoding for Emformer #448

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

yaozengwei
Copy link
Collaborator

This PR aims to support relative positional encoding for the simplified Emformer (#440, not merged yet).
Since the query and key tensors for attention computation is not "continuous" during training, we can not easily apply the "shift trick" as in Conformer (https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/pruned_transducer_stateless2/conformer.py#L532):

  • query: [hard-copied right context, utterance]
  • key: [memory, hard-copied right context, utterance]

Hence, I first compute the relative positions between query indexes and key indexes, and use the torch.gather operation to gather target position-related scores with the pre-computed positions.

The RelPositionalEncoding class is also modified.

Details can be found in conv_emformer_transducer_stateless3/emformer.py.

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.

1 participant