pub struct GenerationConfig {
pub max_length: usize,
pub temperature: f64,
pub top_k: Option<usize>,
pub top_p: Option<f64>,
pub repetition_penalty: f64,
pub use_quantum_reasoning: bool,
pub use_memory: bool,
pub chain_of_thought: bool,
}Expand description
Text generation parameters
Fields§
§max_length: usizeMaximum generation length
temperature: f64Temperature for sampling
top_k: Option<usize>Top-k sampling
top_p: Option<f64>Top-p (nucleus) sampling
repetition_penalty: f64Repetition penalty
use_quantum_reasoning: boolEnable quantum reasoning during generation
use_memory: boolMemory-guided generation
chain_of_thought: boolChain-of-thought generation
Implementations§
Source§impl GenerationConfig
impl GenerationConfig
Sourcepub fn default() -> Self
pub fn default() -> Self
Default generation configuration
Examples found in repository?
examples/quantum_llm.rs (line 292)
284fn text_generation_demo() -> Result<()> {
285 println!(" Testing quantum-enhanced text generation...");
286
287 let config = QuantumLLMConfig::small(10000);
288 let mut model = QuantumLLM::new(config)?;
289
290 // Test different generation configurations
291 let generation_configs = vec![
292 ("Default", GenerationConfig::default()),
293 ("Creative", GenerationConfig::creative()),
294 ("Precise", GenerationConfig::precise()),
295 ];
296
297 let test_prompts = vec![
298 "The quantum computer",
299 "Artificial intelligence will",
300 "In the future, quantum computing",
301 "The relationship between quantum mechanics and consciousness",
302 ];
303
304 for (config_name, gen_config) in generation_configs {
305 println!("\n --- {} Generation ---", config_name);
306 println!(" Configuration:");
307 println!(" - Max length: {}", gen_config.max_length);
308 println!(" - Temperature: {:.1}", gen_config.temperature);
309 println!(" - Top-k: {:?}", gen_config.top_k);
310 println!(" - Top-p: {:?}", gen_config.top_p);
311 println!(
312 " - Quantum reasoning: {}",
313 gen_config.use_quantum_reasoning
314 );
315 println!(" - Memory usage: {}", gen_config.use_memory);
316 println!(" - Chain-of-thought: {}", gen_config.chain_of_thought);
317
318 for (i, prompt) in test_prompts.iter().take(2).enumerate() {
319 println!("\n Prompt {}: \"{}\"", i + 1, prompt);
320
321 let start_time = std::time::Instant::now();
322 let generated = model.generate(prompt, gen_config.clone())?;
323 let generation_time = start_time.elapsed();
324
325 // Display partial generated text (first 100 chars)
326 let display_text = if generated.len() > 100 {
327 format!("{}...", &generated[..100])
328 } else {
329 generated.clone()
330 };
331
332 println!(" Generated: \"{}\"", display_text);
333 println!(" Generation time: {:.2?}", generation_time);
334
335 // Analyze generation quality
336 let quality = analyze_generation_quality(&generated, &gen_config)?;
337 println!(" Quality metrics:");
338 println!(" - Fluency: {:.2}", quality.fluency);
339 println!(" - Coherence: {:.2}", quality.coherence);
340 println!(" - Novelty: {:.2}", quality.novelty);
341 println!(" - Quantum advantage: {:.3}", quality.quantum_advantage);
342 }
343 }
344
345 // Display generation statistics
346 let stats = model.generation_stats();
347 println!("\n Generation Statistics:");
348 println!(" - Total tokens generated: {}", stats.total_tokens);
349 println!(" - Quantum coherence: {:.3}", stats.quantum_coherence);
350 println!(" - Reasoning steps taken: {}", stats.reasoning_steps);
351 println!(" - Memory retrievals: {}", stats.memory_retrievals);
352
353 Ok(())
354}Sourcepub fn creative() -> Self
pub fn creative() -> Self
Creative generation configuration
Examples found in repository?
examples/quantum_llm.rs (line 293)
284fn text_generation_demo() -> Result<()> {
285 println!(" Testing quantum-enhanced text generation...");
286
287 let config = QuantumLLMConfig::small(10000);
288 let mut model = QuantumLLM::new(config)?;
289
290 // Test different generation configurations
291 let generation_configs = vec![
292 ("Default", GenerationConfig::default()),
293 ("Creative", GenerationConfig::creative()),
294 ("Precise", GenerationConfig::precise()),
295 ];
296
297 let test_prompts = vec![
298 "The quantum computer",
299 "Artificial intelligence will",
300 "In the future, quantum computing",
301 "The relationship between quantum mechanics and consciousness",
302 ];
303
304 for (config_name, gen_config) in generation_configs {
305 println!("\n --- {} Generation ---", config_name);
306 println!(" Configuration:");
307 println!(" - Max length: {}", gen_config.max_length);
308 println!(" - Temperature: {:.1}", gen_config.temperature);
309 println!(" - Top-k: {:?}", gen_config.top_k);
310 println!(" - Top-p: {:?}", gen_config.top_p);
311 println!(
312 " - Quantum reasoning: {}",
313 gen_config.use_quantum_reasoning
314 );
315 println!(" - Memory usage: {}", gen_config.use_memory);
316 println!(" - Chain-of-thought: {}", gen_config.chain_of_thought);
317
318 for (i, prompt) in test_prompts.iter().take(2).enumerate() {
319 println!("\n Prompt {}: \"{}\"", i + 1, prompt);
320
321 let start_time = std::time::Instant::now();
322 let generated = model.generate(prompt, gen_config.clone())?;
323 let generation_time = start_time.elapsed();
324
325 // Display partial generated text (first 100 chars)
326 let display_text = if generated.len() > 100 {
327 format!("{}...", &generated[..100])
328 } else {
329 generated.clone()
330 };
331
332 println!(" Generated: \"{}\"", display_text);
333 println!(" Generation time: {:.2?}", generation_time);
334
335 // Analyze generation quality
336 let quality = analyze_generation_quality(&generated, &gen_config)?;
337 println!(" Quality metrics:");
338 println!(" - Fluency: {:.2}", quality.fluency);
339 println!(" - Coherence: {:.2}", quality.coherence);
340 println!(" - Novelty: {:.2}", quality.novelty);
341 println!(" - Quantum advantage: {:.3}", quality.quantum_advantage);
342 }
343 }
344
345 // Display generation statistics
346 let stats = model.generation_stats();
347 println!("\n Generation Statistics:");
348 println!(" - Total tokens generated: {}", stats.total_tokens);
349 println!(" - Quantum coherence: {:.3}", stats.quantum_coherence);
350 println!(" - Reasoning steps taken: {}", stats.reasoning_steps);
351 println!(" - Memory retrievals: {}", stats.memory_retrievals);
352
353 Ok(())
354}Sourcepub fn precise() -> Self
pub fn precise() -> Self
Precise generation configuration
Examples found in repository?
examples/quantum_llm.rs (line 294)
284fn text_generation_demo() -> Result<()> {
285 println!(" Testing quantum-enhanced text generation...");
286
287 let config = QuantumLLMConfig::small(10000);
288 let mut model = QuantumLLM::new(config)?;
289
290 // Test different generation configurations
291 let generation_configs = vec![
292 ("Default", GenerationConfig::default()),
293 ("Creative", GenerationConfig::creative()),
294 ("Precise", GenerationConfig::precise()),
295 ];
296
297 let test_prompts = vec![
298 "The quantum computer",
299 "Artificial intelligence will",
300 "In the future, quantum computing",
301 "The relationship between quantum mechanics and consciousness",
302 ];
303
304 for (config_name, gen_config) in generation_configs {
305 println!("\n --- {} Generation ---", config_name);
306 println!(" Configuration:");
307 println!(" - Max length: {}", gen_config.max_length);
308 println!(" - Temperature: {:.1}", gen_config.temperature);
309 println!(" - Top-k: {:?}", gen_config.top_k);
310 println!(" - Top-p: {:?}", gen_config.top_p);
311 println!(
312 " - Quantum reasoning: {}",
313 gen_config.use_quantum_reasoning
314 );
315 println!(" - Memory usage: {}", gen_config.use_memory);
316 println!(" - Chain-of-thought: {}", gen_config.chain_of_thought);
317
318 for (i, prompt) in test_prompts.iter().take(2).enumerate() {
319 println!("\n Prompt {}: \"{}\"", i + 1, prompt);
320
321 let start_time = std::time::Instant::now();
322 let generated = model.generate(prompt, gen_config.clone())?;
323 let generation_time = start_time.elapsed();
324
325 // Display partial generated text (first 100 chars)
326 let display_text = if generated.len() > 100 {
327 format!("{}...", &generated[..100])
328 } else {
329 generated.clone()
330 };
331
332 println!(" Generated: \"{}\"", display_text);
333 println!(" Generation time: {:.2?}", generation_time);
334
335 // Analyze generation quality
336 let quality = analyze_generation_quality(&generated, &gen_config)?;
337 println!(" Quality metrics:");
338 println!(" - Fluency: {:.2}", quality.fluency);
339 println!(" - Coherence: {:.2}", quality.coherence);
340 println!(" - Novelty: {:.2}", quality.novelty);
341 println!(" - Quantum advantage: {:.3}", quality.quantum_advantage);
342 }
343 }
344
345 // Display generation statistics
346 let stats = model.generation_stats();
347 println!("\n Generation Statistics:");
348 println!(" - Total tokens generated: {}", stats.total_tokens);
349 println!(" - Quantum coherence: {:.3}", stats.quantum_coherence);
350 println!(" - Reasoning steps taken: {}", stats.reasoning_steps);
351 println!(" - Memory retrievals: {}", stats.memory_retrievals);
352
353 Ok(())
354}Trait Implementations§
Source§impl Clone for GenerationConfig
impl Clone for GenerationConfig
Source§fn clone(&self) -> GenerationConfig
fn clone(&self) -> GenerationConfig
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 GenerationConfig
impl RefUnwindSafe for GenerationConfig
impl Send for GenerationConfig
impl Sync for GenerationConfig
impl Unpin for GenerationConfig
impl UnwindSafe for GenerationConfig
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.