]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : set attrs of mislabelled EOT/EOM tokens (#9348)
authorKevin Gibbons <redacted>
Sun, 8 Sep 2024 05:51:00 +0000 (22:51 -0700)
committerGitHub <redacted>
Sun, 8 Sep 2024 05:51:00 +0000 (08:51 +0300)
src/llama.cpp

index 190564fa4e69e2ca47aecf9822a3ed44a6728168..f590bcd3b90476243c469009886060183f62f2cb 100644 (file)
@@ -6399,6 +6399,11 @@ static void llm_load_vocab(
                         )
                    ) {
                     vocab.special_eot_id = t.second;
+                    if ((vocab.id_to_token[t.second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
+                        LLAMA_LOG_WARN("%s: control-looking token: '%s' was not control-type; this is probably a bug in the model. its type will be overridden\n",
+                            __func__, t.first.c_str());
+                        vocab.id_to_token[t.second].attr = LLAMA_TOKEN_ATTR_CONTROL;
+                    }
                     break;
                 }
             }
@@ -6412,6 +6417,11 @@ static void llm_load_vocab(
             const auto & t = vocab.token_to_id.find("<|eom_id|>");
             if (t != vocab.token_to_id.end()) {
                 vocab.special_eom_id = t->second;
+                if ((vocab.id_to_token[t->second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
+                    LLAMA_LOG_WARN("%s: control-looking token: '%s' was not control-type; this is probably a bug in the model. its type will be overridden\n",
+                        __func__, t->first.c_str());
+                    vocab.id_to_token[t->second].attr = LLAMA_TOKEN_ATTR_CONTROL;
+                }
             }
         }
     }