Expand description
§models-cat
models-cat is an unofficial Rust client for ModelScope Hub, inspired by hf-hub. Born from a simple need: “To build a Rust desktop app requiring model/dataset downloads with no suitable Rust client.”
When to use models-cat for model downloads? Three main scenarios:
- Network restrictions prevent accessing huggingface via hf-hub.
- While hf-hub can download from hf-mirror, stability and download speeds aren’t guaranteed.
- Hosting models on ModelScope Hub ensures stability and speed, but hf-hub isn’t compatible with ModelScope - models-cat is required.
§Features
- Model/dataset download & cache management, synchronous & asynchronous
- Concurrent safe file access
- Local cache validation (SHA256)
- Download progress callback
§Usage
Sync download:
use models_cat::{download_model_with_progress, ProgressBarWrapper};
download_model_with_progress(
"BAAI/bge-small-zh-v1.5",
"model.safetensors",
ProgressBarWrapper::default(),
).unwrap();
Note: The filename including extension and parent directory, such as model.safetensors
or safetensors/model.safetensors
.
Async download:
use models_cat::asynchronous::{download_model_with_progress, ProgressBarWrapper};
download_model_with_progress(
"BAAI/bge-small-zh-v1.5",
"model.safetensors",
ProgressBarWrapper::default(),
).await.unwrap();
Asynchronous download requires enabling the tokio feature:
model-cat = { version = "*", features = ["tokio"] }
Download models from ModelScope hosted repositories like BAAI/bge-small-zh-v1.5 to local storage,default cache path is [HOME_DIR].cache/modelscope/hub/models--BAAI--bge-small-zh-v1.5/
.
When using shortcut functions, you can set the local cache path via the environment variable MODELS_CAT_CACHE_DIR
. Alternatively, you can use ModelsCat
and pass the local cache path during initialization.
Re-exports§
pub use hub::ModelsCat;
pub use hub::MultiProgressWrapper;
pub use hub::Progress;
pub use hub::ProgressBarWrapper;
pub use hub::ProgressUnit;
pub use repo::Repo;
pub use repo::RepoType;
pub use utils::OpsError;
Modules§
- hub
- This module provides functionality for interacting with a remote hub, primarily focused on downloading, managing, and listing files from repositories. It includes both synchronous and asynchronous operations, depending on the feature flags enabled.
- repo
- The representation of a repo on the hub.
- utils
- Some utility
Functions§
- download_
dataset - Shortcut for downloading a dataset
- download_
dataset_ with_ progress - Shortcut for downloading a dataset with progress
- download_
model - Shortcut for downloading a model
- download_
model_ with_ progress - Shortcut for downloading a model with progress
The filename including extension and parent directory, such as
models.gguf
orgguf/models.gguf
. - pull_
dataset - Shortcut pulling a dataset repo
- pull_
model - Shortcut pulling a model repo
- remove_
dataset_ file - Shortcut removing a local dataset file
- remove_
dataset_ repo - Shortcut removing a local dataset repo
- remove_
model_ file - Shortcut removing a local model file
- remove_
model_ repo - Shortcut removing a local model repo