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

Additional position embedding increase parameters of transformer? #226

Open
ken-ando opened this issue Dec 8, 2021 · 0 comments
Open

Additional position embedding increase parameters of transformer? #226

ken-ando opened this issue Dec 8, 2021 · 0 comments

Comments

@ken-ando
Copy link

ken-ando commented Dec 8, 2021

This work introduces additional positional embedding for the number of tokens more than 512.

if(args.max_pos>512):
my_pos_embeddings = nn.Embedding(args.max_pos, self.bert.model.config.hidden_size)
my_pos_embeddings.weight.data[:512] = self.bert.model.embeddings.position_embeddings.weight.data
my_pos_embeddings.weight.data[512:] = self.bert.model.embeddings.position_embeddings.weight.data[-1][None,:].repeat(args.max_pos-512,1)
self.bert.model.embeddings.position_embeddings = my_pos_embeddings

But, this code doesn't seem to extend transformer.
I think if the subsequent encoder does not have additional parameters, the shape will not match.

So, I guess the transformers automatically add the parameters of transformer, is this understanding correct?

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