| 94 | } |
| 95 | |
| 96 | std::string Tokenizer::encoding_to_debug_string(const std::vector<int>& encoding) const { |
| 97 | std::string token_encoding_debug_str = ""; |
| 98 | for (int token_id : encoding) { |
| 99 | if (token_id == bos_id) { |
| 100 | token_encoding_debug_str += "[<s>:" + std::to_string(token_id) + "]"; |
| 101 | } else if (token_id == eos_id) { |
| 102 | token_encoding_debug_str += "[</s>:" + std::to_string(token_id) + "]"; |
| 103 | } else { |
| 104 | token_encoding_debug_str += "[" + vocab[token_id] + ":" + std::to_string(token_id) + "]"; |
| 105 | } |
| 106 | } |
| 107 | return token_encoding_debug_str; |
| 108 | } |