Struct rust_bert::openai_gpt::OpenAIGenerator
source · [−]pub struct OpenAIGenerator { /* private fields */ }Expand description
Implementations
sourceimpl OpenAIGenerator
impl OpenAIGenerator
sourcepub fn new(
generate_config: GenerateConfig
) -> Result<OpenAIGenerator, RustBertError>
pub fn new(
generate_config: GenerateConfig
) -> Result<OpenAIGenerator, RustBertError>
Build a new OpenAIGenerator
Arguments
generate_config-GenerateConfigobject containing the resource references (model, vocabulary, configuration), generation options and device placement (CPU/GPU)
Example
use rust_bert::openai_gpt::OpenAIGenerator;
use rust_bert::pipelines::generation_utils::GenerateConfig;
let generate_config = GenerateConfig {
max_length: 30,
do_sample: true,
num_beams: 5,
temperature: 1.1,
num_return_sequences: 3,
..Default::default()
};
let gpt_generator = OpenAIGenerator::new(generate_config)?;pub fn new_with_tokenizer(
generate_config: GenerateConfig,
tokenizer: TokenizerOption
) -> Result<OpenAIGenerator, RustBertError>
Trait Implementations
sourceimpl LanguageGenerator<OpenAIGPTLMHeadModel, OpenAiGptVocab, OpenAiGptTokenizer> for OpenAIGenerator
impl LanguageGenerator<OpenAIGPTLMHeadModel, OpenAiGptVocab, OpenAiGptTokenizer> for OpenAIGenerator
sourcefn generate<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedTextOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator, where
S: AsRef<str> + Sync,
fn generate<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedTextOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator, where
S: AsRef<str> + Sync,
A: Allocator,
Generate text based on a vector of promp texts. Read more
sourcefn generate_indices<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator, where
S: AsRef<str> + Sync,
fn generate_indices<S>(
&self,
prompt_texts: Option<&[S]>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator, where
S: AsRef<str> + Sync,
A: Allocator,
Generate token indices without decoding (useful for token-level operations before returning final text or as validation step during training). Read more
sourcefn generate_from_ids_and_past(
&self,
input_ids: Tensor,
attention_mask: Option<Tensor>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn generate_from_ids_and_past(
&self,
input_ids: Tensor,
attention_mask: Option<Tensor>,
generate_options: Option<GenerateOptions<'_>>
) -> Vec<GeneratedIndicesOutput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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
sourcefn get_tokenizer(&self) -> &TokenizerOption
fn get_tokenizer(&self) -> &TokenizerOption
Returns a reference to the text generator’s tokenizer Read more
fn half(&mut self)
fn float(&mut self)
fn set_device(&mut self, device: Device)
Auto Trait Implementations
impl !RefUnwindSafe for OpenAIGenerator
impl Send for OpenAIGenerator
impl !Sync for OpenAIGenerator
impl Unpin for OpenAIGenerator
impl !UnwindSafe for OpenAIGenerator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more