xray1111 commited on
Commit
7e7b28a
1 Parent(s): ace966b

Add get_output_embeddings

Browse files

When load model using from_pretrained method, output embedding weights will not be loaded if it is shared with other weights, like input embedding.

Files changed (1) hide show
  1. modeling_florence2.py +3 -0
modeling_florence2.py CHANGED
@@ -2588,6 +2588,9 @@ class Florence2ForConditionalGeneration(Florence2PreTrainedModel):
2588
  def get_input_embeddings(self):
2589
  return self.language_model.get_input_embeddings()
2590
 
 
 
 
2591
  def resize_token_embeddings(self, new_num_tokens: Optional[int] = None, pad_to_multiple_of=None) -> nn.Embedding:
2592
  model_embeds = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)
2593
  # update vocab size
 
2588
  def get_input_embeddings(self):
2589
  return self.language_model.get_input_embeddings()
2590
 
2591
+ def get_output_embeddings(self):
2592
+ return self.language_model.get_output_embeddings()
2593
+
2594
  def resize_token_embeddings(self, new_num_tokens: Optional[int] = None, pad_to_multiple_of=None) -> nn.Embedding:
2595
  model_embeds = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)
2596
  # update vocab size