pub struct Stopping<'a> {
pub maximum_tokens: Option<u32>,
pub stop_sequences: &'a [&'a str],
}
Expand description
Controls the conditions under which the language models stops generating text.
Fields§
§maximum_tokens: Option<u32>
The maximum number of tokens to be generated. Completion will terminate after the maximum number of tokens is reached. Increase this value to allow for longer outputs. A text is split into tokens. Usually there are more tokens than words. The total number of tokens of prompt and maximum_tokens depends on the model. If maximum tokens is set to None, no outside limit is opposed on the number of maximum tokens. The model will generate tokens until it generates one of the specified stop_sequences or it reaches its technical limit, which usually is its context window.
stop_sequences: &'a [&'a str]
List of strings which will stop generation if they are generated. Stop sequences are helpful in structured texts. E.g.: In a question answering scenario a text may consist of lines starting with either “Question: “ or “Answer: “ (alternating). After producing an answer, the model will be likely to generate “Question: “. “Question: “ may therefore be used as stop sequence in order not to have the model generate more questions but rather restrict text generation to the answers.
Implementations§
Source§impl<'a> Stopping<'a>
impl<'a> Stopping<'a>
Sourcepub const NO_TOKEN_LIMIT: Self
pub const NO_TOKEN_LIMIT: Self
Only stop once the model reaches its technical limit, usually the context window.
Sourcepub fn from_maximum_tokens(maximum_tokens: u32) -> Self
pub fn from_maximum_tokens(maximum_tokens: u32) -> Self
Stop once the model has reached maximum_tokens.
pub fn from_stop_sequences(stop_sequences: &'a [&'a str]) -> Self
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Stopping<'a>
impl<'a> RefUnwindSafe for Stopping<'a>
impl<'a> Send for Stopping<'a>
impl<'a> Sync for Stopping<'a>
impl<'a> Unpin for Stopping<'a>
impl<'a> UnwindSafe for Stopping<'a>
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
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.