Skip to content

Commit

Permalink
Merge pull request axolotl-ai-cloud#313 from OpenAccess-AI-Collective…
Browse files Browse the repository at this point in the history
…/tokenizer-llama2-embeddings

don't resize embeddings to multiples of 32x by default
  • Loading branch information
winglian committed Jul 22, 2023
2 parents 96d89e3 + 6621543 commit 3539732
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ tokenizer_type: AutoTokenizer
trust_remote_code:
# use_fast option for tokenizer loading from_pretrained, default to True
tokenizer_use_fast:
# resize the model embeddings when new tokens are added to multiples of 32
# this is reported to improve training speed on some models
resize_token_embeddings_to_32x:
# whether you are training a 4-bit GPTQ quantized model
gptq: true
Expand Down
6 changes: 5 additions & 1 deletion src/axolotl/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ def load_model(
**model_kwargs,
)

embeddings_len = math.ceil(len(tokenizer) / 32) * 32
embeddings_len = (
math.ceil(len(tokenizer) / 32) * 32
if cfg.resize_token_embeddings_to_32x
else len(tokenizer)
)
model.resize_token_embeddings(embeddings_len)

if (
Expand Down

0 comments on commit 3539732

Please sign in to comment.