Skip to main content

Crate hf_fetch_model

Crate hf_fetch_model 

Source
Expand description

§hf-fetch-model

Fast HuggingFace model downloads for Rust.

An embeddable library for downloading HuggingFace model repositories with maximum throughput. Wraps hf_hub and adds repo-level orchestration.

§Quick Start

let outcome = hf_fetch_model::download("julien-c/dummy-unknown".to_owned()).await?;
println!("Model at: {}", outcome.inner().display());

§Configured Download

use hf_fetch_model::FetchConfig;

let config = FetchConfig::builder()
    .filter("*.safetensors")
    .filter("*.json")
    .on_progress(|e| {
        println!("{}: {:.1}%", e.filename, e.percent);
    })
    .build()?;

let outcome = hf_fetch_model::download_with_config(
    "google/gemma-2-2b".to_owned(),
    &config,
).await?;
// outcome.is_cached() tells you if it came from local cache
let path = outcome.into_inner();

§HuggingFace Cache

Downloaded files are stored in the standard HuggingFace cache directory (~/.cache/huggingface/hub/), ensuring compatibility with Python tooling.

§Authentication

Set the HF_TOKEN environment variable to access private or gated models, or use FetchConfig::builder().token().

Re-exports§

pub use config::FetchConfig;
pub use config::FetchConfigBuilder;
pub use config::Filter;
pub use download::DownloadOutcome;
pub use error::FetchError;
pub use error::FileFailure;
pub use progress::ProgressEvent;

Modules§

cache
HuggingFace cache directory resolution and local model family scanning.
checksum
SHA256 checksum verification for downloaded files.
config
Configuration for model downloads.
discover
Model family discovery via the HuggingFace Hub API.
download
Download orchestration for HuggingFace model repositories.
error
Error types for hf-fetch-model.
progress
Progress reporting for model downloads.
repo
Repository file listing via the HuggingFace API.

Functions§

download
Downloads all files from a HuggingFace model repository.
download_blocking
Blocking version of download() for non-async callers.
download_file
Downloads a single file from a HuggingFace model repository.
download_file_blocking
Blocking version of download_file() for non-async callers.
download_files
Downloads all files from a HuggingFace model repository and returns a filename → path map.
download_files_blocking
Blocking version of download_files() for non-async callers.
download_files_with_config
Downloads files from a HuggingFace model repository using the given configuration and returns a filename → path map.
download_files_with_config_blocking
Blocking version of download_files_with_config() for non-async callers.
download_with_config
Downloads files from a HuggingFace model repository using the given configuration.
download_with_config_blocking
Blocking version of download_with_config() for non-async callers.