pub struct PrefixTuning { /* private fields */ }Expand description
Prefix Tuning implementation
Implementations§
Source§impl PrefixTuning
impl PrefixTuning
Sourcepub fn new(config: PrefixTuningConfig) -> Result<Self, String>
pub fn new(config: PrefixTuningConfig) -> Result<Self, String>
Create new prefix tuning
Sourcepub fn get_layer_prefix(&self, layer_idx: usize) -> Option<&LayerPrefix>
pub fn get_layer_prefix(&self, layer_idx: usize) -> Option<&LayerPrefix>
Get prefix for a specific layer
Sourcepub fn prepend_to_kv(
&self,
layer_idx: usize,
key: &Tensor,
value: &Tensor,
) -> Result<(Tensor, Tensor), String>
pub fn prepend_to_kv( &self, layer_idx: usize, key: &Tensor, value: &Tensor, ) -> Result<(Tensor, Tensor), String>
Prepend prefix to key/value in attention
Sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Get number of trainable parameters
Sourcepub fn parameter_efficiency(&self, total_model_params: usize) -> f32
pub fn parameter_efficiency(&self, total_model_params: usize) -> f32
Get parameter efficiency ratio
Auto Trait Implementations§
impl Freeze for PrefixTuning
impl !RefUnwindSafe for PrefixTuning
impl Send for PrefixTuning
impl Sync for PrefixTuning
impl Unpin for PrefixTuning
impl !UnwindSafe for PrefixTuning
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
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