pub struct QuantumReasoningConfig {
pub logical_reasoning: bool,
pub causal_reasoning: bool,
pub analogical_reasoning: bool,
pub reasoning_steps: usize,
pub circuit_depth: usize,
pub entanglement_strength: f64,
}Expand description
Quantum reasoning configuration
Fields§
§logical_reasoning: boolEnable quantum logical reasoning
causal_reasoning: boolEnable quantum causal reasoning
analogical_reasoning: boolEnable quantum analogical reasoning
reasoning_steps: usizeNumber of reasoning steps
circuit_depth: usizeReasoning circuit depth
entanglement_strength: f64Quantum entanglement strength for reasoning
Implementations§
Source§impl QuantumReasoningConfig
impl QuantumReasoningConfig
Sourcepub fn default() -> Self
pub fn default() -> Self
Default reasoning configuration
Examples found in repository?
examples/quantum_llm.rs (line 208)
204fn quantum_reasoning_demo() -> Result<()> {
205 println!(" Testing quantum reasoning modules...");
206
207 let reasoning_configs = vec![
208 ("Basic Logical", QuantumReasoningConfig::default()),
209 ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
210 ("Advanced Analogical", QuantumReasoningConfig::advanced()),
211 ];
212
213 for (name, config) in reasoning_configs {
214 println!("\n --- {name} Reasoning ---");
215
216 let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
217
218 println!(" Reasoning capabilities:");
219 println!(" - Logical reasoning: {}", config.logical_reasoning);
220 println!(" - Causal reasoning: {}", config.causal_reasoning);
221 println!(" - Analogical reasoning: {}", config.analogical_reasoning);
222 println!(" - Reasoning steps: {}", config.reasoning_steps);
223 println!(" - Circuit depth: {}", config.circuit_depth);
224 println!(
225 " - Entanglement strength: {:.2}",
226 config.entanglement_strength
227 );
228
229 // Test reasoning on sample hidden states
230 let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
231 // Create patterns that require reasoning
232 let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
233 let causal_pattern = s as f64 * 0.1;
234 let base_value = logical_pattern + causal_pattern;
235
236 0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
237 });
238
239 println!(" Input hidden states shape: {:?}", hidden_states.dim());
240
241 // Apply quantum reasoning
242 let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
243 println!(" Reasoned output shape: {:?}", reasoned_output.dim());
244
245 // Analyze reasoning effects
246 let reasoning_enhancement =
247 analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
248 println!(" Reasoning enhancement metrics:");
249 println!(
250 " - Pattern amplification: {:.3}",
251 reasoning_enhancement.pattern_amplification
252 );
253 println!(
254 " - Logical consistency: {:.3}",
255 reasoning_enhancement.logical_consistency
256 );
257 println!(
258 " - Causal coherence: {:.3}",
259 reasoning_enhancement.causal_coherence
260 );
261
262 // Test quantum coherence during reasoning
263 let coherence = reasoning_module.measure_coherence()?;
264 println!(" Quantum coherence: {coherence:.3}");
265
266 // Test token selection enhancement
267 let sample_logits = Array1::from_shape_fn(1000, |i| {
268 0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
269 });
270
271 let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
272 let enhancement_effect = (&enhanced_logits - &sample_logits)
273 .mapv(f64::abs)
274 .mean()
275 .unwrap_or(0.0);
276 println!(" Token selection enhancement: {enhancement_effect:.4}");
277 }
278
279 Ok(())
280}Sourcepub fn enhanced() -> Self
pub fn enhanced() -> Self
Enhanced reasoning configuration
Examples found in repository?
examples/quantum_llm.rs (line 209)
204fn quantum_reasoning_demo() -> Result<()> {
205 println!(" Testing quantum reasoning modules...");
206
207 let reasoning_configs = vec![
208 ("Basic Logical", QuantumReasoningConfig::default()),
209 ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
210 ("Advanced Analogical", QuantumReasoningConfig::advanced()),
211 ];
212
213 for (name, config) in reasoning_configs {
214 println!("\n --- {name} Reasoning ---");
215
216 let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
217
218 println!(" Reasoning capabilities:");
219 println!(" - Logical reasoning: {}", config.logical_reasoning);
220 println!(" - Causal reasoning: {}", config.causal_reasoning);
221 println!(" - Analogical reasoning: {}", config.analogical_reasoning);
222 println!(" - Reasoning steps: {}", config.reasoning_steps);
223 println!(" - Circuit depth: {}", config.circuit_depth);
224 println!(
225 " - Entanglement strength: {:.2}",
226 config.entanglement_strength
227 );
228
229 // Test reasoning on sample hidden states
230 let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
231 // Create patterns that require reasoning
232 let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
233 let causal_pattern = s as f64 * 0.1;
234 let base_value = logical_pattern + causal_pattern;
235
236 0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
237 });
238
239 println!(" Input hidden states shape: {:?}", hidden_states.dim());
240
241 // Apply quantum reasoning
242 let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
243 println!(" Reasoned output shape: {:?}", reasoned_output.dim());
244
245 // Analyze reasoning effects
246 let reasoning_enhancement =
247 analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
248 println!(" Reasoning enhancement metrics:");
249 println!(
250 " - Pattern amplification: {:.3}",
251 reasoning_enhancement.pattern_amplification
252 );
253 println!(
254 " - Logical consistency: {:.3}",
255 reasoning_enhancement.logical_consistency
256 );
257 println!(
258 " - Causal coherence: {:.3}",
259 reasoning_enhancement.causal_coherence
260 );
261
262 // Test quantum coherence during reasoning
263 let coherence = reasoning_module.measure_coherence()?;
264 println!(" Quantum coherence: {coherence:.3}");
265
266 // Test token selection enhancement
267 let sample_logits = Array1::from_shape_fn(1000, |i| {
268 0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
269 });
270
271 let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
272 let enhancement_effect = (&enhanced_logits - &sample_logits)
273 .mapv(f64::abs)
274 .mean()
275 .unwrap_or(0.0);
276 println!(" Token selection enhancement: {enhancement_effect:.4}");
277 }
278
279 Ok(())
280}Sourcepub fn advanced() -> Self
pub fn advanced() -> Self
Advanced reasoning configuration
Examples found in repository?
examples/quantum_llm.rs (line 210)
204fn quantum_reasoning_demo() -> Result<()> {
205 println!(" Testing quantum reasoning modules...");
206
207 let reasoning_configs = vec![
208 ("Basic Logical", QuantumReasoningConfig::default()),
209 ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
210 ("Advanced Analogical", QuantumReasoningConfig::advanced()),
211 ];
212
213 for (name, config) in reasoning_configs {
214 println!("\n --- {name} Reasoning ---");
215
216 let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
217
218 println!(" Reasoning capabilities:");
219 println!(" - Logical reasoning: {}", config.logical_reasoning);
220 println!(" - Causal reasoning: {}", config.causal_reasoning);
221 println!(" - Analogical reasoning: {}", config.analogical_reasoning);
222 println!(" - Reasoning steps: {}", config.reasoning_steps);
223 println!(" - Circuit depth: {}", config.circuit_depth);
224 println!(
225 " - Entanglement strength: {:.2}",
226 config.entanglement_strength
227 );
228
229 // Test reasoning on sample hidden states
230 let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
231 // Create patterns that require reasoning
232 let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
233 let causal_pattern = s as f64 * 0.1;
234 let base_value = logical_pattern + causal_pattern;
235
236 0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
237 });
238
239 println!(" Input hidden states shape: {:?}", hidden_states.dim());
240
241 // Apply quantum reasoning
242 let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
243 println!(" Reasoned output shape: {:?}", reasoned_output.dim());
244
245 // Analyze reasoning effects
246 let reasoning_enhancement =
247 analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
248 println!(" Reasoning enhancement metrics:");
249 println!(
250 " - Pattern amplification: {:.3}",
251 reasoning_enhancement.pattern_amplification
252 );
253 println!(
254 " - Logical consistency: {:.3}",
255 reasoning_enhancement.logical_consistency
256 );
257 println!(
258 " - Causal coherence: {:.3}",
259 reasoning_enhancement.causal_coherence
260 );
261
262 // Test quantum coherence during reasoning
263 let coherence = reasoning_module.measure_coherence()?;
264 println!(" Quantum coherence: {coherence:.3}");
265
266 // Test token selection enhancement
267 let sample_logits = Array1::from_shape_fn(1000, |i| {
268 0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
269 });
270
271 let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
272 let enhancement_effect = (&enhanced_logits - &sample_logits)
273 .mapv(f64::abs)
274 .mean()
275 .unwrap_or(0.0);
276 println!(" Token selection enhancement: {enhancement_effect:.4}");
277 }
278
279 Ok(())
280}Trait Implementations§
Source§impl Clone for QuantumReasoningConfig
impl Clone for QuantumReasoningConfig
Source§fn clone(&self) -> QuantumReasoningConfig
fn clone(&self) -> QuantumReasoningConfig
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 QuantumReasoningConfig
impl RefUnwindSafe for QuantumReasoningConfig
impl Send for QuantumReasoningConfig
impl Sync for QuantumReasoningConfig
impl Unpin for QuantumReasoningConfig
impl UnwindSafe for QuantumReasoningConfig
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.