pub struct DistillationConfig {
pub temperature: f32,
pub alpha: f32,
pub num_teachers: usize,
pub student: StudentConfig,
pub training: DistillTrainingConfig,
pub output_dir: PathBuf,
}Expand description
Configuration for knowledge distillation training
Implements multi-teacher distillation via temperature-scaled KL divergence (Hinton et al. 2015). The loss function is:
L_distill = α * KL(softmax(z_s/T) || softmax(z_t/T)) + (1-α) * L_CEWhere:
Tis the temperature (higher = softer distributions)αis the balance between distillation and cross-entropy lossz_sandz_tare student and teacher logits
Fields§
§temperature: f32Temperature for softmax (higher = softer probabilities) Typical values: 1.0-10.0. Default: 3.0
alpha: f32Balance between distillation loss and CE loss α=1.0 means pure distillation, α=0.0 means pure CE Typical values: 0.5-0.9. Default: 0.7
num_teachers: usizeNumber of teacher models for ensemble distillation
student: StudentConfigStudent model configuration
training: DistillTrainingConfigTraining hyperparameters
output_dir: PathBufOutput directory for distilled model
Implementations§
Source§impl DistillationConfig
impl DistillationConfig
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Builder: set temperature
Sourcepub fn with_alpha(self, alpha: f32) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
Builder: set alpha (distillation weight)
Sourcepub fn with_teachers(self, num_teachers: usize) -> Self
pub fn with_teachers(self, num_teachers: usize) -> Self
Builder: set number of teachers
Sourcepub fn with_student(self, student: StudentConfig) -> Self
pub fn with_student(self, student: StudentConfig) -> Self
Builder: set student config
Sourcepub fn with_training(self, training: DistillTrainingConfig) -> Self
pub fn with_training(self, training: DistillTrainingConfig) -> Self
Builder: set training config
Sourcepub fn with_output_dir(self, output_dir: impl Into<PathBuf>) -> Self
pub fn with_output_dir(self, output_dir: impl Into<PathBuf>) -> Self
Builder: set output directory
Sourcepub fn run_placeholder(&self) -> DistillationResult
pub fn run_placeholder(&self) -> DistillationResult
Run placeholder distillation (simulates training)
Full distillation requires entrenar LLM feature and teacher model weights. This returns a placeholder result for testing the pipeline.
Trait Implementations§
Source§impl Clone for DistillationConfig
impl Clone for DistillationConfig
Source§fn clone(&self) -> DistillationConfig
fn clone(&self) -> DistillationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DistillationConfig
impl Debug for DistillationConfig
Source§impl Default for DistillationConfig
impl Default for DistillationConfig
Source§impl<'de> Deserialize<'de> for DistillationConfig
impl<'de> Deserialize<'de> for DistillationConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for DistillationConfig
impl RefUnwindSafe for DistillationConfig
impl Send for DistillationConfig
impl Sync for DistillationConfig
impl Unpin for DistillationConfig
impl UnsafeUnpin for DistillationConfig
impl UnwindSafe for DistillationConfig
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> 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>
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