Hugging Face
tensoris.lib.integrations.huggingface ¶
Hugging Face Hub Integration Helper.
Classes¶
HuggingFaceIntegration ¶
Hugging Face Hub helper for downloading datasets/models and pushing PyTorch checkpoints.
References
Hugging Face Hub Python SDK: https://huggingface.co/docs/huggingface_hub/
Source code in src/tensoris/lib/integrations/huggingface.py
Attributes¶
Methods:¶
__init__ ¶
Initialize Hugging Face Hub client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
Optional Hugging Face User Access Token (defaults to HF_TOKEN env var). |
None
|
Source code in src/tensoris/lib/integrations/huggingface.py
download_file ¶
Download a single model weight file from Hugging Face Hub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Source Hugging Face Hub repository ID. |
required |
filename
|
str
|
Target file name (e.g. 'pytorch_model.bin'). |
required |
local_dir
|
str | Path
|
Destination folder path. |
'inputs/models'
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to downloaded file. |
Source code in src/tensoris/lib/integrations/huggingface.py
push_model ¶
Upload local model directory or checkpoint files to Hugging Face Hub repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
Target Hugging Face Hub repo ID (e.g. 'username/model-name'). |
required |
local_dir
|
str | Path
|
Local folder path containing checkpoint weights and configs. |
required |
commit_message
|
str
|
Git commit message on Hub repo. |
'Upload model checkpoint'
|
Returns:
| Type | Description |
|---|---|
str
|
URL string of published Hugging Face repository. |