Skip to main content

ValidatedBuilder

Struct ValidatedBuilder 

Source
pub struct ValidatedBuilder<T> { /* private fields */ }
Expand description

Validation builder for objects that need validation

Implementations§

Source§

impl ValidatedBuilder<GenerationConfig>

Source

pub fn with_validation() -> Self

Create a new GenerationConfig builder with validation

Source

pub fn strategy(self, strategy: GenerationStrategy) -> Self

Set the generation strategy

Source

pub fn max_length(self, max_length: usize) -> Self

Set max length

Source

pub fn max_new_tokens(self, max_new_tokens: usize) -> Self

Set max new tokens

Source

pub fn min_length(self, min_length: usize) -> Self

Set min length

Source

pub fn enable_sampling(self, do_sample: bool) -> Self

Enable sampling

Source

pub fn early_stopping(self, early_stopping: bool) -> Self

Enable early stopping

Source

pub fn num_return_sequences(self, num_sequences: usize) -> Self

Set number of return sequences

Source

pub fn pad_token_id(self, token_id: usize) -> Self

Set pad token ID

Source

pub fn eos_token_id(self, token_id: usize) -> Self

Set EOS token ID

Source

pub fn bos_token_id(self, token_id: usize) -> Self

Set BOS token ID

Source

pub fn repetition_penalty(self, penalty: f32) -> Self

Set repetition penalty

Source

pub fn length_penalty(self, penalty: f32) -> Self

Set length penalty

Source

pub fn no_repeat_ngram_size(self, size: usize) -> Self

Set no repeat ngram size

Source

pub fn use_cache(self, use_cache: bool) -> Self

Enable/disable caching

Source

pub fn streaming(self, streaming: bool) -> Self

Enable/disable streaming

Source

pub fn guided_generation(self, config: GuidedGenerationConfig) -> Self

Set guided generation config

Source

pub fn watermarking(self, config: WatermarkingConfig) -> Self

Set watermarking config

Source

pub fn greedy(self) -> Self

Quick setup for greedy decoding

Source

pub fn sampling_with_temperature(self, temperature: f32) -> Self

Quick setup for sampling with temperature

Source

pub fn top_k_sampling(self, k: usize, temperature: f32) -> Self

Quick setup for top-k sampling

Source

pub fn top_p_sampling(self, p: f32, temperature: f32) -> Self

Quick setup for top-p sampling

Quick setup for beam search

Source§

impl<T> ValidatedBuilder<T>
where T: Default,

Source

pub fn new() -> Self

Create a new validated builder

Source

pub fn add_validator<F>(self, validator: F) -> Self
where F: Fn(&T) -> Result<()> + Send + Sync + 'static,

Add a validation function

Source

pub fn data(&self) -> &T

Get a reference to the data

Source

pub fn data_mut(&mut self) -> &mut T

Get a mutable reference to the data

Trait Implementations§

Source§

impl<T> Builder<T> for ValidatedBuilder<T>
where T: Clone,

Source§

fn build(self) -> Result<T>

Build the final object
Source§

fn validate(&self) -> Result<()>

Validate the current builder state
Source§

fn reset(self) -> Self
where T: Default,

Reset the builder to default state
Source§

impl<T> Default for ValidatedBuilder<T>
where T: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more