Skip to content

Commit

Permalink
add resize token embeddings option
Browse files Browse the repository at this point in the history
  • Loading branch information
Малахов Алексей Павлович committed Nov 26, 2024
1 parent 809eb0e commit ead02ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion turbo_alignment/common/tf/loaders/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def load_model(
if model_settings.transformers_settings.load_in_8bit:
model = prepare_model_for_int8_training(model)

model.resize_token_embeddings(len(tokenizer))
if model_settings.resize_token_embeddings:
model.resize_token_embeddings(len(tokenizer))

if model_settings.embeddings_initialization_strategy is not None:
with torch.no_grad():
Expand Down
2 changes: 2 additions & 0 deletions turbo_alignment/settings/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class PreTrainedModelSettings(ExtraFieldsNotAllowedBaseModel):

transformers_settings: ModelTransformersSettings

resize_token_embeddings: bool = False

embeddings_initialization_strategy: dict[str, str] | None = None

liger_kernels_settings: LigerKernelSettings | None = None
Expand Down

0 comments on commit ead02ad

Please sign in to comment.