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

Dev zhanglu #3649

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions model/model_training/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,16 @@ def get_model(conf, tokenizer, pad_vocab_size_to_multiple_of=16, check_freeze_la
)

n_embs = model.get_input_embeddings().num_embeddings
if len(tokenizer) != n_embs and check_freeze_layer:
assert not conf.freeze_layer, "Cannot change the number of embeddings if the model is frozen."

if len(tokenizer) != n_embs or pad_vocab_size_to_multiple_of:
p = pad_vocab_size_to_multiple_of
target_size = len(tokenizer) if not p else math.ceil(len(tokenizer) / p) * p
print("Resizing embeddings to", target_size)
model.resize_token_embeddings(target_size)

new_n_embs = model.get_input_embeddings().num_embeddings
if new_n_embs != n_embs and check_freeze_layer:
assert not conf.freeze_layer, "Cannot change the number of embeddings if the model is frozen."

if conf.freeze_layer:
model = freeze_top_n_layers(model, conf.freeze_layer)

Expand Down
2 changes: 1 addition & 1 deletion model/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tests = [
]

[tool.setuptools]
py-modules = ["model_training"]
packages = ["model_training"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure why this change is shown, this was already merged in #3643.


[tool.black]
line-length = 120
Expand Down