pub struct LlamaLogitBias { /* private fields */ }
Expand description
A transparent wrapper around llama_logit_bias
.
Represents a bias to be applied to a specific token during text generation. The bias modifies the likelihood of the token being selected.
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 LlamaLogitBias
impl LlamaLogitBias
Sourcepub fn new(LlamaToken: LlamaToken, bias: f32) -> Self
pub fn new(LlamaToken: LlamaToken, bias: f32) -> Self
Creates a new logit bias for a specific token with the given bias value.
§Examples
let token = LlamaToken::new(1);
let bias = LlamaLogitBias::new(token, 1.5);
Sourcepub fn token(&self) -> LlamaToken
pub fn token(&self) -> LlamaToken
Gets the token this bias applies to.
§Examples
let token = LlamaToken::new(1);
let bias = LlamaLogitBias::new(token, 1.5);
assert_eq!(bias.token(), token);
Sourcepub fn bias(&self) -> f32
pub fn bias(&self) -> f32
Gets the bias value.
§Examples
let token = LlamaToken::new(1);
let bias = LlamaLogitBias::new(token, 1.5);
assert_eq!(bias.bias(), 1.5);
Sourcepub fn set_token(&mut self, token: LlamaToken)
pub fn set_token(&mut self, token: LlamaToken)
Sets the token this bias applies to.
§Examples
let token = LlamaToken::new(1);
let mut bias = LlamaLogitBias::new(token, 1.5);
let new_token = LlamaToken::new(2);
bias.set_token(new_token);
assert_eq!(bias.token(), new_token);
Trait Implementations§
Source§impl Clone for LlamaLogitBias
impl Clone for LlamaLogitBias
Source§fn clone(&self) -> LlamaLogitBias
fn clone(&self) -> LlamaLogitBias
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 LlamaLogitBias
impl Debug for LlamaLogitBias
Source§impl PartialEq for LlamaLogitBias
impl PartialEq for LlamaLogitBias
impl Copy for LlamaLogitBias
impl StructuralPartialEq for LlamaLogitBias
Auto Trait Implementations§
impl Freeze for LlamaLogitBias
impl RefUnwindSafe for LlamaLogitBias
impl Send for LlamaLogitBias
impl Sync for LlamaLogitBias
impl Unpin for LlamaLogitBias
impl UnwindSafe for LlamaLogitBias
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