Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
tokenizer.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
18#pragma once
19
20#include <cstdint>
21#include <string>
22#include <vector>
23
24namespace entropic {
25
40class Tokenizer {
41public:
42 virtual ~Tokenizer() = default;
43
51 virtual std::vector<int32_t> tokenize(
52 const std::string& text, bool add_special) const = 0;
53
60 virtual std::string detokenize(int32_t token) const = 0;
61
74 virtual int count_tokens(const std::string& text) const {
75 return static_cast<int>(tokenize(text, false).size());
76 }
77};
78
79} // namespace entropic
Pure-virtual tokenizer surface used by the inference backend.
Definition tokenizer.h:40
virtual int count_tokens(const std::string &text) const
Count tokens in text without retaining the IDs.
Definition tokenizer.h:74
virtual std::string detokenize(int32_t token) const =0
Decode a single token to its surface piece.
virtual std::vector< int32_t > tokenize(const std::string &text, bool add_special) const =0
Encode text to token IDs.
Activate model on GPU (WARM → ACTIVE).