pub struct SlidingWindowConfig {
pub d_model: usize,
pub n_heads: usize,
pub window_size: usize,
pub d_k: usize,
pub causal: bool,
pub dropout: f64,
}Expand description
Configuration for Sliding Window Attention
Fields§
§d_model: usizeModel dimension
n_heads: usizeNumber of attention heads
window_size: usizeWindow size (positions attended to)
d_k: usizeDimension per head
causal: boolWhether to use causal masking
dropout: f64Dropout probability
Implementations§
Source§impl SlidingWindowConfig
impl SlidingWindowConfig
Sourcepub fn new(d_model: usize, n_heads: usize, window_size: usize) -> Result<Self>
pub fn new(d_model: usize, n_heads: usize, window_size: usize) -> Result<Self>
Create a new Sliding Window Attention configuration
Sourcepub fn with_causal(self, causal: bool) -> Self
pub fn with_causal(self, causal: bool) -> Self
Enable causal masking
Sourcepub fn with_dropout(self, dropout: f64) -> Self
pub fn with_dropout(self, dropout: f64) -> Self
Set dropout probability
Sourcepub fn complexity_reduction(&self, seq_len: usize) -> f64
pub fn complexity_reduction(&self, seq_len: usize) -> f64
Calculate complexity reduction compared to full attention
Sourcepub fn memory_reduction(&self, seq_len: usize) -> f64
pub fn memory_reduction(&self, seq_len: usize) -> f64
Calculate memory reduction compared to full attention
Trait Implementations§
Source§impl Clone for SlidingWindowConfig
impl Clone for SlidingWindowConfig
Source§fn clone(&self) -> SlidingWindowConfig
fn clone(&self) -> SlidingWindowConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SlidingWindowConfig
impl RefUnwindSafe for SlidingWindowConfig
impl Send for SlidingWindowConfig
impl Sync for SlidingWindowConfig
impl Unpin for SlidingWindowConfig
impl UnwindSafe for SlidingWindowConfig
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