diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 46a5f45cfa..b2f4b5c66e 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -613,10 +613,10 @@ def patch_tokenizer(model, tokenizer): # Edit all config with new pad token current_model = model - while hasattr(model, "model") and hasattr(model, "config"): + while hasattr(current_model, "model") and hasattr(current_model, "config"): current_model.config.update({"pad_token_id" : tokenizer.pad_token_id}) current_model = current_model.model - if hasattr(model, "model") and hasattr(model, "config"): + if hasattr(current_model, "model") and hasattr(current_model, "config"): current_model.config.update({"pad_token_id" : tokenizer.pad_token_id}) pass @@ -630,10 +630,10 @@ def patch_tokenizer(model, tokenizer): # Edit all config with new pad token current_model = model - while hasattr(model, "model") and hasattr(model, "config"): + while hasattr(current_model, "model") and hasattr(current_model, "config"): current_model.config.update({"pad_token_id" : tokenizer.pad_token_id}) current_model = model - if hasattr(model, "model") and hasattr(model, "config"): + if hasattr(current_model, "model") and hasattr(current_model, "config"): current_model.config.update({"pad_token_id" : tokenizer.pad_token_id}) pass diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index a53f52fe27..65e2d773e8 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1849,12 +1849,12 @@ class FastLlamaModel: # Fix up all vocab sizes current_model = model - while hasattr(model, "model") and hasattr(model, "config"): - if hasattr(model.config, "vocab_size"): + while hasattr(current_model, "model") and hasattr(current_model, "config"): + if hasattr(current_model.config, "vocab_size"): current_model.config.update({"vocab_size" : len(tokenizer)}) current_model = current_model.model - if hasattr(model, "model") and hasattr(model, "config"): - if hasattr(model.config, "vocab_size"): + if hasattr(current_model, "model") and hasattr(current_model, "config"): + if hasattr(current_model.config, "vocab_size"): current_model.config.update({"vocab_size" : len(tokenizer)}) pass pass