MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / unicode_byte_encoding_process

Function unicode_byte_encoding_process

external/llama_tokenizer/unicode.cpp:196–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196static std::vector<std::string> unicode_byte_encoding_process(const std::vector<std::string> & bpe_words) {
197 std::vector<std::string> bpe_encoded_words;
198 for (const auto & word : bpe_words) {
199 std::string text_utf;
200 auto utf_word = unicode_cpts_from_utf8(word);
201 for (size_t i = 0; i < utf_word.size(); ++i) {
202 text_utf += unicode_cpt_to_utf8(utf_word[i]);
203 }
204
205 std::string encoded_token;
206 for (char & c : text_utf) {
207 encoded_token += unicode_byte_to_utf8(c);
208 }
209 bpe_encoded_words.emplace_back(encoded_token);
210 }
211 return bpe_encoded_words;
212}
213
214// GPT2 system regex: 's|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+
215static std::vector<size_t> unicode_regex_split_custom_gpt2(const std::string & text, const std::vector<size_t> & offsets) {

Callers 1

unicode_regex_splitFunction · 0.85

Calls 4

unicode_cpts_from_utf8Function · 0.85
unicode_cpt_to_utf8Function · 0.85
unicode_byte_to_utf8Function · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected