Using HuggingFace embedded locally

Hi,

The model card shows how to use the model entirely locally, see nomic-ai/nomic-embed-text-v1.5 · Hugging Face if you prefer Sentence Transformers and nomic-ai/nomic-embed-text-v1.5 · Hugging Face if you prefer to use the Transformers library.

Here’s how to use it entirely locally:

from transformers import AutoTokenizer, AutoModel

# load the model and tokenizer from the hub
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
model = AutoModel.from_pretrained("nomic-ai/nomic-embed-text-v1.5", trust_remote_code=True)

# save the the tokenizer files as well as the model weights locally
tokenizer.save_pretrained("path_to_your_local_folder")
model.save_pretrained("path_to_your_local_folder")

# load from local storage
tokenizer = AutoTokenizer.from_pretrained("path_to_your_local_folder")
model = AutoModel.from_pretrained("path_to_your_local_folder")

# proceed with embedding text as shown in the model card