From 0239d29fa02a88b50f27caa706834f3c3ce0262d Mon Sep 17 00:00:00 2001 From: hiyouga Date: Mon, 11 Dec 2023 18:09:40 +0800 Subject: [PATCH] tiny fix --- src/llmtuner/model/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/llmtuner/model/utils.py b/src/llmtuner/model/utils.py index b52582f5..4be84dce 100644 --- a/src/llmtuner/model/utils.py +++ b/src/llmtuner/model/utils.py @@ -189,7 +189,7 @@ def resize_embedding_layer(model: "PreTrainedModel", tokenizer: "PreTrainedToken Resize token embeddings. """ old_vocab_size = model.get_input_embeddings().weight.size(0) - new_vocab_size = len(tokenizer) - if new_vocab_size != old_vocab_size: - model.resize_token_embeddings(new_vocab_size, pad_to_multiple_of=64) - logger.info("Resized embedding tokens from {} to {}.".format(old_vocab_size, new_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))