pub struct LoraMapper { /* private fields */ }Expand description
A module mapper that attaches LoRA adapters to 2-D weight parameters.
Apply it the same way as quantization:
ⓘ
let model = model.map(&mut LoraMapper::new(LoraConfig::new(8, 16.0)));Each rank-2 float weight is frozen and given a trainable low-rank adapter; other
parameters are left untouched. No model or layer code needs to change — the same Linear (and
any other module) keeps working, now producing base + scale * (a @ b) for adapted weights.
Implementations§
Source§impl LoraMapper
impl LoraMapper
Sourcepub fn new(config: LoraConfig) -> Self
pub fn new(config: LoraConfig) -> Self
Create a new mapper from the given configuration.
Sourcepub fn for_group(self, group: ParamGroup) -> Self
pub fn for_group(self, group: ParamGroup) -> Self
Specify a parameter group on which to apply the LoRA.
Trait Implementations§
Source§impl Clone for LoraMapper
impl Clone for LoraMapper
Source§fn clone(&self) -> LoraMapper
fn clone(&self) -> LoraMapper
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LoraMapper
impl Debug for LoraMapper
Source§impl ModuleMapper for LoraMapper
impl ModuleMapper for LoraMapper
Source§fn enter_module(&mut self, name: &str, _container_type: &str)
fn enter_module(&mut self, name: &str, _container_type: &str)
Called when entering a submodule. Read more
Source§fn exit_module(&mut self, _name: &str, _container_type: &str)
fn exit_module(&mut self, _name: &str, _container_type: &str)
Called when exiting a submodule. Read more
Source§fn map_float<const D: usize>(
&mut self,
param: Param<Tensor<D>>,
) -> Param<Tensor<D>>
fn map_float<const D: usize>( &mut self, param: Param<Tensor<D>>, ) -> Param<Tensor<D>>
Map a float parameter in the module. Read more
Auto Trait Implementations§
impl Freeze for LoraMapper
impl RefUnwindSafe for LoraMapper
impl Send for LoraMapper
impl Sync for LoraMapper
impl Unpin for LoraMapper
impl UnsafeUnpin for LoraMapper
impl UnwindSafe for LoraMapper
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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