Struct rust_bert::pipelines::generation_utils::GenerateConfig
source · [−]pub struct GenerateConfig {Show 19 fields
pub model_resource: Box<dyn ResourceProvider + Send>,
pub config_resource: Box<dyn ResourceProvider + Send>,
pub vocab_resource: Box<dyn ResourceProvider + Send>,
pub merges_resource: Box<dyn ResourceProvider + Send>,
pub min_length: i64,
pub max_length: i64,
pub do_sample: bool,
pub early_stopping: bool,
pub num_beams: i64,
pub temperature: f64,
pub top_k: i64,
pub top_p: f64,
pub repetition_penalty: f64,
pub length_penalty: f64,
pub no_repeat_ngram_size: i64,
pub num_return_sequences: i64,
pub num_beam_groups: Option<i64>,
pub diversity_penalty: Option<f64>,
pub device: Device,
}Expand description
Fields
model_resource: Box<dyn ResourceProvider + Send>Model weights resource (default: pretrained GPT2 model)
config_resource: Box<dyn ResourceProvider + Send>Config resource (default: pretrained GPT2 model)
vocab_resource: Box<dyn ResourceProvider + Send>Vocab resource (default: pretrained GPT2 model)
merges_resource: Box<dyn ResourceProvider + Send>Merges resource (default: pretrained GPT2 model)
min_length: i64Minimum sequence length (default: 0)
max_length: i64Maximum sequence length (default: 20)
do_sample: boolSampling flag. If true, will perform top-k and/or nucleus sampling on generated tokens, otherwise greedy (deterministic) decoding (default: true)
early_stopping: boolEarly stopping flag indicating if the beam search should stop as soon as num_beam hypotheses have been generated (default: false)
num_beams: i64Number of beams for beam search (default: 5)
temperature: f64Temperature setting. Values higher than 1 will improve originality at the risk of reducing relevance (default: 1.0)
top_k: i64Top_k values for sampling tokens. Value higher than 0 will enable the feature (default: 0)
top_p: f64Top_p value for Nucleus sampling, Holtzman et al.. Keep top tokens until cumulative probability reaches top_p (default: 0.9)
repetition_penalty: f64Repetition penalty (mostly useful for CTRL decoders). Values higher than 1 will penalize tokens that have been already generated. (default: 1.0)
length_penalty: f64Exponential penalty based on the length of the hypotheses generated (default: 1.0)
no_repeat_ngram_size: i64Number of allowed repetitions of n-grams. Values higher than 0 turn on this feature (default: 3)
num_return_sequences: i64Number of sequences to return for each prompt text (default: 1)
num_beam_groups: Option<i64>Number of beam groups for diverse beam generation. If provided and higher than 1, will split the beams into beam subgroups leading to more diverse generation.
diversity_penalty: Option<f64>Diversity penalty for diverse beam search. High values will enforce more difference between beam groups (default: 5.5)
device: DeviceDevice to place the model on (default: CUDA/GPU when available)
Trait Implementations
sourceimpl Default for GenerateConfig
impl Default for GenerateConfig
sourcefn default() -> GenerateConfig
fn default() -> GenerateConfig
Returns the “default value” for a type. Read more
sourceimpl From<ConversationConfig> for GenerateConfig
impl From<ConversationConfig> for GenerateConfig
sourcefn from(config: ConversationConfig) -> GenerateConfig
fn from(config: ConversationConfig) -> GenerateConfig
Converts to this type from the input type.
sourceimpl From<SummarizationConfig> for GenerateConfig
impl From<SummarizationConfig> for GenerateConfig
sourcefn from(config: SummarizationConfig) -> GenerateConfig
fn from(config: SummarizationConfig) -> GenerateConfig
Converts to this type from the input type.
sourceimpl From<TextGenerationConfig> for GenerateConfig
impl From<TextGenerationConfig> for GenerateConfig
sourcefn from(config: TextGenerationConfig) -> GenerateConfig
fn from(config: TextGenerationConfig) -> GenerateConfig
Converts to this type from the input type.
sourceimpl From<TranslationConfig> for GenerateConfig
impl From<TranslationConfig> for GenerateConfig
sourcefn from(config: TranslationConfig) -> GenerateConfig
fn from(config: TranslationConfig) -> GenerateConfig
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for GenerateConfig
impl Send for GenerateConfig
impl !Sync for GenerateConfig
impl Unpin for GenerateConfig
impl !UnwindSafe for GenerateConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more