| 216 | } |
| 217 | |
| 218 | static 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+ |
| 237 | static std::vector<size_t> unicode_regex_split_custom_gpt2(const std::string & text, const std::vector<size_t> & offsets) { |
no test coverage detected