Running locally using transformers

I am confirming whether or not using transformers with the models locally on my workstation downloads the model or if it is using APIs to models hosted on Hugging Face. Could you please let me know I am not familiar enough with the mechanisms in transformers and if that hides API calls to a huggingFace server. It appears that a model is loaded locally to my workstation and I am using that. I just need to confirm.

You filed this question under NLP Course 1 which does not involve Sequential Models, Attention or Transformers, so I’m not sure which assignment you are referring to here. But just generally speaking a Transformer model is just a complex model that plugs together several Attention layers and other network layers, so there should be no remote API calls involved. But I’m speaking generally here, not w.r.t. to any particular assignment. If Hugging Face APIs were being used, I’d expect them to be apparent at the level of the visible code in the notebook. Well, I guess they could be in a utility function that is in another file and is invoked from the main notebook. You can look at the “import” block in your notebook and see what is used there. Then examine any local utility files to see what they contain.

Hello there!

Hugging Face models are by default stored in ./cache/hugginface/hub
(e.g., Windows: Users\YourName\.cache\huggingface\hub - Linux/Mac: ~/.cache/huggingface/hub)

If your code looks something like:

from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained("bert-base-uncased")

the model should be cached locally and no call to a remote model via API is performed (if that is what you are asking).

1 Like

Thank you this is very helpful. It is exactly what I am doing.