pub struct AttentionModuleOptions {
pub scale: Option<f64>,
pub softcap: Option<f64>,
pub is_causal: bool,
}Expand description
Options for attention.
Fields§
§scale: Option<f64>Custom scale factor applied to QK^T. When None, defaults to 1/sqrt(head_dim).
softcap: Option<f64>Soft capping applied before softmax: softcap * tanh(scores / softcap).
Used by Gemma-2 and similar models. Must be positive when set.
is_causal: boolWhen true, applies causal (autoregressive) masking so that each query position
can only attend to key positions at or before it. This is more efficient than
passing an explicit lower-triangular bool mask because backends can use optimized
kernel paths (e.g. flash attention with causal mode).
Trait Implementations§
Source§impl Clone for AttentionModuleOptions
impl Clone for AttentionModuleOptions
Source§fn clone(&self) -> AttentionModuleOptions
fn clone(&self) -> AttentionModuleOptions
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 AttentionModuleOptions
impl Debug for AttentionModuleOptions
Source§impl Default for AttentionModuleOptions
impl Default for AttentionModuleOptions
Source§fn default() -> AttentionModuleOptions
fn default() -> AttentionModuleOptions
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for AttentionModuleOptions
impl<'de> Deserialize<'de> for AttentionModuleOptions
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AttentionModuleOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AttentionModuleOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AttentionModuleOptions
impl PartialEq for AttentionModuleOptions
Source§fn eq(&self, other: &AttentionModuleOptions) -> bool
fn eq(&self, other: &AttentionModuleOptions) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for AttentionModuleOptions
impl Serialize for AttentionModuleOptions
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for AttentionModuleOptions
impl StructuralPartialEq for AttentionModuleOptions
Auto Trait Implementations§
impl Freeze for AttentionModuleOptions
impl RefUnwindSafe for AttentionModuleOptions
impl Send for AttentionModuleOptions
impl Sync for AttentionModuleOptions
impl Unpin for AttentionModuleOptions
impl UnsafeUnpin for AttentionModuleOptions
impl UnwindSafe for AttentionModuleOptions
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