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 166)
153fn quantum_memory_demo() -> Result<()> {
154 println!(" Testing quantum memory systems...");
155
156 // Test different memory configurations
157 let memory_configs = vec![
158 ("Basic Associative", QuantumMemoryConfig::default()),
159 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
160 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
161 ];
162
163 for (name, config) in memory_configs {
164 println!("\n --- {name} Memory ---");
165
166 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
167 println!(" Memory configuration:");
168 println!(" - Memory size: {}", config.memory_size);
169 println!(" - Associative memory: {}", config.associative_memory);
170 println!(" - Episodic memory: {}", config.episodic_memory);
171 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
172 println!(" - Quantum compression: {}", config.quantum_compression);
173
174 // Test memory storage and retrieval
175 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
176 0.1 * (d as f64).mul_add(0.01, (s as f64).mul_add(0.1, b as f64))
177 });
178
179 // Enhance embeddings with memory
180 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
181 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
182
183 // Measure memory enhancement effect
184 let original_variance = test_embeddings.var(0.0);
185 let enhanced_variance = enhanced.var(0.0);
186 let enhancement_factor = enhanced_variance / original_variance;
187
188 println!(" Memory enhancement factor: {enhancement_factor:.3}");
189
190 // Test memory update
191 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
192 memory_system.update_memory(&enhanced, &input_ids)?;
193
194 println!(" Memory updated with new experiences");
195
196 // Test memory retrieval patterns
197 test_memory_patterns(&memory_system, &config)?;
198 }
199
200 Ok(())
201}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 180)
153fn quantum_memory_demo() -> Result<()> {
154 println!(" Testing quantum memory systems...");
155
156 // Test different memory configurations
157 let memory_configs = vec![
158 ("Basic Associative", QuantumMemoryConfig::default()),
159 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
160 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
161 ];
162
163 for (name, config) in memory_configs {
164 println!("\n --- {name} Memory ---");
165
166 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
167 println!(" Memory configuration:");
168 println!(" - Memory size: {}", config.memory_size);
169 println!(" - Associative memory: {}", config.associative_memory);
170 println!(" - Episodic memory: {}", config.episodic_memory);
171 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
172 println!(" - Quantum compression: {}", config.quantum_compression);
173
174 // Test memory storage and retrieval
175 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
176 0.1 * (d as f64).mul_add(0.01, (s as f64).mul_add(0.1, b as f64))
177 });
178
179 // Enhance embeddings with memory
180 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
181 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
182
183 // Measure memory enhancement effect
184 let original_variance = test_embeddings.var(0.0);
185 let enhanced_variance = enhanced.var(0.0);
186 let enhancement_factor = enhanced_variance / original_variance;
187
188 println!(" Memory enhancement factor: {enhancement_factor:.3}");
189
190 // Test memory update
191 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
192 memory_system.update_memory(&enhanced, &input_ids)?;
193
194 println!(" Memory updated with new experiences");
195
196 // Test memory retrieval patterns
197 test_memory_patterns(&memory_system, &config)?;
198 }
199
200 Ok(())
201}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 192)
153fn quantum_memory_demo() -> Result<()> {
154 println!(" Testing quantum memory systems...");
155
156 // Test different memory configurations
157 let memory_configs = vec![
158 ("Basic Associative", QuantumMemoryConfig::default()),
159 ("Enhanced Memory", QuantumMemoryConfig::enhanced()),
160 ("Advanced Holographic", QuantumMemoryConfig::advanced()),
161 ];
162
163 for (name, config) in memory_configs {
164 println!("\n --- {name} Memory ---");
165
166 let mut memory_system = QuantumMemorySystem::new(config.clone())?;
167 println!(" Memory configuration:");
168 println!(" - Memory size: {}", config.memory_size);
169 println!(" - Associative memory: {}", config.associative_memory);
170 println!(" - Episodic memory: {}", config.episodic_memory);
171 println!(" - Retrieval mechanism: {:?}", config.retrieval_mechanism);
172 println!(" - Quantum compression: {}", config.quantum_compression);
173
174 // Test memory storage and retrieval
175 let test_embeddings = Array3::from_shape_fn((2, 10, 128), |(b, s, d)| {
176 0.1 * (d as f64).mul_add(0.01, (s as f64).mul_add(0.1, b as f64))
177 });
178
179 // Enhance embeddings with memory
180 let enhanced = memory_system.enhance_embeddings(&test_embeddings)?;
181 println!(" Enhanced embeddings shape: {:?}", enhanced.dim());
182
183 // Measure memory enhancement effect
184 let original_variance = test_embeddings.var(0.0);
185 let enhanced_variance = enhanced.var(0.0);
186 let enhancement_factor = enhanced_variance / original_variance;
187
188 println!(" Memory enhancement factor: {enhancement_factor:.3}");
189
190 // Test memory update
191 let input_ids = Array2::from_shape_fn((2, 10), |(b, s)| (b * 10 + s) % 1000);
192 memory_system.update_memory(&enhanced, &input_ids)?;
193
194 println!(" Memory updated with new experiences");
195
196 // Test memory retrieval patterns
197 test_memory_patterns(&memory_system, &config)?;
198 }
199
200 Ok(())
201}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.