|
Entropic 2.9.4
Local-first agentic inference engine
|
Pure-virtual tokenizer surface used by the inference backend. More...
#include <entropic/inference/tokenizer.h>

Public Member Functions | |
| virtual std::vector< int32_t > | tokenize (const std::string &text, bool add_special) const =0 |
| Encode text to token IDs. | |
| virtual std::string | detokenize (int32_t token) const =0 |
| Decode a single token to its surface piece. | |
| virtual int | count_tokens (const std::string &text) const |
| Count tokens in text without retaining the IDs. | |
Pure-virtual tokenizer surface used by the inference backend.
Three responsibilities:
Implementations may be lossy (count is exact when model is loaded, estimate otherwise) but must never throw and must never crash on empty inputs. Callers treat returned vectors as authoritative.
Definition at line 40 of file tokenizer.h.
|
inlinevirtual |
Count tokens in text without retaining the IDs.
Default implementation invokes tokenize() and returns size(). Overrides may use a faster path (e.g., model size-prediction without actual allocation).
| text | UTF-8 input. |
Definition at line 74 of file tokenizer.h.
|
pure virtual |
Decode a single token to its surface piece.
| token | Token ID. |
Implemented in entropic::LlamaCppTokenizer.
|
pure virtual |
Encode text to token IDs.
| text | UTF-8 input. |
| add_special | Insert model-specific BOS/EOS specials when true. |
Implemented in entropic::LlamaCppTokenizer.