| Title: | Hugging Face Hub Interface |
|---|---|
| Description: | Provides functionality to download and cache files from 'Hugging Face Hub' <https://huggingface.co/models>. Uses the same caching structure so files can be shared between different client libraries. |
| Authors: | Tomasz Kalinowski [ctb, cre], Daniel Falbel [aut], Christophe Regouby [ctb], Posit Software, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>) |
| Maintainer: | Tomasz Kalinowski <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2.9000 |
| Built: | 2026-05-15 09:05:08 UTC |
| Source: | https://github.com/mlverse/hfhub |
Downloads files from HuggingFace repositories
hub_download( repo_id, filename, ..., revision = "main", repo_type = "model", local_files_only = FALSE, force_download = FALSE )hub_download( repo_id, filename, ..., revision = "main", repo_type = "model", local_files_only = FALSE, force_download = FALSE )
repo_id |
The repository identifier, eg |
filename |
Filename to download from the repository. Example |
... |
currenytly unused. |
revision |
Revision (branch, tag or commitid) to download the file from. |
repo_type |
The type of the repository. Currently only |
local_files_only |
Only use cached files? |
force_download |
For re-downloading of files that are cached. |
The file path of the downloaded or cached file. The snapshot path is returned as an attribute.
try({ withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), { path <- hub_download("gpt2", "config.json") print(path) str(jsonlite::fromJSON(path)) }) })try({ withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), { path <- hub_download("gpt2", "config.json") print(path) str(jsonlite::fromJSON(path)) }) })
Queries information about Hub repositories
hub_repo_info( repo_id, ..., repo_type = NULL, revision = NULL, files_metadata = FALSE ) hub_dataset_info(repo_id, ..., revision = NULL, files_metadata = FALSE)hub_repo_info( repo_id, ..., repo_type = NULL, revision = NULL, files_metadata = FALSE ) hub_dataset_info(repo_id, ..., revision = NULL, files_metadata = FALSE)
repo_id |
The repository identifier, eg |
... |
currenytly unused. |
repo_type |
The type of the repository. Currently only |
revision |
Revision (branch, tag or commitid) to download the file from. |
files_metadata |
Obtain files metadata information when querying repository information. |
A list with information about the repository, including model details, file siblings, tags, and other metadata returned by the Hugging Face API.
hub_dataset_info(): Query information from a Hub Dataset
try({ info <- hub_repo_info("gpt2") info$modelId })try({ info <- hub_repo_info("gpt2") info$modelId })
Downloads and stores all files from a Hugging Face Hub repository.
hub_snapshot( repo_id, ..., revision = "main", repo_type = "model", local_files_only = FALSE, force_download = FALSE, allow_patterns = NULL, ignore_patterns = NULL )hub_snapshot( repo_id, ..., revision = "main", repo_type = "model", local_files_only = FALSE, force_download = FALSE, allow_patterns = NULL, ignore_patterns = NULL )
repo_id |
The repository identifier, eg |
... |
currenytly unused. |
revision |
Revision (branch, tag or commitid) to download the file from. |
repo_type |
The type of the repository. Currently only |
local_files_only |
Only use cached files? |
force_download |
For re-downloading of files that are cached. |
allow_patterns |
A character vector containing patters that are used to filter allowed files to snapshot. |
ignore_patterns |
A character vector contaitning patterns to reject files from being downloaded. |
A string with the path to the snapshot directory containing all downloaded files.
try({ withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), { path <- hub_snapshot("gpt2", allow_patterns = "config.json") list.files(path) }) })try({ withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), { path <- hub_snapshot("gpt2", allow_patterns = "config.json") list.files(path) }) })
Weight file names in HUB
WEIGHTS_NAME() WEIGHTS_INDEX_NAME()WEIGHTS_NAME() WEIGHTS_INDEX_NAME()
A string with the default file names for indexes in the Hugging Face Hub.
WEIGHTS_NAME(): Name of weights file
WEIGHTS_INDEX_NAME(): Name of weights index file
WEIGHTS_NAME() WEIGHTS_INDEX_NAME()WEIGHTS_NAME() WEIGHTS_INDEX_NAME()