Struct rust_bert::pipelines::text_generation::TextGenerationModel [−][src]
pub struct TextGenerationModel { /* fields omitted */ }Expand description
Implementations
pub fn new(
generation_config: TextGenerationConfig
) -> Result<TextGenerationModel, RustBertError>
pub fn new(
generation_config: TextGenerationConfig
) -> Result<TextGenerationModel, RustBertError>
Build a new TextGenerationModel
Arguments
generation_config-GenerateConfigobject containing the resource references (model, vocabulary, configuration), generation options and device placement (CPU/GPU)model_type-ModelTypeenum variant indicating the type of model to use for generation
Example
use rust_bert::pipelines::common::ModelType;
use rust_bert::pipelines::text_generation::TextGenerationModel;
let generation_model = TextGenerationModel::new(Default::default())?;Generate texts from provided prompts
Arguments
input-&[&str]Array of texts to summarize.prefix-impl Into<Option<&'a str>>: Optional string to pass as a prefix for generation. Will be excluded from generated sequences.
Returns
Vec<String>Generated texts
Example
use rust_bert::pipelines::common::ModelType;
use rust_bert::pipelines::text_generation::TextGenerationModel;
let model = TextGenerationModel::new(Default::default())?;
let input = ["The dog", "The cat was"];
let prefix = None;
let output = model.generate(&input, prefix);Auto Trait Implementations
impl RefUnwindSafe for TextGenerationModel
impl Send for TextGenerationModel
impl !Sync for TextGenerationModel
impl Unpin for TextGenerationModel
impl UnwindSafe for TextGenerationModel
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self
