0002-pretokenizer.patch 2.29 KB
Newer Older
1
2
3
4
5
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Yang <mxyng@pm.me>
Date: Mon, 16 Sep 2024 15:53:13 -0700
Subject: [PATCH] pretokenizer

6
7
allow for an unset pretokenizer with a warning in the
logs instead of throwing an error
8
---
9
 src/llama-vocab.cpp | 14 +++-----------
10
11
 1 file changed, 3 insertions(+), 11 deletions(-)

12
diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp
13
index 50ded286..a9ee9f03 100644
14
15
--- a/src/llama-vocab.cpp
+++ b/src/llama-vocab.cpp
16
@@ -1491,16 +1491,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
17
18
19
         if (type == LLAMA_VOCAB_TYPE_BPE) {
             add_space_prefix = false;
             clean_spaces = true;
20
21
22
23
24
25
26
27
-            if (tokenizer_pre.empty()) {
-                LLAMA_LOG_WARN("%s: missing pre-tokenizer type, using: 'default'\n", __func__);
-                LLAMA_LOG_WARN("%s:                                             \n", __func__);
-                LLAMA_LOG_WARN("%s: ************************************        \n", __func__);
-                LLAMA_LOG_WARN("%s: GENERATION QUALITY WILL BE DEGRADED!        \n", __func__);
-                LLAMA_LOG_WARN("%s: CONSIDER REGENERATING THE MODEL             \n", __func__);
-                LLAMA_LOG_WARN("%s: ************************************        \n", __func__);
-                LLAMA_LOG_WARN("%s:                                             \n", __func__);
28
-                pre_type = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
29
30
-            } else if (tokenizer_pre == "default") {
+            if (tokenizer_pre == "default") {
31
                 pre_type = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
32
33
             } else if (
                     tokenizer_pre == "llama3"   ||
34
@@ -1635,7 +1626,8 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
35
36
                 pre_type = LLAMA_VOCAB_PRE_TYPE_BAILINGMOE;
                 clean_spaces = false;
37
38
39
             } else {
-                throw std::runtime_error(format("unknown pre-tokenizer type: '%s'", tokenizer_pre.c_str()));
+                LLAMA_LOG_WARN("%s: missing or unrecognized pre-tokenizer type, using: 'default'\n", __func__);
40
+                pre_type = LLAMA_VOCAB_PRE_TYPE_DEFAULT;
41
             }
42
43
         } else if (type == LLAMA_VOCAB_TYPE_SPM) {
             pre_type = LLAMA_VOCAB_PRE_TYPE_DEFAULT;