Skip to content

AutoModel.from_pretrained(local_files_only=True) changes the hash inside the refs/main #29401

@kouroshHakha

Description

@kouroshHakha

System Info

transformers 4.38.1

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. Download the model locally but put it under a hash that is not the same as the one from the latest in the hub
  2. Run this. Interestingly if you instantiate the tokenizer first and the model it works fine. The culprit is that the is_peft_available() branch of the logic will look for adapter_config.json file and it won't find it, so it will ask hub and in that process it overrides the refs/main file.
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained(
    model_id, 
    local_files_only=True,
)

tokenizer = AutoTokenizer.from_pretrained(
    model_id, 
    local_files_only=True,
)

Expected behavior

The code above to work, more importantly AutoModel.from_pretrained() to not change the content of refs/main file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions