#[non_exhaustive]pub struct Generation { /* private fields */ }Expand description
The result of one generate call: text, generated token count, why
it stopped, the mean token log-probability when asked for, and the
call’s metrics. Built by LocalModel implementations with new.
Implementations§
Source§impl Generation
impl Generation
Sourcepub fn new(
text: String,
tokens: usize,
stop: GenStop,
mean_logprob: Option<f64>,
metrics: LocalMetrics,
) -> Self
pub fn new( text: String, tokens: usize, stop: GenStop, mean_logprob: Option<f64>, metrics: LocalMetrics, ) -> Self
Builds a result from text, token count, stop reason, mean
log-prob (None unless asked for) and metrics.
Panics when the mean log-prob is above 0 or NaN.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Returns the generated text, stop string excluded. Input: none. Output: the text.
Sourcepub fn tokens(&self) -> usize
pub fn tokens(&self) -> usize
Returns how many tokens were generated. Input: none. Output: the count.
Sourcepub fn stop(&self) -> GenStop
pub fn stop(&self) -> GenStop
Returns why generation ended. Input: none. Output: the stop reason.
Sourcepub fn mean_logprob(&self) -> Option<f64>
pub fn mean_logprob(&self) -> Option<f64>
Returns the mean token log-probability.
Only set when GenParams::confidence was true.
Output: at most 0.
Sourcepub fn metrics(&self) -> &LocalMetrics
pub fn metrics(&self) -> &LocalMetrics
Returns the call’s speed and memory figures. Input: none. Output: the metrics.
Trait Implementations§
Source§impl Clone for Generation
impl Clone for Generation
Source§impl Debug for Generation
impl Debug for Generation
Source§impl PartialEq for Generation
impl PartialEq for Generation
impl StructuralPartialEq for Generation
Auto Trait Implementations§
impl Forget for Generation
impl Freeze for Generation
impl Move for Generation
impl RefUnwindSafe for Generation
impl Send for Generationwhere
RawVecInner: Send,
impl Sync for Generationwhere
RawVecInner: Sync,
impl Unpin for Generation
impl UnsafeUnpin for Generation
impl UnwindSafe for Generationwhere
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
Mutably borrows from an owned value. Read more