Struct rust_bert::prophetnet::ProphetNetConditionalGenerator [−][src]
pub struct ProphetNetConditionalGenerator { /* fields omitted */ }Expand description
Implementations
pub fn new(
generate_config: GenerateConfig
) -> Result<ProphetNetConditionalGenerator, RustBertError>
pub fn new(
generate_config: GenerateConfig
) -> Result<ProphetNetConditionalGenerator, RustBertError>
Build a new ProphetNetConditionalGenerator
Arguments
vocab_path- Path to the model vocabulary, expected to have a structure following the Transformers library conventionmerges_path- Path to the bpe merges, expected to have a structure following the Transformers library conventionconfig_path- Path to the model configuration, expected to have a structure following the Transformers library conventionweights_path- Path to the model weight files. These need to be converted form the.binto.otformat using the utility script provided.device- Device to run the model on, e.g.Device::CpuorDevice::Cuda(0)
Example
use rust_bert::pipelines::generation_utils::GenerateConfig;
use rust_bert::prophetnet::ProphetNetConditionalGenerator;
let device = Device::cuda_if_available();
let generate_config = GenerateConfig {
max_length: 30,
do_sample: true,
num_beams: 5,
temperature: 1.1,
num_return_sequences: 3,
..Default::default()
};
let prophetnet_generator = ProphetNetConditionalGenerator::new(generate_config)?;Trait Implementations
Generate text based on a vector of promp texts. Read more
Generate token indices without decoding (useful for token-level operations before returning final text or as validation step during training). Read more
fn generate_from_ids_and_past(
&self,
input_ids: Tensor,
attention_mask: Option<Tensor>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘ
fn generate_from_ids_and_past(
&self,
input_ids: Tensor,
attention_mask: Option<Tensor>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘ
Generate token indices given a list of indices (useful when the input has been pre-tokenized). Returns a list of output tokens that need to be decoded using a tokenizer. Read more
Returns a reference to the text generator’s tokenizer Read more
Auto Trait Implementations
impl Send for ProphetNetConditionalGenerator
impl !Sync for ProphetNetConditionalGenerator
impl Unpin for ProphetNetConditionalGenerator
impl UnwindSafe for ProphetNetConditionalGenerator
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
