MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / unicode_byte_encoding_process

Function unicode_byte_encoding_process

smallthinker/src/unicode.cpp:218–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218static std::vector<std::string> unicode_byte_encoding_process(const std::vector<std::string> & bpe_words) {
219 std::vector<std::string> bpe_encoded_words;
220 for (const auto & word : bpe_words) {
221 std::string text_utf;
222 auto utf_word = unicode_cpts_from_utf8(word);
223 for (size_t i = 0; i < utf_word.size(); ++i) {
224 text_utf += unicode_cpt_to_utf8(utf_word[i]);
225 }
226
227 std::string encoded_token;
228 for (char & c : text_utf) {
229 encoded_token += unicode_byte_to_utf8(c);
230 }
231 bpe_encoded_words.emplace_back(encoded_token);
232 }
233 return bpe_encoded_words;
234}
235
236// GPT2 system regex: 's|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+
237static 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