pub struct T5Generator { /* private fields */ }
Implementations§
Source§impl T5Generator
impl T5Generator
pub fn new( generate_config: GenerateConfig, ) -> Result<T5Generator, RustBertError>
pub fn new_with_tokenizer( generate_config: GenerateConfig, tokenizer: TokenizerOption, ) -> Result<T5Generator, RustBertError>
Trait Implementations§
Source§impl LanguageGenerator for T5Generator
impl LanguageGenerator for T5Generator
Source§fn generate<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>,
) -> Result<Vec<GeneratedTextOutput>, RustBertError>
fn generate<S>( &self, prompt_texts: Option<&[S]>, generate_options: Option<GenerateOptions<'_>>, ) -> Result<Vec<GeneratedTextOutput>, RustBertError>
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<'_>>,
) -> Result<Vec<GeneratedIndicesOutput>, RustBertError>
fn generate_indices<S>( &self, prompt_texts: Option<&[S]>, generate_options: Option<GenerateOptions<'_>>, ) -> Result<Vec<GeneratedIndicesOutput>, RustBertError>
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<'_>>,
) -> Result<Vec<GeneratedIndicesOutput>, RustBertError>
fn generate_from_ids_and_past( &self, input_ids: Tensor, attention_mask: Option<Tensor>, generate_options: Option<GenerateOptions<'_>>, ) -> Result<Vec<GeneratedIndicesOutput>, RustBertError>
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
fn get_tokenizer_mut(&mut self) -> &mut TokenizerOption
fn half(&mut self) -> Result<(), RustBertError>
fn float(&mut self) -> Result<(), RustBertError>
fn set_device(&mut self, device: Device) -> Result<(), RustBertError>
Auto Trait Implementations§
impl !Freeze for T5Generator
impl !RefUnwindSafe for T5Generator
impl Send for T5Generator
impl !Sync for T5Generator
impl Unpin for T5Generator
impl !UnwindSafe for T5Generator
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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