pub struct ProphetNetConditionalGenerator { /* private fields */ }Expand description
Implementations§
source§impl ProphetNetConditionalGenerator
impl ProphetNetConditionalGenerator
sourcepub 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: Some(30),
do_sample: true,
num_beams: 5,
temperature: 1.1,
num_return_sequences: 3,
..Default::default()
};
let prophetnet_generator = ProphetNetConditionalGenerator::new(generate_config)?;pub fn new_with_tokenizer(
generate_config: GenerateConfig,
tokenizer: TokenizerOption
) -> Result<ProphetNetConditionalGenerator, RustBertError>
Trait Implementations§
source§impl LanguageGenerator<ProphetNetForConditionalGeneration, ProphetNetVocab, ProphetNetTokenizer> for ProphetNetConditionalGenerator
impl LanguageGenerator<ProphetNetForConditionalGeneration, ProphetNetVocab, ProphetNetTokenizer> for ProphetNetConditionalGenerator
source§fn generate<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedTextOutput> ⓘwhere
S: AsRef<str> + Sync,
fn generate<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedTextOutput> ⓘwhere
S: AsRef<str> + Sync,
Generate text based on a vector of promp texts. Read more
source§fn generate_indices<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput> ⓘwhere
S: AsRef<str> + Sync,
fn generate_indices<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput> ⓘwhere
S: AsRef<str> + Sync,
Generate token indices without decoding (useful for token-level operations before returning final text or as validation step during training). Read more
source§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
source§fn get_tokenizer(&self) -> &TokenizerOption
fn get_tokenizer(&self) -> &TokenizerOption
Returns a reference to the text generator’s tokenizer Read more