Skip to content

Commit 3ffb018

Browse files
authored
Merge pull request axolotl-ai-cloud#313 from OpenAccess-AI-Collective/tokenizer-llama2-embeddings
don't resize embeddings to multiples of 32x by default
2 parents a94f2ee + 1066751 commit 3ffb018

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ tokenizer_type: AutoTokenizer
322322
trust_remote_code:
323323
# use_fast option for tokenizer loading from_pretrained, default to True
324324
tokenizer_use_fast:
325+
# resize the model embeddings when new tokens are added to multiples of 32
326+
# this is reported to improve training speed on some models
327+
resize_token_embeddings_to_32x:
325328
326329
# whether you are training a 4-bit GPTQ quantized model
327330
gptq: true

src/axolotl/utils/models.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ def load_model(
301301
**model_kwargs,
302302
)
303303

304-
embeddings_len = math.ceil(len(tokenizer) / 32) * 32
304+
embeddings_len = (
305+
math.ceil(len(tokenizer) / 32) * 32
306+
if cfg.resize_token_embeddings_to_32x
307+
else len(tokenizer)
308+
)
305309
model.resize_token_embeddings(embeddings_len)
306310

307311
if (

0 commit comments

Comments
 (0)