From 1fcd545c3dd78bd2113cde8ef788c5395de11c34 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Wed, 13 Dec 2023 10:14:01 +0800 Subject: [PATCH] fix #1819 --- src/llmtuner/model/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llmtuner/model/utils.py b/src/llmtuner/model/utils.py index a8853b1d..d3a5e1ed 100644 --- a/src/llmtuner/model/utils.py +++ b/src/llmtuner/model/utils.py @@ -182,7 +182,7 @@ def resize_embedding_layer(model: "PreTrainedModel", tokenizer: "PreTrainedToken return old_vocab_size = model.get_input_embeddings().weight.size(0) - if len(tokenizer) != old_vocab_size: + if len(tokenizer) > old_vocab_size: model.resize_token_embeddings(len(tokenizer), pad_to_multiple_of=64) new_vocab_size = model.get_input_embeddings().weight.size(0) logger.info("Resized token embeddings from {} to {}.".format(old_vocab_size, new_vocab_size))