pub struct DraftDist { /* private fields */ }Expand description
The distribution one drafted position was sampled from, as its
complete support: (token id, probability) pairs summing to 1.
Sparse rather than a dense vocabulary-length vector because the distributions drafters actually produce are sparse: a prompt-lookup drafter’s support is a single token, and a real drafter’s is a top-k, not 150k floats per drafted position per step.
§Contract
The support must be the distribution the draft token was actually
sampled from. Losslessness does not require the drafter to be good,
or even sane – the rejection rule corrects any q – but it does
require q to be honest. A drafter that truncates its own softmax
to a top-k before sampling must report the truncated, renormalised
distribution, not the full softmax it started from.
Implementations§
Source§impl DraftDist
impl DraftDist
Sourcepub fn deterministic(token: usize) -> Self
pub fn deterministic(token: usize) -> Self
A drafter that is certain: all probability on one token. This is what a lookup-table drafter honestly reports – it did not sample, it asserted.
Sourcepub fn from_dense(probs: &[f32]) -> Self
pub fn from_dense(probs: &[f32]) -> Self
The nonzero entries of a dense probability vector.
Sourcepub fn from_support(support: Vec<(usize, f32)>) -> Self
pub fn from_support(support: Vec<(usize, f32)>) -> Self
Builds from explicit (token, probability) pairs.
pub fn support(&self) -> &[(usize, f32)]
Trait Implementations§
impl StructuralPartialEq for DraftDist
Auto Trait Implementations§
impl Freeze for DraftDist
impl RefUnwindSafe for DraftDist
impl Send for DraftDist
impl Sync for DraftDist
impl Unpin for DraftDist
impl UnsafeUnpin for DraftDist
impl UnwindSafe for DraftDist
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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