pub struct SummarizationConfig {Show 21 fields
pub model_type: ModelType,
pub model_resource: ModelResource,
pub config_resource: Box<dyn ResourceProvider + Send>,
pub vocab_resource: Box<dyn ResourceProvider + Send>,
pub merges_resource: Option<Box<dyn ResourceProvider + Send>>,
pub min_length: i64,
pub max_length: Option<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,
pub kind: Option<Kind>,
}
Expand description
§Configuration for text summarization
Contains information regarding the model to load, mirrors the GenerationConfig, with a different set of default parameters and sets the device to place the model on.
Fields§
§model_type: ModelType
Model type
model_resource: ModelResource
Model weights resource (default: pretrained BART model on CNN-DM)
config_resource: Box<dyn ResourceProvider + Send>
Config resource (default: pretrained BART model on CNN-DM)
vocab_resource: Box<dyn ResourceProvider + Send>
Vocab resource (default: pretrained BART model on CNN-DM)
merges_resource: Option<Box<dyn ResourceProvider + Send>>
Merges resource (default: pretrained BART model on CNN-DM)
min_length: i64
Minimum sequence length (default: 0)
max_length: Option<i64>
Maximum sequence length (default: 20)
do_sample: bool
Sampling flag. If true, will perform top-k and/or nucleus sampling on generated tokens, otherwise greedy (deterministic) decoding (default: true)
early_stopping: bool
Early stopping flag indicating if the beam search should stop as soon as num_beam
hypotheses have been generated (default: false)
num_beams: i64
Number of beams for beam search (default: 5)
temperature: f64
Temperature setting. Values higher than 1 will improve originality at the risk of reducing relevance (default: 1.0)
top_k: i64
Top_k values for sampling tokens. Value higher than 0 will enable the feature (default: 0)
top_p: f64
Top_p value for Nucleus sampling, Holtzman et al.. Keep top tokens until cumulative probability reaches top_p (default: 0.9)
repetition_penalty: f64
Repetition penalty (mostly useful for CTRL decoders). Values higher than 1 will penalize tokens that have been already generated. (default: 1.0)
length_penalty: f64
Exponential penalty based on the length of the hypotheses generated (default: 1.0)
no_repeat_ngram_size: i64
Number of allowed repetitions of n-grams. Values higher than 0 turn on this feature (default: 3)
num_return_sequences: i64
Number 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: Device
Device to place the model on (default: CUDA/GPU when available)
kind: Option<Kind>
Model weights precision. If not provided, will default to full precision on CPU, or the loaded weights precision otherwise
Implementations§
Source§impl SummarizationConfig
impl SummarizationConfig
Sourcepub fn new<RC, RV>(
model_type: ModelType,
model_resource: ModelResource,
config_resource: RC,
vocab_resource: RV,
merges_resource: Option<RV>,
) -> SummarizationConfig
pub fn new<RC, RV>( model_type: ModelType, model_resource: ModelResource, config_resource: RC, vocab_resource: RV, merges_resource: Option<RV>, ) -> SummarizationConfig
Instantiate a new summarization configuration of the supplied type.
§Arguments
model_type
-ModelType
indicating the model type to load (must match with the actual data to be loaded!)- model_resource - The
ModelResources
pointing to the model to load (e.g. model.ot) - config_resource - The
ResourceProvider
pointing to the model configuration to load (e.g. config.json) - vocab_resource - The
ResourceProvider
pointing to the tokenizer’s vocabulary to load (e.g. vocab.txt/vocab.json) - merges_resource - The
ResourceProvider
pointing to the tokenizer’s merge file or SentencePiece model to load (e.g. merges.txt).
Trait Implementations§
Source§impl Default for SummarizationConfig
impl Default for SummarizationConfig
Source§fn default() -> SummarizationConfig
fn default() -> SummarizationConfig
Source§impl From<SummarizationConfig> for GenerateConfig
impl From<SummarizationConfig> for GenerateConfig
Source§fn from(config: SummarizationConfig) -> GenerateConfig
fn from(config: SummarizationConfig) -> GenerateConfig
Auto Trait Implementations§
impl Freeze for SummarizationConfig
impl !RefUnwindSafe for SummarizationConfig
impl Send for SummarizationConfig
impl Sync for SummarizationConfig
impl Unpin for SummarizationConfig
impl !UnwindSafe for SummarizationConfig
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
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>
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>
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