Skip to content

Commit

Permalink
support {set,get}_input_embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
KoichiYasuoka authored Dec 27, 2024
1 parent 7ff39fa commit e51b48a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/transformers/models/modernbert/modular_modernbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,12 @@ def __init__(self, config: ModernBertConfig):
# Initialize weights and apply final processing
self.post_init()

def get_input_embeddings(self):
return self.embeddings.tok_embeddings

def set_input_embeddings(self, value):
self.embeddings.tok_embeddings = value

@add_start_docstrings_to_model_forward(MODERNBERT_INPUTS_DOCSTRING)
@add_code_sample_docstrings(
checkpoint=_CHECKPOINT_FOR_DOC,
Expand Down Expand Up @@ -1389,6 +1395,12 @@ def __init__(self, config: ModernBertConfig):
# Initialize weights and apply final processing
self.post_init()

def get_input_embeddings(self):
return self.embeddings.tok_embeddings

def set_input_embeddings(self, value):
self.embeddings.tok_embeddings = value

@add_start_docstrings_to_model_forward(MODERNBERT_INPUTS_DOCSTRING)
@add_code_sample_docstrings(
checkpoint=_CHECKPOINT_FOR_DOC,
Expand Down

0 comments on commit e51b48a

Please sign in to comment.