Title: Hugging Face Hub Interface
Version: 0.1.2
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.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: httr, filelock, fs, cli, withr, curl, glue, urltools, rlang
Suggests: testthat (≥ 3.0.0), jsonlite
Config/testthat/edition: 3
URL: https://mlverse.github.io/hfhub/
BugReports: https://github.com/mlverse/hfhub/issues
NeedsCompilation: no
Packaged: 2026-04-15 14:23:17 UTC; dfalbel
Author: Tomasz Kalinowski [ctb, cre], Daniel Falbel [aut], Christophe Regouby [ctb], Posit Software, PBC ROR ID [cph, fnd]
Maintainer: Tomasz Kalinowski <tomasz@posit.co>
Repository: CRAN
Date/Publication: 2026-04-15 14:50:02 UTC

Weight file names in HUB

Description

Weight file names in HUB

Usage

WEIGHTS_NAME()

WEIGHTS_INDEX_NAME()

Value

A string with the default file names for indexes in the Hugging Face Hub.

Functions

Examples

WEIGHTS_NAME()
WEIGHTS_INDEX_NAME()

Downloads files from HuggingFace repositories

Description

Downloads files from HuggingFace repositories

Usage

hub_download(
  repo_id,
  filename,
  ...,
  revision = "main",
  repo_type = "model",
  local_files_only = FALSE,
  force_download = FALSE
)

Arguments

repo_id

The repository identifier, eg "bert-base-uncased" or "deepset/sentence_bert".

filename

Filename to download from the repository. Example "config.json".

...

currenytly unused.

revision

Revision (branch, tag or commitid) to download the file from.

repo_type

The type of the repository. Currently only "model" is supported.

local_files_only

Only use cached files?

force_download

For re-downloading of files that are cached.

Value

The file path of the downloaded or cached file. The snapshot path is returned as an attribute.

Examples

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

Description

Queries information about Hub repositories

Usage

hub_repo_info(
  repo_id,
  ...,
  repo_type = NULL,
  revision = NULL,
  files_metadata = FALSE
)

hub_dataset_info(repo_id, ..., revision = NULL, files_metadata = FALSE)

Arguments

repo_id

The repository identifier, eg "bert-base-uncased" or "deepset/sentence_bert".

...

currenytly unused.

repo_type

The type of the repository. Currently only "model" is supported.

revision

Revision (branch, tag or commitid) to download the file from.

files_metadata

Obtain files metadata information when querying repository information.

Value

A list with information about the repository, including model details, file siblings, tags, and other metadata returned by the Hugging Face API.

Functions

Examples

try({
info <- hub_repo_info("gpt2")
info$modelId
})

Snapshot the entire repository

Description

Downloads and stores all files from a Hugging Face Hub repository.

Usage

hub_snapshot(
  repo_id,
  ...,
  revision = "main",
  repo_type = "model",
  local_files_only = FALSE,
  force_download = FALSE,
  allow_patterns = NULL,
  ignore_patterns = NULL
)

Arguments

repo_id

The repository identifier, eg "bert-base-uncased" or "deepset/sentence_bert".

...

currenytly unused.

revision

Revision (branch, tag or commitid) to download the file from.

repo_type

The type of the repository. Currently only "model" is supported.

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.

Value

A string with the path to the snapshot directory containing all downloaded files.

Examples

try({
withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), {
path <- hub_snapshot("gpt2", allow_patterns = "config.json")
list.files(path)
})
})