|
liblloyal 1.0.0
Composable primitives for llama.cpp inference
|
Functions | |
| std::vector< llama_token > | tokenize (const llama_vocab *vocab, const std::string &text, bool add_special, bool parse_special) |
| Tokenize text to token array. | |
| std::string | detokenize (const llama_vocab *vocab, llama_token token, bool special) |
| Detokenize SINGLE token to text (streaming use case) | |
| std::string | detokenize_batch (const llama_vocab *vocab, const llama_token *tokens, int32_t n_tokens, bool remove_special, bool unparse_special) |
| Detokenize TOKEN ARRAY to text (reconstruction use case) | |
| const llama_vocab * | get_vocab (const llama_model *model) |
| Get vocabulary from model. | |
| bool | is_eog (const llama_vocab *vocab, llama_token token) |
| Check if token is end-of-generation marker. | |
| int32_t | vocab_size (const llama_vocab *vocab) |
| Get vocabulary size (total number of tokens) | |
| std::vector< llama_token > | tokenize (const llama_model *model, const std::string &text) |
| Tokenize text to token array (model-accepting overload) | |
| std::string | detokenize (const llama_model *model, llama_token token, bool special=true) |
| Detokenize SINGLE token to text (model-accepting overload) | |
| std::string | detokenize_batch (const llama_model *model, const std::vector< llama_token > &tokens, bool remove_special=false, bool unparse_special=true) |
| Detokenize TOKEN VECTOR to text (convenience overload) | |
| std::string | detokenize_batch (const llama_model *model, const llama_token *tokens, int32_t n_tokens, bool remove_special, bool unparse_special) |
| Detokenize TOKEN ARRAY to text (model-accepting overload) | |
| bool | is_eog (const llama_model *model, llama_token token) |
| Check if token is end-of-generation marker (model-accepting overload) | |
| int32_t | vocab_size (const llama_model *model) |
| Get vocabulary size (model-accepting overload) | |
|
inline |
Detokenize SINGLE token to text (model-accepting overload)
| model | Llama model |
| token | Token ID to convert |
| special | Enable special token rendering (default: true) |
Definition at line 289 of file tokenizer.hpp.
|
inline |
Detokenize SINGLE token to text (streaming use case)
Fast synchronous operation for per-token conversion during generation. AVOID CONFUSION: This is NOT llama_decode (KV cache update).
| vocab | Vocabulary from llama_model_get_vocab() |
| token | Token ID to convert |
| special | Enable special token rendering (e.g., "<|im_start|>") |
Definition at line 91 of file tokenizer.hpp.
|
inline |
Detokenize TOKEN ARRAY to text (model-accepting overload)
| model | Llama model |
| tokens | Array of token IDs |
| n_tokens | Number of tokens in array |
| remove_special | Remove BOS/EOS tokens from output |
| unparse_special | Render special tokens as text |
Definition at line 348 of file tokenizer.hpp.
|
inline |
Detokenize TOKEN VECTOR to text (convenience overload)
Accepts std::vector instead of raw pointer for safer API.
| model | Llama model |
| tokens | Vector of token IDs |
| remove_special | Remove BOS/EOS tokens from output (default: false) |
| unparse_special | Render special tokens as text (default: true) |
Definition at line 316 of file tokenizer.hpp.
|
inline |
Detokenize TOKEN ARRAY to text (reconstruction use case)
Batch operation for reconstructing complete text from token sequences. AVOID CONFUSION: This is NOT llama_decode (KV cache update).
| vocab | Vocabulary from llama_model_get_vocab() |
| tokens | Array of token IDs |
| n_tokens | Number of tokens in array |
| remove_special | Remove BOS/EOS tokens from output |
| unparse_special | Render special tokens as text (e.g., "<|im_start|>") |
Definition at line 137 of file tokenizer.hpp.
|
inline |
Get vocabulary from model.
Simple accessor that wraps llama_model_get_vocab(). Isolates direct llama.cpp model API dependency.
| model | Llama model |
Definition at line 196 of file tokenizer.hpp.
|
inline |
Check if token is end-of-generation marker (model-accepting overload)
| model | Llama model |
| token | Token ID to check |
Definition at line 375 of file tokenizer.hpp.
|
inline |
Check if token is end-of-generation marker.
| vocab | Vocabulary from get_vocab() |
| token | Token ID to check |
Definition at line 218 of file tokenizer.hpp.
|
inline |
Tokenize text to token array (model-accepting overload)
Convenience wrapper that handles:
| model | Llama model |
| text | Text to tokenize |
Definition at line 264 of file tokenizer.hpp.
|
inline |
Tokenize text to token array.
| vocab | Vocabulary from llama_model_get_vocab() |
| text | Text to tokenize |
| add_special | Add special tokens (BOS/EOS) if model configured |
| parse_special | Parse special token strings like "<|im_start|>" |
Definition at line 38 of file tokenizer.hpp.
|
inline |
Get vocabulary size (model-accepting overload)
| model | Llama model |
Definition at line 396 of file tokenizer.hpp.
|
inline |
Get vocabulary size (total number of tokens)
| vocab | Vocabulary from get_vocab() |
Definition at line 233 of file tokenizer.hpp.