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

Positional embedding weight #5

Open
StevenLau6 opened this issue Sep 30, 2022 · 0 comments
Open

Positional embedding weight #5

StevenLau6 opened this issue Sep 30, 2022 · 0 comments

Comments

@StevenLau6
Copy link

StevenLau6 commented Sep 30, 2022

Hi @luyang-huang96, thanks so much for posting the code. I noticed that the function align_embed_position keeps the first 1026 tokens' positional embedding weight and concatenates the same weight for tokens after 1026.

def align_embed_position(self):
self.embed_positions_new.weight.data[:1026, :] = self.embed_positions.weight.data
self.embed_positions_new.weight.data[1026:, :] = self.embed_positions.weight.data[-1][None, :].repeat(self.max_source_positions-1024, 1)
if self.section:
self.embed_section.weight.data[4:1028, :] = self.embed_positions.weight.data[2:, :]
self.embed_section.weight.data[0:2, :] = self.embed_positions.weight.data[0:2, :]
self.embed_section.weight.data[1028:, :] = self.embed_positions.weight.data[-1][None, :].repeat(self.max_source_positions-1026, 1)
# self.embed_positions = self.embed_positions_new

I have two questions:

  1. Considering the 1026th token can be the eos token, I wonder whether it should keep the first 1025 tokens' positional embedding weight.
  2. Why not copy the first 1026 tokens' positional embedding weight for the tokens after 1026, like people discussed in
    Does BART support more than 1024 tokens in inference of summarization task?  facebookresearch/fairseq#1685 (comment)
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

1 participant