diff options
author | Jared Van Bortel <jared@nomic.ai> | 2023-11-15 11:34:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 11:34:47 -0500 |
commit | a6fc554e268634494f33b0de76f9dde650dd292f (patch) | |
tree | a4e9fe3a98858a726e046d415bb588cd245bc286 /llama.cpp | |
parent | 1cf2850d52bb027aa215e039ed9a0c61beeef8d3 (diff) |
llama : restore prefix space in llama tokenizer (#4081)
Diffstat (limited to 'llama.cpp')
-rw-r--r-- | llama.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -6283,7 +6283,10 @@ static std::vector<llama_vocab::id> llama_tokenize_internal(const llama_vocab & // by modifying llm_tokenizer_x to operate with string offsets like pre-tokenizer // and passing 'add space prefix' as bool argument // - auto raw_text = (special ? "" : " ") + fragment.raw_text.substr(fragment.offset, fragment.length); + auto raw_text = fragment.raw_text.substr(fragment.offset, fragment.length); + if (&fragment == &fragment_buffer.front()) { + raw_text = " " + raw_text; // prefix with space if the first token is not special + } #ifdef PRETOKENIZERDEBUG fprintf(stderr,"TT: (%ld %ld %ld) '%s'\n", raw_text.length(), fragment.offset, fragment.length, raw_text.c_str()); |