Commit 4a82f4f8 authored by thomwolf's avatar thomwolf
Browse files

update special token addition

parent 991b8e65
...@@ -608,6 +608,7 @@ class OpenAIGPTModel(OpenAIGPTPreTrainedModel): ...@@ -608,6 +608,7 @@ class OpenAIGPTModel(OpenAIGPTPreTrainedModel):
# Build new embeddings and initialize all new embeddings (in particular the special tokens) # Build new embeddings and initialize all new embeddings (in particular the special tokens)
old_embed = self.tokens_embed old_embed = self.tokens_embed
self.tokens_embed = nn.Embedding(self.config.total_tokens_embeddings, self.config.n_embd) self.tokens_embed = nn.Embedding(self.config.total_tokens_embeddings, self.config.n_embd)
self.tokens_embed.to(old_embed.device.weight.device)
self.init_weights(self.tokens_embed) self.init_weights(self.tokens_embed)
# Copy word embeddings from the previous weights # Copy word embeddings from the previous weights
self.tokens_embed.weight.data[:self.config.vocab_size, :] = old_embed.weight.data[:self.config.vocab_size, :] self.tokens_embed.weight.data[:self.config.vocab_size, :] = old_embed.weight.data[:self.config.vocab_size, :]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment