pub struct RecursiveConfig {Show 39 fields
pub vocab_size: usize,
pub hidden_size: usize,
pub intermediate_size: usize,
pub num_attention_heads: usize,
pub num_key_value_heads: Option<usize>,
pub hidden_act: String,
pub max_position_embeddings: usize,
pub initializer_range: f32,
pub layer_norm_eps: f32,
pub use_cache: bool,
pub pad_token_id: Option<u32>,
pub bos_token_id: u32,
pub eos_token_id: u32,
pub num_recursive_layers: usize,
pub recursion_depth: usize,
pub chunk_size: usize,
pub overlap_size: usize,
pub use_adaptive_depth: bool,
pub min_depth: usize,
pub max_depth: usize,
pub depth_threshold: f32,
pub memory_size: usize,
pub use_memory_compression: bool,
pub compression_ratio: f32,
pub memory_update_strategy: String,
pub use_hierarchical_attention: bool,
pub hierarchy_levels: usize,
pub level_compression_ratios: Vec<f32>,
pub cross_level_attention: bool,
pub use_universal_transformer: bool,
pub max_steps: usize,
pub adaptive_computation_time: bool,
pub act_threshold: f32,
pub act_loss_weight: f32,
pub use_gradient_checkpointing: bool,
pub use_flash_attention: bool,
pub dropout: f32,
pub attention_dropout: f32,
pub model_type: String,
}Expand description
Recursive Transformer configuration Reference: “Recursive Transformers for Long Sequences” (Universal Transformers, PaLM)
Fields§
§vocab_size: usize§intermediate_size: usize§num_attention_heads: usize§num_key_value_heads: Option<usize>§max_position_embeddings: usize§initializer_range: f32§layer_norm_eps: f32§use_cache: bool§pad_token_id: Option<u32>§bos_token_id: u32§eos_token_id: u32§num_recursive_layers: usize§recursion_depth: usize§chunk_size: usize§overlap_size: usize§use_adaptive_depth: bool§min_depth: usize§max_depth: usize§depth_threshold: f32§memory_size: usize§use_memory_compression: bool§compression_ratio: f32§memory_update_strategy: String§use_hierarchical_attention: bool§hierarchy_levels: usize§level_compression_ratios: Vec<f32>§cross_level_attention: bool§use_universal_transformer: bool§max_steps: usize§adaptive_computation_time: bool§act_threshold: f32§act_loss_weight: f32§use_gradient_checkpointing: bool§use_flash_attention: bool§dropout: f32§attention_dropout: f32§model_type: StringImplementations§
Source§impl RecursiveConfig
impl RecursiveConfig
Sourcepub fn long_document() -> Self
pub fn long_document() -> Self
Create a recursive transformer for long documents
Sourcepub fn memory_efficient() -> Self
pub fn memory_efficient() -> Self
Create a memory-efficient recursive transformer
Sourcepub fn hierarchical() -> Self
pub fn hierarchical() -> Self
Create a hierarchical recursive transformer
Sourcepub fn code_understanding() -> Self
pub fn code_understanding() -> Self
Create configuration for code understanding
Sourcepub fn num_kv_heads(&self) -> usize
pub fn num_kv_heads(&self) -> usize
Get the number of key-value heads
Sourcepub fn effective_chunk_size(&self) -> usize
pub fn effective_chunk_size(&self) -> usize
Get effective sequence length per chunk
Sourcepub fn total_memory_capacity(&self) -> usize
pub fn total_memory_capacity(&self) -> usize
Get total memory capacity across all levels
Sourcepub fn from_pretrained_name(name: &str) -> Option<Self>
pub fn from_pretrained_name(name: &str) -> Option<Self>
Create configuration from pretrained model name
Sourcepub fn with_memory(
&mut self,
size: usize,
compression: bool,
ratio: f32,
) -> &mut Self
pub fn with_memory( &mut self, size: usize, compression: bool, ratio: f32, ) -> &mut Self
Configure memory settings
Sourcepub fn with_chunks(
&mut self,
chunk_size: usize,
overlap_size: usize,
) -> &mut Self
pub fn with_chunks( &mut self, chunk_size: usize, overlap_size: usize, ) -> &mut Self
Configure chunking settings
Sourcepub fn with_depth(&mut self, depth: usize, adaptive: bool) -> &mut Self
pub fn with_depth(&mut self, depth: usize, adaptive: bool) -> &mut Self
Configure recursion depth
Sourcepub fn with_hierarchy(&mut self, levels: usize, ratios: Vec<f32>) -> &mut Self
pub fn with_hierarchy(&mut self, levels: usize, ratios: Vec<f32>) -> &mut Self
Configure hierarchical attention
Sourcepub fn with_universal(&mut self, max_steps: usize, act: bool) -> &mut Self
pub fn with_universal(&mut self, max_steps: usize, act: bool) -> &mut Self
Configure Universal Transformer settings
Trait Implementations§
Source§impl Clone for RecursiveConfig
impl Clone for RecursiveConfig
Source§impl Config for RecursiveConfig
impl Config for RecursiveConfig
Source§impl Debug for RecursiveConfig
impl Debug for RecursiveConfig
Source§impl Default for RecursiveConfig
impl Default for RecursiveConfig
Source§impl<'de> Deserialize<'de> for RecursiveConfig
impl<'de> Deserialize<'de> for RecursiveConfig
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 RecursiveConfig
impl RefUnwindSafe for RecursiveConfig
impl Send for RecursiveConfig
impl Sync for RecursiveConfig
impl Unpin for RecursiveConfig
impl UnsafeUnpin for RecursiveConfig
impl UnwindSafe for RecursiveConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ConfigSerializable for Twhere
T: Serialize + for<'de> Deserialize<'de>,
impl<T> ConfigSerializable for Twhere
T: Serialize + for<'de> Deserialize<'de>,
Source§fn save_to_file(&self, path: &Path) -> Result<(), TrustformersError>
fn save_to_file(&self, path: &Path) -> Result<(), TrustformersError>
Save to file
Source§fn load_from_file(path: &Path) -> Result<Self, TrustformersError>where
Self: Sized,
fn load_from_file(path: &Path) -> Result<Self, TrustformersError>where
Self: Sized,
Load from file
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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