Loading...
Searching...
No Matches
tokenizer_operator.h
Go to the documentation of this file.
void load(const filesystem::path &vocabulary_json, const filesystem::path &merges_txt)
unique_ptr< TokenizerOperator > clone() const override
Definition tokenizer_operator.h:171
void tokenize_into(string_view, vector< string > *, vector< Index > *) const
void build_vocabulary(const vector< vector< string > > &, Index, Index) override
Definition tokenizer_operator.h:164
BytePairTokenizer(const filesystem::path &vocabulary_json, const filesystem::path &merges_txt)
virtual vector< string > pre_tokenize(string_view text) const
BytePairTokenizer()
string_view get_kind() const override
Definition tokenizer_operator.h:172
void set_merges(const vector< string > &)
bool supports_incremental_decode() const noexcept override
Definition tokenizer_operator.h:162
void from_JSON(const Json *) override
static constexpr string_view PAD_TOKEN
Definition tokenizer_operator.h:178
StringMap< int > merge_ranks
Definition tokenizer_operator.h:190
vector< string > get_merges() const
unordered_map< uint32_t, unsigned char > byte_decoder
Definition tokenizer_operator.h:189
vector< string > bpe(const string &token) const
vector< Index > encode(string_view text) const override
string decode(const vector< Index > &ids) const override
unordered_set< Index > special_ids
Definition tokenizer_operator.h:194
string decode_token(Index id) const override
array< uint32_t, 256 > byte_encoder
Definition tokenizer_operator.h:188
vector< string > tokenize(string_view text) const override
Index get_special_token_id(string_view) const
void set_vocabulary(const vector< string > &) override
void set_special_tokens(const vector< string > &)
shared_ptr< Cache > bpe_cache
Definition tokenizer_operator.h:192
uint64_t fingerprint() const override
vector< string > special_strings
Definition tokenizer_operator.h:193
void to_JSON(JsonWriter &) const override
Definition json.h:92
Definition json.h:24
void load(const filesystem::path &vocabulary_json, const filesystem::path &merges_txt, const filesystem::path &special_tokens_tsv)
Index get_im_start_id() const
Definition tokenizer_operator.h:208
unique_ptr< TokenizerOperator > clone() const override
Definition tokenizer_operator.h:212
Qwen3Tokenizer()=default
string_view get_kind() const override
Definition tokenizer_operator.h:213
vector< string > pre_tokenize(string_view text) const override
Qwen3Tokenizer(const filesystem::path &directory)
Index get_endoftext_id() const
Definition tokenizer_operator.h:210
Definition tokenizer_operator.h:35
VocabularyMap vocabulary_map
Definition tokenizer_operator.h:83
virtual vector< Index > encode(string_view text) const
vector< Index > frame_sequence(span< const Index >, Index sequence_length) const
void from_JSON(const Json *) override
virtual string decode(const vector< Index > &ids) const
Index token_to_id(string_view token) const
virtual string_view get_kind() const =0
virtual void build_vocabulary(const vector< vector< string > > &documents, Index maximum_vocabulary_size, Index minimum_token_frequency)
void to_JSON(JsonWriter &) const override
vector< Index > encode_sequence(const vector< string > &tokens, Index sequence_length) const
const string & id_to_token(Index id) const
vector< string > reserved_tokens
Definition tokenizer_operator.h:77
void rebuild_map()
virtual string decode_token(Index id) const
const VocabularyMap & get_vocabulary_map() const noexcept
Definition tokenizer_operator.h:48
virtual void set_vocabulary(const vector< string > &)
static constexpr Index UNK_INDEX
Definition tokenizer_operator.h:54
const vector< string > & get_vocabulary() const noexcept
Definition tokenizer_operator.h:46
virtual uint64_t fingerprint() const
StringMap< Index > VocabularyMap
Definition tokenizer_operator.h:37
Index get_vocabulary_size() const noexcept
Definition tokenizer_operator.h:49
virtual vector< string > tokenize(string_view text) const =0
virtual bool supports_incremental_decode() const noexcept
Definition tokenizer_operator.h:64
const vector< string > & get_reserved_tokens() const noexcept
Definition tokenizer_operator.h:47
virtual unique_ptr< TokenizerOperator > clone() const =0
static constexpr Index START_INDEX
Definition tokenizer_operator.h:55
vector< Index > encode_sequence(string_view text, Index sequence_length) const
static constexpr Index END_INDEX
Definition tokenizer_operator.h:56
Index get_unk_id() const noexcept
Definition tokenizer_operator.h:66
void to_JSON(JsonWriter &) const override
void from_JSON(const Json *) override
uint64_t fingerprint() const override
WordLevelTokenizer()
WordLevelTokenizer(vector< string > reserved_tokens)
vector< string > tokenize(string_view text) const override
unique_ptr< TokenizerOperator > clone() const override
Definition tokenizer_operator.h:101
vector< Index > encode(string_view text) const override
string_view get_kind() const override
Definition tokenizer_operator.h:102
unique_ptr< TokenizerOperator > clone() const override
Definition tokenizer_operator.h:127
void from_JSON(const Json *) override
vector< Index > encode(string_view text) const override
void build_vocabulary(const vector< vector< string > > &, Index, Index) override
Definition tokenizer_operator.h:123
WordPieceTokenizer()=default
void set_vocabulary(const vector< string > &) override
void set_lower_case(bool value) noexcept
Definition tokenizer_operator.h:125
void to_JSON(JsonWriter &) const override
void load_vocabulary(const filesystem::path &vocabulary_file)
string_view get_kind() const override
Definition tokenizer_operator.h:128
uint64_t fingerprint() const override
WordPieceTokenizer(const vector< string > &vocabulary)
vector< string > tokenize(string_view text) const override
Definition configuration.h:10
constexpr size_t utf8_sequence_length(unsigned char lead) noexcept
Definition tokenizer_operator.h:21
unique_ptr< TokenizerOperator > make_tokenizer_operator(string_view kind)
constexpr bool is_utf8_continuation(unsigned char byte) noexcept
Definition tokenizer_operator.h:29
unordered_map< string, Value, TransparentStringHash, equal_to<> > StringMap
Definition string_utilities.h:72
vector< string > make_vocabulary(const unordered_map< string_view, size_t > &, span< const string > reserved_tokens, Index maximum_size, Index minimum_frequency)
Definition operator.h:28