Skip to main content

ModelSource

Trait ModelSource 

Source
pub trait ModelSource {
    // Required methods
    fn config(&self) -> &ModelConfig;
    fn config_mut(&mut self) -> &mut ModelConfig;
    fn architecture(&self) -> Architecture;
    fn load_tensor(&self, name: &str) -> ModelResult<Tensor>;
    fn try_load_tensor(&self, name: &str) -> Option<Tensor>;
}
Expand description

Trait for model weight sources (GGUF, ONNX, SafeTensors).

Implementors provide tensor loading and config access. The shared model assembly functions use this trait to load weights from any supported format.

Required Methods§

Source

fn config(&self) -> &ModelConfig

Get parsed model configuration.

Source

fn config_mut(&mut self) -> &mut ModelConfig

Get mutable reference to model configuration.

Source

fn architecture(&self) -> Architecture

Get detected architecture.

Source

fn load_tensor(&self, name: &str) -> ModelResult<Tensor>

Load a tensor by internal name (e.g., “blk.0.attn_q.weight”).

Source

fn try_load_tensor(&self, name: &str) -> Option<Tensor>

Try to load a tensor (None if not found).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§