Struct Loader

Source
pub struct Loader<Hp: Hyperparameters, F: FnMut(LoadProgress)> {
    pub container_type: ContainerType,
    pub hyperparameters: Hp,
    pub vocabulary: Vocabulary,
    pub tensors: HashMap<String, TensorLoadInfo>,
    /* private fields */
}
Expand description

A GGML format loader for LLMs.

Fields§

§container_type: ContainerType

The container type of the model.

§hyperparameters: Hp

The hyperparameters of the model.

§vocabulary: Vocabulary

The vocabulary of the model.

§tensors: HashMap<String, TensorLoadInfo>

The tensors of the model.

Implementations§

Source§

impl<Hp: Hyperparameters, F: FnMut(LoadProgress)> Loader<Hp, F>

Source

pub fn new(load_progress_callback: F) -> Self

Creates a new loader.

Trait Implementations§

Source§

impl<Hp: Hyperparameters, F: FnMut(LoadProgress)> LoadHandler<LoadError> for Loader<Hp, F>

Source§

fn container_type( &mut self, container_type: ContainerType, ) -> Result<(), LoadError>

Called when the ContainerType is read.
Source§

fn vocabulary_token( &mut self, i: usize, token: Vec<u8>, score: f32, ) -> Result<(), LoadError>

Called when a token is read so it can be added to the model’s vocabulary.
Source§

fn read_hyperparameters( &mut self, reader: &mut dyn BufRead, ) -> Result<PartialHyperparameters, LoadError>

Called when the model’s hyperparameters need to be read.
Source§

fn tensor_buffer(&mut self, info: TensorLoadInfo) -> Result<(), LoadError>

Called when a new crate::Tensor is read for the model.

Auto Trait Implementations§

§

impl<Hp, F> Freeze for Loader<Hp, F>
where F: Freeze, Hp: Freeze,

§

impl<Hp, F> RefUnwindSafe for Loader<Hp, F>

§

impl<Hp, F> Send for Loader<Hp, F>
where F: Send, Hp: Send,

§

impl<Hp, F> Sync for Loader<Hp, F>
where F: Sync, Hp: Sync,

§

impl<Hp, F> Unpin for Loader<Hp, F>
where F: Unpin, Hp: Unpin,

§

impl<Hp, F> UnwindSafe for Loader<Hp, F>
where F: UnwindSafe, Hp: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V