Load model from cache or disk not working

Library versions in my conda environment:
pytorch == 1.10.2
tokenizers == 0.10.1
transformers == 4.6.1 (cannot really upgrade due to a GLIB lib issue on linux)

I am trying to load a model and tokenizer - ProsusAI/finbert (already cached on disk by an earlier run in ~/.cache/huggingface/transformers/) using the transformers/tokenizers library, on a machine with no internet access.

However, when I try to load up the model using the below command, it throws up a connection error:

model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert", local_files_only=True)
tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert", local_files_only=True)

However I still get the error: ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

So, then, I download all model files from here and tried loading the model from that directory using the below command:

model = AutoModelForSequenceClassification.from_pretrained("./PATH_TO_FILES/", local_files_only=True)
tokenizer = AutoTokenizer.from_pretrained("./PATH_TO_FILES/", local_files_only=True)

This throws the same error I got above. This error persists on setting the environment variable to offline mode by

os.environ["TRANSFORMERS_OFFLINE"] = "1"

Is there a way to really load models from cache if I don’t have access to internet on the machine?

Thanks!

3 Likes

@s0ap, have you managed to solve your problem?