Skip to main content

FerrotensorHub

Struct FerrotensorHub 

Source
pub struct FerrotensorHub { /* private fields */ }
Expand description

Main entry point for loading models from HuggingFace Hub.

Currently supports loading from local directories. Download models using huggingface-cli download or the Python huggingface_hub library.

§Example

let hub = FerrotensorHub::new();
let config = hub.load_config("meta-llama/Llama-3.2-1B")?;
println!("Model has {} layers", config.num_hidden_layers);

Implementations§

Source§

impl FerrotensorHub

Source

pub fn new() -> Self

Create a new FerrotensorHub instance with default cache directory.

Default cache: ~/.cache/huggingface/hub/models--{org}--{model}

Source

pub fn with_cache_dir(cache_dir: PathBuf) -> Self

Create a FerrotensorHub with a custom cache directory.

Source

pub fn get_model_path(&self, model_id: &str) -> PathBuf

Get the path to a cached model.

Compatible with HuggingFace cache format.

Source

pub fn find_latest_snapshot(&self, model_id: &str) -> HubResult<PathBuf>

Find the latest snapshot of a model.

Source

pub fn load_config(&self, model_id: &str) -> HubResult<ModelConfig>

Load model configuration.

Source

pub fn is_cached(&self, model_id: &str) -> bool

Check if a model is cached locally.

Source

pub fn list_cached(&self) -> Vec<String>

List all cached models.

Source

pub fn get_weight_files(&self, model_id: &str) -> HubResult<Vec<PathBuf>>

Get safetensors file paths for a model.

Trait Implementations§

Source§

impl Default for FerrotensorHub

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.