HuggingFaceApi

Documentation for HuggingFaceApi.

HuggingFaceApi.cached_downloadMethod
cached_download(
    hgfurl :: HuggingFaceURL;
    local_files_only :: Bool = false,
    auth_token :: Union{AbstractString, Nothing} = nothing,
)

Find the local cache of given url or do downloading. If local_files_only is set, it will try to find the file from cache, and error out when not found. For downloading from private repo, auth_token need to be set, or do HuggingFaceApi.login() beforehand.

See also: HuggingFaceURL, login

source
HuggingFaceApi.hf_hub_downloadMethod
hf_hub_download(
    repo_id :: AbstractString,
    filename :: AbstractString;
    repo_type = nothing,
    revision = "main",
    auth_token :: Union{AbstractString, Nothing} = get_token(),
    local_files_only :: Bool  = false,
    cache :: Bool = true,
)

Construct HuggingFaceURL and do cached_download. If cache is false, download file to the temp dir with name generated by tempname(). If local_files_only is set, cache must set.

source
HuggingFaceApi.list_datasetsFunction
list_datasets(token = get_token();
              search = nothing, author = nothing, filter = nothing,
              sort = nothing, direction = nothing, limit = nothing,
              full::Bool = false, cardData::Bool = false)

Get information from all datasets in the Hub. You can specify additional parameters to have more specific results.

  • search: Filter based on substrings for repos and their usernames, such as pets or microsoft
  • author: Filter datasets by an other or organization, such as huggingface or microsoft
  • filter: Filter based on tags, such as task_categories:text-classification or languages:en.
  • sort: Property to use when sorting, such as downloads or author.
  • direction: Direction in which to sort, such as -1 for descending, and anything else for ascending.
  • limit: Limit the number of datasets fetched.
  • full: Whether to fetch most dataset data, such as all tags, the files, etc.
  • cardData: Whether to grab the metadata for the dataset as well. Can contain useful information such as the PapersWithCode ID.
source
HuggingFaceApi.list_modelsFunction
list_models(token = get_token();
            search = nothing, author = nothing, filter = nothing,
            sort = nothing, direction = nothing, limit = nothing,
            full::Bool = !isnothing(filter), cardData::Bool = false)

Get information from all models in the Hub. You can specify additional parameters to have more specific results.

  • search: Filter based on substrings for repos and their usernames, such as resnet or microsoft
  • author: Filter models by an author or organization, such as huggingface or microsoft
  • filter: Filter based on tags, such as text-classification or spacy.
  • sort: Property to use when sorting, such as downloads or author.
  • direction: Direction in which to sort, such as -1 for descending, and anything else for ascending.
  • limit: Limit the number of models fetched.
  • full: Whether to fetch most model data, such as all tags, the files, etc.
  • cardData: Whether to grab the metadata for the model as well, such as carbon emissions, metrics, and datasets trained on.
source
HuggingFaceApi.list_spacesFunction
list_spaces(token = get_token();
           search = nothing, author = nothing, filter = nothing,
           datasets = nothing, models = nothing, linked::Bool = false,
           sort = nothing, direction = nothing, limit = nothing,
           full::Bool = false)

Get information from all Spaces in the Hub. You can specify additional parameters to have more specific results.

  • search: Filter based on substrings for repos and their usernames, such as resnet or microsoft
  • author: Filter models by an author or organization, such as huggingface or microsoft
  • filter: Filter based on tags, such as text-classification or spacy.
  • sort: Property to use when sorting, such as downloads or author.
  • direction: Direction in which to sort, such as -1 for descending, and anything else for ascending.
  • limit: Limit the number of models fetched.
  • full: Whether to fetch most model data, such as all tags, the files, etc.
  • datasets: Whether to return Spaces that make use of a dataset. The name of a specific dataset can be passed as a string.
  • models: Whether to return Spaces that make use of a model. The name of a specific model can be passed as a string.
  • linked: Whether to return Spaces that make use of either a model or a dataset.
source
HuggingFaceApi.loginMethod
login(user::AbstractString = readline())

Login to huggingface hub and get/save the account token for operations that need authentication. Re-run this function with username (i.e. login(username)) if token expired.

source
HuggingFaceApi.remove_cacheMethod
remove_cache(repo_id::AbstractString; repo_type = nothing, revision = "main", now = false)

Remove all cached files of a given repo. If now is set to true, cache file will be deleted immediately, otherwise waiting OhMyArtifacts to do the garbage collection.

source
HuggingFaceApi.remove_cacheMethod
remove_cache(hgfurl::HuggingFaceURL; now = false)

Remove files link to the given url. If now is set to true, cache file will be deleted immediately, otherwise waiting OhMyArtifacts to do the garbage collection.

source
HuggingFaceApi.remove_cacheMethod
remove_cache(; now=false)

Remove all cached files. If now is set to true, cache file will be deleted immediately, otherwise waiting OhMyArtifacts to do the garbage collection.

source