pub struct QuantumMemorySystem { /* private fields */ }Expand description
Quantum memory system
Implementations§
Source§impl QuantumMemorySystem
impl QuantumMemorySystem
Sourcepub fn new(config: QuantumMemoryConfig) -> Result<Self>
pub fn new(config: QuantumMemoryConfig) -> Result<Self>
Create new quantum memory system
Examples found in repository?
examples/quantum_llm.rs (line 167)
154fn quantum_memory_demo() -> Result<()> {
155 println!(" Testing quantum memory systems...");
156
157 // Test different memory configurations
158 let memory_configs = vec![
159 ("Basic Associative", QuantumMemoryConfig::default()),
160 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
161 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
162 ];
163
164 for (name, config) in memory_configs {
165 println!("\n --- {} Memory ---", name);
166
167 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
168 println!(" Memory configuration:");
169 println!(" - Memory size: {}", config.memory_size);
170 println!(" - Associative memory: {}", config.associative_memory);
171 println!(" - Episodic memory: {}", config.episodic_memory);
172 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
173 println!(" - Quantum compression: {}", config.quantum_compression);
174
175 // Test memory storage and retrieval
176 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
177 0.1 * (b as f64 + s as f64 * 0.1 + d as f64 * 0.01)
178 });
179
180 // Enhance embeddings with memory
181 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
182 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
183
184 // Measure memory enhancement effect
185 let original_variance = test_embeddings.var(0.0);
186 let enhanced_variance = enhanced.var(0.0);
187 let enhancement_factor = enhanced_variance / original_variance;
188
189 println!(" Memory enhancement factor: {:.3}", enhancement_factor);
190
191 // Test memory update
192 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
193 memory_system.update_memory(&enhanced, &input_ids)?;
194
195 println!(" Memory updated with new experiences");
196
197 // Test memory retrieval patterns
198 test_memory_patterns(&memory_system, &config)?;
199 }
200
201 Ok(())
202}Sourcepub fn enhance_embeddings(
&self,
embeddings: &Array3<f64>,
) -> Result<Array3<f64>>
pub fn enhance_embeddings( &self, embeddings: &Array3<f64>, ) -> Result<Array3<f64>>
Enhance embeddings with memory retrieval
Examples found in repository?
examples/quantum_llm.rs (line 181)
154fn quantum_memory_demo() -> Result<()> {
155 println!(" Testing quantum memory systems...");
156
157 // Test different memory configurations
158 let memory_configs = vec![
159 ("Basic Associative", QuantumMemoryConfig::default()),
160 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
161 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
162 ];
163
164 for (name, config) in memory_configs {
165 println!("\n --- {} Memory ---", name);
166
167 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
168 println!(" Memory configuration:");
169 println!(" - Memory size: {}", config.memory_size);
170 println!(" - Associative memory: {}", config.associative_memory);
171 println!(" - Episodic memory: {}", config.episodic_memory);
172 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
173 println!(" - Quantum compression: {}", config.quantum_compression);
174
175 // Test memory storage and retrieval
176 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
177 0.1 * (b as f64 + s as f64 * 0.1 + d as f64 * 0.01)
178 });
179
180 // Enhance embeddings with memory
181 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
182 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
183
184 // Measure memory enhancement effect
185 let original_variance = test_embeddings.var(0.0);
186 let enhanced_variance = enhanced.var(0.0);
187 let enhancement_factor = enhanced_variance / original_variance;
188
189 println!(" Memory enhancement factor: {:.3}", enhancement_factor);
190
191 // Test memory update
192 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
193 memory_system.update_memory(&enhanced, &input_ids)?;
194
195 println!(" Memory updated with new experiences");
196
197 // Test memory retrieval patterns
198 test_memory_patterns(&memory_system, &config)?;
199 }
200
201 Ok(())
202}Sourcepub fn update_memory(
&mut self,
hidden_states: &Array3<f64>,
input_ids: &Array2<usize>,
) -> Result<()>
pub fn update_memory( &mut self, hidden_states: &Array3<f64>, input_ids: &Array2<usize>, ) -> Result<()>
Update memory with new information
Examples found in repository?
examples/quantum_llm.rs (line 193)
154fn quantum_memory_demo() -> Result<()> {
155 println!(" Testing quantum memory systems...");
156
157 // Test different memory configurations
158 let memory_configs = vec![
159 ("Basic Associative", QuantumMemoryConfig::default()),
160 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
161 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
162 ];
163
164 for (name, config) in memory_configs {
165 println!("\n --- {} Memory ---", name);
166
167 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
168 println!(" Memory configuration:");
169 println!(" - Memory size: {}", config.memory_size);
170 println!(" - Associative memory: {}", config.associative_memory);
171 println!(" - Episodic memory: {}", config.episodic_memory);
172 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
173 println!(" - Quantum compression: {}", config.quantum_compression);
174
175 // Test memory storage and retrieval
176 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
177 0.1 * (b as f64 + s as f64 * 0.1 + d as f64 * 0.01)
178 });
179
180 // Enhance embeddings with memory
181 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
182 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
183
184 // Measure memory enhancement effect
185 let original_variance = test_embeddings.var(0.0);
186 let enhanced_variance = enhanced.var(0.0);
187 let enhancement_factor = enhanced_variance / original_variance;
188
189 println!(" Memory enhancement factor: {:.3}", enhancement_factor);
190
191 // Test memory update
192 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
193 memory_system.update_memory(&enhanced, &input_ids)?;
194
195 println!(" Memory updated with new experiences");
196
197 // Test memory retrieval patterns
198 test_memory_patterns(&memory_system, &config)?;
199 }
200
201 Ok(())
202}Sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Get number of parameters
Trait Implementations§
Source§impl Clone for QuantumMemorySystem
impl Clone for QuantumMemorySystem
Source§fn clone(&self) -> QuantumMemorySystem
fn clone(&self) -> QuantumMemorySystem
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 QuantumMemorySystem
impl RefUnwindSafe for QuantumMemorySystem
impl Send for QuantumMemorySystem
impl Sync for QuantumMemorySystem
impl Unpin for QuantumMemorySystem
impl UnwindSafe for QuantumMemorySystem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.