pub struct LoadedModel {
pub model: Box<dyn Module>,
pub tokenizer: Tokenizer,
pub device: Device,
pub dtype: DType,
pub adapter_layers: Option<AdapterLayers>,
pub trainable_params: VarMap,
}Expand description
Loaded model with configuration.
Fields§
§model: Box<dyn Module>Model weights and forward pass
tokenizer: TokenizerTokenizer
device: DeviceDevice where model is loaded
dtype: DTypeModel dtype
adapter_layers: Option<AdapterLayers>Adapter layers (if using LoRA/QLoRA)
trainable_params: VarMapTrainable parameters (LoRA weights)
Implementations§
Source§impl LoadedModel
impl LoadedModel
Sourcepub fn forward_with_adapters(
&self,
input_ids: &Tensor,
) -> Result<Tensor, AxolotlError>
pub fn forward_with_adapters( &self, input_ids: &Tensor, ) -> Result<Tensor, AxolotlError>
Run forward pass with adapter layers.
IMPORTANT: Current implementation does NOT properly integrate adapters. LoRA adapters need to be injected at each attention/MLP layer, not applied post-hoc to logits. This requires custom model architecture (LoraLlama).
For now, this returns base model output. Gradient flow is maintained through
the trainable LoRA parameters in trainable_params VarMap.
§Errors
Returns an error if the forward pass fails.
Sourcepub fn trainable_tensors(&self) -> Vec<Var>
pub fn trainable_tensors(&self) -> Vec<Var>
Get trainable parameters for optimizer.
Returns only the LoRA A/B matrices, not the frozen base model weights.
Sourcepub fn trainable_param_count(&self) -> usize
pub fn trainable_param_count(&self) -> usize
Count trainable parameters.
Auto Trait Implementations§
impl !Freeze for LoadedModel
impl !RefUnwindSafe for LoadedModel
impl !Send for LoadedModel
impl !Sync for LoadedModel
impl Unpin for LoadedModel
impl !UnwindSafe for LoadedModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more