| 7051 | } |
| 7052 | |
| 7053 | static llama_token llama_byte_to_token(const llama_vocab & vocab, uint8_t ch) { |
| 7054 | static const char * hex = "0123456789ABCDEF"; |
| 7055 | switch (llama_vocab_get_type(vocab)) { |
| 7056 | case LLAMA_VOCAB_TYPE_SPM: { |
| 7057 | const char buf[7] = { '<', '0', 'x', hex[ch >> 4], hex[ch & 15], '>', 0 }; |
| 7058 | return vocab.token_to_id.at(buf); |
| 7059 | } |
| 7060 | case LLAMA_VOCAB_TYPE_BPE: { |
| 7061 | return vocab.token_to_id.at(bytes_to_unicode_bpe(ch)); |
| 7062 | } |
| 7063 | default: |
| 7064 | GGML_ASSERT(false); |
| 7065 | } |
| 7066 | } |
| 7067 | |
| 7068 | static void llama_escape_whitespace(std::string & text) { |
| 7069 | replace_all(text, " ", "\xe2\x96\x81"); |
no test coverage detected