GenerationConfig

Struct GenerationConfig 

Source
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: usize

Maximum generation length

§temperature: f64

Temperature for sampling

§top_k: Option<usize>

Top-k sampling

§top_p: Option<f64>

Top-p (nucleus) sampling

§repetition_penalty: f64

Repetition penalty

§use_quantum_reasoning: bool

Enable quantum reasoning during generation

§use_memory: bool

Memory-guided generation

§chain_of_thought: bool

Chain-of-thought generation

Implementations§

Source§

impl GenerationConfig

Source

pub fn default() -> Self

Default generation configuration

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

pub fn creative() -> Self

Creative generation configuration

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

pub fn precise() -> Self

Precise generation configuration

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

Trait Implementations§

Source§

impl Clone for GenerationConfig

Source§

fn clone(&self) -> GenerationConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GenerationConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Ungil for T
where T: Send,