From 30caac3a68a54de8396b21e20ba972554c587230 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Tue, 24 Dec 2024 09:44:20 +0200 Subject: [PATCH] llama : the WPM vocabs use the CLS token as BOS (#10930) * llama : the WPM vocabs use the CLS token as BOS ggml-ci * llama : add comment --- src/llama-vocab.cpp | 2 +- src/llama-vocab.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp index 7f2725f94..0a477d6dd 100644 --- a/src/llama-vocab.cpp +++ b/src/llama-vocab.cpp @@ -1657,7 +1657,7 @@ bool llama_token_is_control_impl(const struct llama_vocab & vocab, llama_token t } llama_token llama_token_bos_impl(const struct llama_vocab & vocab) { - return vocab.special_bos_id; + return vocab.type != LLAMA_VOCAB_TYPE_WPM ? vocab.special_bos_id : vocab.special_cls_id; } llama_token llama_token_eos_impl(const struct llama_vocab & vocab) { diff --git a/src/llama-vocab.h b/src/llama-vocab.h index 4bb16d2e4..a9b0da5ef 100644 --- a/src/llama-vocab.h +++ b/src/llama-vocab.h @@ -45,7 +45,7 @@ struct llama_vocab { id special_unk_id = 0; id special_sep_id = LLAMA_TOKEN_NULL; id special_pad_id = LLAMA_TOKEN_NULL; - id special_cls_id = LLAMA_TOKEN_NULL; + id special_cls_id = LLAMA_TOKEN_NULL; // TODO: revisit if this is really needed https://github.com/ggerganov/llama.cpp/pull/10930 id special_mask_id = LLAMA_TOKEN_NULL; id linefeed_id = 13;