|
Entropic 2.9.4
Local-first agentic inference engine
|
Tokenizer adapter that forwards to llama.cpp's vocab API. More...
#include </home/runner/work/entropic/entropic/src/inference/llama_cpp_tokenizer.h>


Public Member Functions | |
| LlamaCppTokenizer (const llama_vocab *vocab) | |
| Construct with a borrowed vocab pointer. | |
| std::vector< int32_t > | tokenize (const std::string &text, bool add_special) const override |
| Encode text into token ids via the wrapped vocab. | |
| std::string | detokenize (int32_t token) const override |
| Decode a single token id to its surface string. | |
Public Member Functions inherited from entropic::Tokenizer | |
| virtual int | count_tokens (const std::string &text) const |
| Count tokens in text without retaining the IDs. | |
Tokenizer adapter that forwards to llama.cpp's vocab API.
Borrowing semantics: vocab pointer is owned by the model. Caller (LlamaCppBackend) must ensure the model outlives the tokenizer.
Definition at line 35 of file llama_cpp_tokenizer.h.
|
explicit |
Construct with a borrowed vocab pointer.
Construct a tokenizer borrowing a llama_vocab pointer.
| vocab | Non-owning pointer; must outlive this tokenizer. |
vocab is borrowed, not owned — its lifetime must outlive this object. LlamaCppBackend resets the tokenizer before freeing the backing llama_model so the borrow never dangles.
Definition at line 37 of file llama_cpp_tokenizer.cpp.
|
overridevirtual |
Decode a single token id to its surface string.
special=false — special tokens (BOS, EOS, channel markers) do not render to surface text. History (gh#68, gh#65): defensive flag is kept regardless of whether the current model fleet emits special tokens, since the seam is shared across families.
| token | Token id to decode. |
Implements entropic::Tokenizer.
Definition at line 86 of file llama_cpp_tokenizer.cpp.
|
overridevirtual |
Encode text into token ids via the wrapped vocab.
| text | Input string (any UTF-8). |
| add_special | True to prepend BOS / model-defined special tokens. |
Implements entropic::Tokenizer.
Definition at line 49 of file llama_cpp_tokenizer.cpp.