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

Significance of using 'num_embeddings' and 'origin_shift' #29

Open
neenaloysius opened this issue Jun 23, 2021 · 1 comment
Open

Significance of using 'num_embeddings' and 'origin_shift' #29

neenaloysius opened this issue Jun 23, 2021 · 1 comment

Comments

@neenaloysius
Copy link

Hi,

Could you please give clarity on the significance of using 'num_embeddings' and 'origin_shift' when computing RelativeSinusoidalPositionalEmbedding?

self.origin_shift = num_embeddings//2 + 1

Thanks,
Neena

@yhcc
Copy link
Member

yhcc commented Aug 10, 2021

Sorry for the super late reply. Because we want the current word to have 0 distance with itself, and the word in its left has -1, -2, -3 ... distance(from nearby left to further left), and the word in the right has 1, 2, 3 ... distance. However, as you already know the nn.Embedding() does not support negative indexes, therefore, the negative indexes in the left should be converted into positive ones. We conduct this conversion by adding all distance with self.origin_shift. By doing so, the distance will be something like [...., self.orign_shift-3, self.orign_shift-2, self.orign_shift-1, self.origin_shift, self.origin_shift+1, self.origin_shift+2, ...].

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

No branches or pull requests

2 participants