pub struct LlamaVocab { /* private fields */ }Expand description
A safe wrapper around llama_vocab.
Implementations§
Source§impl LlamaVocab
impl LlamaVocab
Sourcepub fn vocab_type(&self) -> u32
pub fn vocab_type(&self) -> u32
Get the vocabulary type.
Sourcepub fn bos(&self) -> LlamaToken
pub fn bos(&self) -> LlamaToken
Get the BOS token.
Sourcepub fn eos(&self) -> LlamaToken
pub fn eos(&self) -> LlamaToken
Get the EOS token.
Sourcepub fn eot(&self) -> LlamaToken
pub fn eot(&self) -> LlamaToken
Get the EOT (end of turn) token.
Sourcepub fn cls(&self) -> LlamaToken
pub fn cls(&self) -> LlamaToken
Get the CLS (classification) token.
Sourcepub fn sep(&self) -> LlamaToken
pub fn sep(&self) -> LlamaToken
Get the SEP (separator) token.
Sourcepub fn nl(&self) -> LlamaToken
pub fn nl(&self) -> LlamaToken
Get the NL (newline) token.
Sourcepub fn pad(&self) -> LlamaToken
pub fn pad(&self) -> LlamaToken
Get the PAD (padding) token.
Sourcepub fn fim_pre(&self) -> LlamaToken
pub fn fim_pre(&self) -> LlamaToken
Get the FIM prefix token.
Sourcepub fn fim_suf(&self) -> LlamaToken
pub fn fim_suf(&self) -> LlamaToken
Get the FIM suffix token.
Sourcepub fn fim_mid(&self) -> LlamaToken
pub fn fim_mid(&self) -> LlamaToken
Get the FIM middle token.
Sourcepub fn fim_pad(&self) -> LlamaToken
pub fn fim_pad(&self) -> LlamaToken
Get the FIM padding token.
Sourcepub fn fim_rep(&self) -> LlamaToken
pub fn fim_rep(&self) -> LlamaToken
Get the FIM repository token.
Sourcepub fn fim_sep(&self) -> LlamaToken
pub fn fim_sep(&self) -> LlamaToken
Get the FIM separator token.
Sourcepub fn get_add_bos(&self) -> bool
pub fn get_add_bos(&self) -> bool
Check whether BOS should be added.
Sourcepub fn get_add_eos(&self) -> bool
pub fn get_add_eos(&self) -> bool
Check whether EOS should be added.
Sourcepub fn get_add_sep(&self) -> bool
pub fn get_add_sep(&self) -> bool
Check whether SEP should be added.
Sourcepub fn get_text(&self, token: LlamaToken) -> Result<&str, StringFromModelError>
pub fn get_text(&self, token: LlamaToken) -> Result<&str, StringFromModelError>
Get the text representation of a token.
§Errors
Returns an error if the text pointer is null or not valid UTF-8.
Sourcepub fn get_score(&self, token: LlamaToken) -> f32
pub fn get_score(&self, token: LlamaToken) -> f32
Get the score of a token.
Sourcepub fn get_attr(&self, token: LlamaToken) -> u32
pub fn get_attr(&self, token: LlamaToken) -> u32
Get the attributes of a token.
Sourcepub fn is_control(&self, token: LlamaToken) -> bool
pub fn is_control(&self, token: LlamaToken) -> bool
Check if a token is a control token.
Sourcepub fn is_eog(&self, token: LlamaToken) -> bool
pub fn is_eog(&self, token: LlamaToken) -> bool
Check if a token is an end-of-generation token.
Sourcepub fn mask(&self) -> LlamaToken
pub fn mask(&self) -> LlamaToken
Get the token mask value for the vocabulary.