pub struct Vocabulary { /* private fields */ }Expand description
Vocabulary for a large language model.
Implementations§
Source§impl Vocabulary
impl Vocabulary
Sourcepub fn tokens(&self) -> &HashMap<Vec<u8>, Vec<u32>>
pub fn tokens(&self) -> &HashMap<Vec<u8>, Vec<u32>>
Returns all tokens with their token ids in vocabulary.
Sourcepub fn token_ids(&self, token: impl AsRef<[u8]>) -> Option<&[u32]>
pub fn token_ids(&self, token: impl AsRef<[u8]>) -> Option<&[u32]>
Returns all token ids per provided token if available in the vocabulary.
Sourcepub fn eos_token_id(&self) -> u32
pub fn eos_token_id(&self) -> u32
Gets the identifier of the special end of the sentence token.
Sourcepub fn try_insert(
&mut self,
token: impl Into<Vec<u8>>,
id: u32,
) -> Result<(), Error>
pub fn try_insert( &mut self, token: impl Into<Vec<u8>>, id: u32, ) -> Result<(), Error>
Inserts a token with the given id. Idempotent: repeating (token, id) is a no-op.
A different id under the same bytes is still kept.
Trait Implementations§
Source§impl Clone for Vocabulary
impl Clone for Vocabulary
Source§impl Debug for Vocabulary
impl Debug for Vocabulary
Source§impl Default for Vocabulary
impl Default for Vocabulary
Source§impl Display for Vocabulary
impl Display for Vocabulary
Source§impl PartialEq for Vocabulary
impl PartialEq for Vocabulary
impl StructuralPartialEq for Vocabulary
Auto Trait Implementations§
impl Freeze for Vocabulary
impl RefUnwindSafe for Vocabulary
impl Send for Vocabulary
impl Sync for Vocabulary
impl Unpin for Vocabulary
impl UnsafeUnpin 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