pub struct HeadAnalysis {
pub model_id: String,
pub num_heads: usize,
pub num_layers: usize,
pub heads: Vec<HeadImportance>,
pub category_mapping: CategoryMapping,
pub prune_threshold: f32,
pub metadata: AnalysisMetadata,
}Expand description
Complete analysis of all attention heads
Fields§
§model_id: StringModel identifier
num_heads: usizeNumber of heads per layer
num_layers: usizeNumber of layers
heads: Vec<HeadImportance>Per-head importance data
category_mapping: CategoryMappingCategory mapping derived from analysis
prune_threshold: f32Global importance threshold for pruning
metadata: AnalysisMetadataAnalysis metadata
Implementations§
Source§impl HeadAnalysis
impl HeadAnalysis
Sourcepub fn get_importance(
&self,
layer: usize,
head: usize,
) -> Option<&HeadImportance>
pub fn get_importance( &self, layer: usize, head: usize, ) -> Option<&HeadImportance>
Get importance for a specific head
Sourcepub fn important_heads(&self, threshold: f32) -> Vec<&HeadImportance>
pub fn important_heads(&self, threshold: f32) -> Vec<&HeadImportance>
Get all heads above importance threshold
Sourcepub fn heads_by_category(&self, category: HeadCategory) -> Vec<&HeadImportance>
pub fn heads_by_category(&self, category: HeadCategory) -> Vec<&HeadImportance>
Get heads by category
Sourcepub fn layer_importance(&self) -> Vec<f32>
pub fn layer_importance(&self) -> Vec<f32>
Get layer-wise importance distribution
Sourcepub fn suggested_sparsity(&self, target_overall: f32) -> Vec<f32>
pub fn suggested_sparsity(&self, target_overall: f32) -> Vec<f32>
Suggest optimal sparsity per layer based on importance
Trait Implementations§
Source§impl Clone for HeadAnalysis
impl Clone for HeadAnalysis
Source§fn clone(&self) -> HeadAnalysis
fn clone(&self) -> HeadAnalysis
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 HeadAnalysis
impl Debug for HeadAnalysis
Source§impl<'de> Deserialize<'de> for HeadAnalysis
impl<'de> Deserialize<'de> for HeadAnalysis
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HeadAnalysis
impl RefUnwindSafe for HeadAnalysis
impl Send for HeadAnalysis
impl Sync for HeadAnalysis
impl Unpin for HeadAnalysis
impl UnsafeUnpin for HeadAnalysis
impl UnwindSafe for HeadAnalysis
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