ARTIFACTORY: How to download the models from Artifactory using HuggingFace Repositories

ARTIFACTORY: How to download the models from Artifactory using HuggingFace Repositories

AuthorFullName__c
Vaibhav Jain
articleNumber
000006285
ft:sourceType
Salesforce
FirstPublishedDate
2024-12-30T18:43:39Z
lastModifiedDate
2025-01-02
VersionNumber
3
Introduction to HuggingFace Repositories

HuggingFace is a community and data science platform that provides a broad community of data scientists, researchers, and ML engineers to come together and share ideas, get support, and contribute to open-source projects.


Artifactory’s integration with Hugging Face allows you to create a single system of record for ML models that brings ML/AI development in line with your existing SSC, using Artifactory to integrate machine learning into your stack.

This Knowledge Base article helps quickly configure the HuggingFace Remote Repositories in Artifactory and with HuggingFace SDK and then download models.


Downloading of a model

In order to download a model from Artifactory, we first need to create a remote repository pointing to https://huggingface.co  Below are the steps in detail.

1. Create a new remote repository by navigating to Administration -> Repositories -> Create Repository. Select HuggingFace and then create it.

User-added image 

2. Now, navigate to Terminal, and verify if python3 is installed. If yes, then run the below command to install the transformers. Installing transformers will install huggingface-hub and other packages that are needed. Then verify by running the pip3 list command.
> pip3 install transformers
> pip3 list                
Package            Version
------------------ ----------
certifi            2024.12.14
charset-normalizer 3.4.0
filelock           3.16.1
fsspec             2024.12.0
huggingface-hub    0.27.0
idna               3.10
numpy              2.2.1
packaging          24.2
pip                24.0
PyYAML             6.0.2
regex              2024.11.6
requests           2.32.3
safetensors        0.4.5
tokenizers         0.21.0
tqdm               4.67.1
transformers       4.47.1
typing_extensions  4.12.2
urllib3            2.3.0

 

 

3. Now, To configure the Hugging Face SDK to work with Artifactory:

> Go to the JFrog Platform Artifacts page, select your Hugging Face repository, and click Set Me Up.

> To create a Hugging Face token, enter your JFrog Platform password, and click Generate Token & Create Instructions.

> Connect your HuggingFaceML repository to the Hugging Face SDK in Artifactory using the following command:
export HF_HUB_ETAG_TIMEOUT=86400
export HF_HUB_DOWNLOAD_TIMEOUT=86400 
export HF_ENDPOINT=https://<YOUR_JFROG_DOMAIN>/artifactory/api/huggingfaceml/<REPOSITORY_NAME>
For ex:-
export HF_HUB_ETAG_TIMEOUT=86400
export HF_HUB_DOWNLOAD_TIMEOUT=86400
export HF_ENDPOINT=https://myArtifactory.jfrog.io/artifactory/api/huggingfaceml/testing-vj-hf-remote
4. Now, create a new .py file (download.py) and add the download command generated from Artifactory(Resolve section)
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id="<model_name>", revision="<model_revision>", etag_timeout=86400
)
Here, replace <model_name> and <model_revision> with the model and the revision number that needs to be downloaded. Below is the sample py file
snapshot_download(
    repo_id="Wi/gptp",revision="b21e4f3ae916c2e3f2a91ca3339d6ab78e672c97", etag_timeout=86400
)
5. Now execute the .py file with the following command(python3 download.py). The model download will be started. Below is the sample output from the client and the relevant screenshot from the UI.

Client output:-
python3 download.py                                                             
(…)280e6c0a28b696da77dd7bbc4fca20/README.md: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 69.0/69.0 [00:00<00:00, 79.5kB/s]
(…)0e6c0a28b696da77dd7bbc4fca20/config.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 814/814 [00:00<00:00, 1.24MB/s]
(…)c0a28b696da77dd7bbc4fca20/.gitattributes: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.38k/1.38k [00:00<00:00, 11.8MB/s]
(…)28b696da77dd7bbc4fca20/pytorch_model.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 431/431 [00:00<00:00, 1.34MB/s]
Fetching 4 files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:02<00:00,  1.90it/s]


Screenshot from UI:-

User-added image


Hooray, the model is downloaded!!!

For more details on the HuggingFace Repositories, please refer to the below articles.

  1. How to download a private model from HuggingFace using Artifactory
  2. How to Create HuggingFace Repostories in Artifactory
  3. How to Configure the HuggingFace SDK to work with Artifactory