From f4657de7d574fdab5d164c679bd474d35140894a Mon Sep 17 00:00:00 2001 From: hiyouga Date: Mon, 11 Dec 2023 20:55:50 +0800 Subject: [PATCH] fix baichuan resize --- src/llmtuner/model/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/llmtuner/model/utils.py b/src/llmtuner/model/utils.py index 4be84dce..d897c849 100644 --- a/src/llmtuner/model/utils.py +++ b/src/llmtuner/model/utils.py @@ -188,6 +188,10 @@ def resize_embedding_layer(model: "PreTrainedModel", tokenizer: "PreTrainedToken r""" Resize token embeddings. """ + if not isinstance(model.get_output_embeddings(), torch.nn.Linear): + logger.warning("Current model does not support resizing token embeddings.") + return + old_vocab_size = model.get_input_embeddings().weight.size(0) if len(tokenizer) != old_vocab_size: model.resize_token_embeddings(len(tokenizer), pad_to_multiple_of=64)