From 9eb0fca02756b7a35ed9228c8666e121970404d9 Mon Sep 17 00:00:00 2001 From: jaime-m-p <> Date: Mon, 24 Jun 2024 20:37:48 +0200 Subject: [PATCH] Do not remove space when decoding special tokens --- llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index 61788d403..4bc5a631b 100644 --- a/llama.cpp +++ b/llama.cpp @@ -18506,7 +18506,7 @@ int32_t llama_detokenize( bool special) { // remove the leading space of the first non-control token static const int attr_special = LLAMA_TOKEN_ATTR_UNKNOWN | LLAMA_TOKEN_ATTR_CONTROL; - bool remove_space = model->vocab.tokenizer_add_space_prefix; + bool remove_space = !special && model->vocab.tokenizer_add_space_prefix; int32_t avail = text_len_max; int32_t total = 0;