pub struct ValidatedBuilder<T> { /* private fields */ }Expand description
Validation builder for objects that need validation
Implementations§
Source§impl ValidatedBuilder<GenerationConfig>
impl ValidatedBuilder<GenerationConfig>
Sourcepub fn with_validation() -> Self
pub fn with_validation() -> Self
Create a new GenerationConfig builder with validation
Sourcepub fn strategy(self, strategy: GenerationStrategy) -> Self
pub fn strategy(self, strategy: GenerationStrategy) -> Self
Set the generation strategy
Sourcepub fn max_length(self, max_length: usize) -> Self
pub fn max_length(self, max_length: usize) -> Self
Set max length
Sourcepub fn max_new_tokens(self, max_new_tokens: usize) -> Self
pub fn max_new_tokens(self, max_new_tokens: usize) -> Self
Set max new tokens
Sourcepub fn min_length(self, min_length: usize) -> Self
pub fn min_length(self, min_length: usize) -> Self
Set min length
Sourcepub fn enable_sampling(self, do_sample: bool) -> Self
pub fn enable_sampling(self, do_sample: bool) -> Self
Enable sampling
Sourcepub fn early_stopping(self, early_stopping: bool) -> Self
pub fn early_stopping(self, early_stopping: bool) -> Self
Enable early stopping
Sourcepub fn num_return_sequences(self, num_sequences: usize) -> Self
pub fn num_return_sequences(self, num_sequences: usize) -> Self
Set number of return sequences
Sourcepub fn pad_token_id(self, token_id: usize) -> Self
pub fn pad_token_id(self, token_id: usize) -> Self
Set pad token ID
Sourcepub fn eos_token_id(self, token_id: usize) -> Self
pub fn eos_token_id(self, token_id: usize) -> Self
Set EOS token ID
Sourcepub fn bos_token_id(self, token_id: usize) -> Self
pub fn bos_token_id(self, token_id: usize) -> Self
Set BOS token ID
Sourcepub fn repetition_penalty(self, penalty: f32) -> Self
pub fn repetition_penalty(self, penalty: f32) -> Self
Set repetition penalty
Sourcepub fn length_penalty(self, penalty: f32) -> Self
pub fn length_penalty(self, penalty: f32) -> Self
Set length penalty
Sourcepub fn no_repeat_ngram_size(self, size: usize) -> Self
pub fn no_repeat_ngram_size(self, size: usize) -> Self
Set no repeat ngram size
Sourcepub fn guided_generation(self, config: GuidedGenerationConfig) -> Self
pub fn guided_generation(self, config: GuidedGenerationConfig) -> Self
Set guided generation config
Sourcepub fn watermarking(self, config: WatermarkingConfig) -> Self
pub fn watermarking(self, config: WatermarkingConfig) -> Self
Set watermarking config
Sourcepub fn sampling_with_temperature(self, temperature: f32) -> Self
pub fn sampling_with_temperature(self, temperature: f32) -> Self
Quick setup for sampling with temperature
Sourcepub fn top_k_sampling(self, k: usize, temperature: f32) -> Self
pub fn top_k_sampling(self, k: usize, temperature: f32) -> Self
Quick setup for top-k sampling
Sourcepub fn top_p_sampling(self, p: f32, temperature: f32) -> Self
pub fn top_p_sampling(self, p: f32, temperature: f32) -> Self
Quick setup for top-p sampling
Sourcepub fn beam_search(self, num_beams: usize) -> Self
pub fn beam_search(self, num_beams: usize) -> Self
Quick setup for beam search
Source§impl<T> ValidatedBuilder<T>where
T: Default,
impl<T> ValidatedBuilder<T>where
T: Default,
Sourcepub fn add_validator<F>(self, validator: F) -> Self
pub fn add_validator<F>(self, validator: F) -> Self
Add a validation function
Trait Implementations§
Source§impl<T> Builder<T> for ValidatedBuilder<T>where
T: Clone,
impl<T> Builder<T> for ValidatedBuilder<T>where
T: Clone,
Auto Trait Implementations§
impl<T> Freeze for ValidatedBuilder<T>where
T: Freeze,
impl<T> !RefUnwindSafe for ValidatedBuilder<T>
impl<T> Send for ValidatedBuilder<T>where
T: Send,
impl<T> Sync for ValidatedBuilder<T>where
T: Sync,
impl<T> Unpin for ValidatedBuilder<T>where
T: Unpin,
impl<T> UnsafeUnpin for ValidatedBuilder<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for ValidatedBuilder<T>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more