pub struct LlamaTokenData { /* private fields */ }Expand description
A transparent wrapper around llama_token_data.
Do not rely on repr(transparent) for this type. It should be considered an implementation
detail and may change across minor versions.
Implementations§
Source§impl LlamaTokenData
impl LlamaTokenData
Sourcepub const fn new(LlamaToken: LlamaToken, logit: f32, p: f32) -> Self
pub const fn new(LlamaToken: LlamaToken, logit: f32, p: f32) -> Self
Create a new token data from a token, logit, and probability.
let token = LlamaToken::new(1);
let token_data = LlamaTokenData::new(token, 1.0, 1.0);Sourcepub const fn id(&self) -> LlamaToken
pub const fn id(&self) -> LlamaToken
Get the token’s id
let token = LlamaToken::new(1);
let token_data = LlamaTokenData::new(token, 1.0, 1.0);
assert_eq!(token_data.id(), token);Sourcepub const fn logit(&self) -> f32
pub const fn logit(&self) -> f32
Get the token’s logit
let token = LlamaToken::new(1);
let token_data = LlamaTokenData::new(token, 1.0, 1.0);
assert_eq!(token_data.logit(), 1.0);Sourcepub const fn p(&self) -> f32
pub const fn p(&self) -> f32
Get the token’s probability
let token = LlamaToken::new(1);
let token_data = LlamaTokenData::new(token, 1.0, 1.0);
assert_eq!(token_data.p(), 1.0);Sourcepub const fn set_id(&mut self, id: LlamaToken)
pub const fn set_id(&mut self, id: LlamaToken)
Set the token’s id
let token = LlamaToken::new(1);
let mut token_data = LlamaTokenData::new(token, 1.0, 1.0);
token_data.set_id(LlamaToken::new(2));
assert_eq!(token_data.id(), LlamaToken::new(2));Trait Implementations§
Source§impl Clone for LlamaTokenData
impl Clone for LlamaTokenData
Source§fn clone(&self) -> LlamaTokenData
fn clone(&self) -> LlamaTokenData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LlamaTokenData
impl Debug for LlamaTokenData
Source§impl PartialEq for LlamaTokenData
impl PartialEq for LlamaTokenData
impl Copy for LlamaTokenData
impl StructuralPartialEq for LlamaTokenData
Auto Trait Implementations§
impl Freeze for LlamaTokenData
impl RefUnwindSafe for LlamaTokenData
impl Send for LlamaTokenData
impl Sync for LlamaTokenData
impl Unpin for LlamaTokenData
impl UnsafeUnpin for LlamaTokenData
impl UnwindSafe for LlamaTokenData
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