TENER icon indicating copy to clipboard operation
TENER copied to clipboard

Significance of using 'num_embeddings' and 'origin_shift'

Open neenaloysius opened this issue 4 years ago • 1 comments

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

neenaloysius avatar Jun 23 '21 06:06 neenaloysius

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, ...].

yhcc avatar Aug 10 '21 15:08 yhcc