pub struct LogprobStops { /* private fields */ }Expand description
A StopMatcher that carries each token’s log probability along with the text it produced, so
the entries a reply reports are exactly those of the tokens whose text it returns. Shared by the
chat route and /v1/completions.
Text arrives as the decoder releases it: one piece and the entries of every token since the previous piece (a character split across tokens, or a special token the stream skips, adds no piece of its own). Such a group is the unit entries are attached to; this never assumes a token’s own bytes add up to the streamed text.
The rule: an entry is reported when its token’s text is at least partly returned. A token whose text a stop sequence cut in the middle keeps its entry, which still describes the whole sampled token, as every entry does; the tokens of the stop sequence itself, and any after it, have none. Entries pushed with no text cover nothing returned and are dropped.
Implementations§
Source§impl LogprobStops
impl LogprobStops
pub fn new(stops: Vec<String>) -> Self
Sourcepub fn hit(&self) -> bool
pub fn hit(&self) -> bool
A stop sequence has fired: generation must halt and no further text may be emitted.
Sourcepub fn push(
&mut self,
piece: &str,
logprobs: Vec<TokenLogprob>,
) -> Vec<TokenText>
pub fn push( &mut self, piece: &str, logprobs: Vec<TokenLogprob>, ) -> Vec<TokenText>
Feed one decoded piece and the entries of the tokens that produced it. Returns the text now
safe to send, split where it changes group so a caller can keep a delta from splitting a
token. A group with entries is handed out whole, so its text waits while the matcher holds
any of it; text without entries is handed out as the matcher releases it, so a request that
asked for no log probabilities streams exactly as through a bare StopMatcher.
Trait Implementations§
Source§impl Debug for LogprobStops
impl Debug for LogprobStops
Auto Trait Implementations§
impl Forget for LogprobStops
impl Freeze for LogprobStopswhere
*const u8 is !null: Freeze,
PhantomData<String>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Group>: Freeze,
impl Move for LogprobStops
impl RefUnwindSafe for LogprobStops
impl Send for LogprobStopswhere
RawVecInner: Send,
impl Sync for LogprobStopswhere
RawVecInner: Sync,
impl Unpin for LogprobStops
impl UnsafeUnpin for LogprobStopswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Group>: UnsafeUnpin,
impl UnwindSafe for LogprobStopswhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more