pub enum Sampler {
Greedy,
Sample {
temperature: f32,
top_k: Option<usize>,
},
}Expand description
Sampling strategy for one token.
Variants§
Greedy
Deterministic argmax.
Sample
Stochastic sampling with temperature and optional top-k truncation (the truncated distribution is renormalized, matching replay requirements).
Implementations§
Source§impl Sampler
impl Sampler
Sourcepub fn behavior_logprob(&self, logits: &Tensor, token: u32) -> Result<f32>
pub fn behavior_logprob(&self, logits: &Tensor, token: u32) -> Result<f32>
log-probability of token under this sampler’s ACTUAL sampling distribution
(paper §5.3: behavior log-probabilities must describe the distribution that
produced the action, including temperature and truncation/renormalization).
Greedy: point mass at the argmax — 0.0 for the argmax, −∞ otherwise.Sample: logits scaled by 1/temperature, optionally top-k truncated; a token outside the candidate set has probability 0 (−∞ log-prob). For temperature 1.0 without top-k this equals the model’s full-vocab log-prob.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Sampler
impl Freeze for Sampler
impl RefUnwindSafe for Sampler
impl Send for Sampler
impl Sync for Sampler
impl Unpin for Sampler
impl UnsafeUnpin for Sampler
impl UnwindSafe for Sampler
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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