Package 'hfhub'

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: Daniel Falbel [aut, cre], Regouby Christophe [ctb], Posit [cph]
Maintainer: Daniel Falbel <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1.9000
Built: 2024-11-16 05:50:57 UTC
Source: https://github.com/mlverse/hfhub

Help Index


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.

Functions

  • hub_dataset_info(): Query information from a Hub Dataset


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.


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

  • WEIGHTS_NAME(): Name of weights file

  • WEIGHTS_INDEX_NAME(): Name of weights index file

Examples

WEIGHTS_NAME()
WEIGHTS_INDEX_NAME()