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