pub struct Vocabulary {
pub id_to_token: Vec<Vec<u8>>,
pub id_to_token_score: Vec<f32>,
pub token_to_id: HashMap<Vec<u8>, TokenId>,
pub max_token_length: usize,
}
Expand description
The vocabulary used by a model.
Fields§
§id_to_token: Vec<Vec<u8>>
Maps every integer (index) token ID to its corresponding token.
id_to_token_score: Vec<f32>
Maps every integer (index) token ID to corresponding score.
token_to_id: HashMap<Vec<u8>, TokenId>
Maps a token to a token ID.
max_token_length: usize
The longest token in this vocabulary.
Implementations§
Source§impl Vocabulary
impl Vocabulary
Sourcepub fn push_token(&mut self, id: TokenId, content: Vec<u8>, score: f32)
pub fn push_token(&mut self, id: TokenId, content: Vec<u8>, score: f32)
Add a token to the vocabulary.
The token added must have id
directly after the last token in the vocabulary.
§Panics
- This function can panic if
id
does not correspond to the next token in the vocabulary. That is, if there are alreadyn
tokens in the vocabulary, thenid
must ben
.
Trait Implementations§
Source§impl Clone for Vocabulary
impl Clone for Vocabulary
Source§fn clone(&self) -> Vocabulary
fn clone(&self) -> Vocabulary
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Vocabulary
impl Debug for Vocabulary
Source§impl Default for Vocabulary
impl Default for Vocabulary
Source§fn default() -> Vocabulary
fn default() -> Vocabulary
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Vocabulary
impl RefUnwindSafe for Vocabulary
impl Send for Vocabulary
impl Sync for Vocabulary
impl Unpin for Vocabulary
impl UnwindSafe for Vocabulary
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