pub struct TitansPredictor { /* private fields */ }Expand description
Titans-based message predictor with Neural Long-Term Memory
Unlike standard Transformers with fixed context windows, Titans maintains persistent memory that survives across sequences through surprise-gated test-time training. This enables:
- Unbounded context: Memory consolidates patterns indefinitely
- Anomaly detection: High surprise indicates novel/malicious messages
- Adaptive prediction: Memory updates based on prediction errors
Implementations§
Source§impl TitansPredictor
impl TitansPredictor
pub fn new(config: TitansConfig) -> Self
Sourcepub fn observe(&mut self, message: &[u8])
pub fn observe(&mut self, message: &[u8])
Add a message to the context for prediction (triggers test-time training)
Sourcepub fn predict_next(&mut self) -> (u8, f32)
pub fn predict_next(&mut self) -> (u8, f32)
Predict the next byte
Sourcepub fn predict_sequence(&mut self, length: usize, greedy: bool) -> Vec<u8> ⓘ
pub fn predict_sequence(&mut self, length: usize, greedy: bool) -> Vec<u8> ⓘ
Predict multiple bytes autoregressively
Sourcepub fn verify_prediction(&mut self, message: &[u8]) -> (bool, f32)
pub fn verify_prediction(&mut self, message: &[u8]) -> (bool, f32)
Check if a message matches prediction
Sourcepub fn get_surprise(&self) -> f32
pub fn get_surprise(&self) -> f32
Get accumulated surprise (anomaly score) High values indicate unexpected/novel message patterns
Sourcepub fn is_anomalous(&self, threshold: f32) -> bool
pub fn is_anomalous(&self, threshold: f32) -> bool
Check if current message pattern is anomalous
Sourcepub fn set_temperature(&mut self, temp: f32)
pub fn set_temperature(&mut self, temp: f32)
Set temperature for sampling
Trait Implementations§
Source§impl Clone for TitansPredictor
impl Clone for TitansPredictor
Source§fn clone(&self) -> TitansPredictor
fn clone(&self) -> TitansPredictor
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 TitansPredictor
impl Debug for TitansPredictor
Source§impl<'de> Deserialize<'de> for TitansPredictor
impl<'de> Deserialize<'de> for TitansPredictor
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 TitansPredictor
impl RefUnwindSafe for TitansPredictor
impl Send for TitansPredictor
impl Sync for TitansPredictor
impl Unpin for TitansPredictor
impl UnsafeUnpin for TitansPredictor
impl UnwindSafe for TitansPredictor
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