From 9396c7bbaf93a0d0f49c6b92cbb8635e5a2e81be Mon Sep 17 00:00:00 2001 From: toyer <2042519524@qq.com> Date: Wed, 26 Jun 2024 02:16:12 +0000 Subject: [PATCH] set <|endoftext|> as eos and <|user|> as eot --- convert-hf-to-gguf.py | 2 +- llama.cpp | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index 4f6308d46..363c09720 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -3048,9 +3048,9 @@ class ChatGLMModel(Model): special_vocab.chat_template = "ChatGLM4" special_vocab.merges = merges # only add special tokens when they were not already loaded from config.json - # if len(special_vocab.special_token_ids) == 0: special_vocab._set_special_token("bos", tokenizer.get_added_vocab()["<|endoftext|>"]) special_vocab._set_special_token("eos", tokenizer.get_added_vocab()["<|endoftext|>"]) + special_vocab._set_special_token("eot", tokenizer.get_added_vocab()["<|user|>"]) # this one is usually not in config.json anyway special_vocab._set_special_token("unk", tokenizer.get_added_vocab()["<|endoftext|>"]) special_vocab.add_to_gguf(self.gguf_writer) diff --git a/llama.cpp b/llama.cpp index aea08fa52..7a48c1115 100644 --- a/llama.cpp +++ b/llama.cpp @@ -18832,19 +18832,6 @@ llama_token_attr llama_token_get_attr(const struct llama_model * model, llama_to } bool llama_token_is_eog(const struct llama_model * model, llama_token token) { - auto arch_name = llama_model_arch_name(model->arch); - auto vocab_type = model->vocab.type; - if (strcmp(arch_name, "chatglm") == 0) { - if (LLAMA_VOCAB_TYPE_BPE == vocab_type) { // glm4 - return token != -1 && ( - token == llama_token_eos(model) || - token == llama_token_eot(model) || - token == 151329 || - token == 151336 || - token == 151338 - ); - } - } return token != -1 && ( token == llama_token_eos(model) || token == llama_token_eot(model)