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