15
15
#include <map>
16
16
#include <queue>
17
17
#include <set>
18
- #include <sstream>
19
18
#include <unordered_map>
20
19
21
20
//
@@ -416,7 +415,7 @@ struct llm_tokenizer_bpe_session {
416
415
}
417
416
418
417
bool append_bos(std::vector<llama_token> & output) const {
419
- if (vocab.add_bos_token ()) {
418
+ if (vocab.add_bos ()) {
420
419
GGML_ASSERT(vocab.token_bos() != LLAMA_TOKEN_NULL);
421
420
output.push_back(vocab.token_bos());
422
421
return true;
@@ -425,7 +424,7 @@ struct llm_tokenizer_bpe_session {
425
424
}
426
425
427
426
bool append_eos(std::vector<llama_token> & output) const {
428
- if (vocab.add_eos_token ()) {
427
+ if (vocab.add_eos ()) {
429
428
GGML_ASSERT(vocab.token_eos() != LLAMA_TOKEN_NULL);
430
429
output.push_back(vocab.token_eos());
431
430
return true;
@@ -434,13 +433,13 @@ struct llm_tokenizer_bpe_session {
434
433
}
435
434
436
435
void check_double_bos_eos(const std::vector<llama_token> & output) const {
437
- if (vocab.add_bos_token () && output.size() >= 2 && output[1] == vocab.token_bos()) {
436
+ if (vocab.add_bos () && output.size() >= 2 && output[1] == vocab.token_bos()) {
438
437
LLAMA_LOG_WARN(
439
438
"%s: Added a BOS token to the prompt as specified by the model but the prompt "
440
439
"also starts with a BOS token. So now the final prompt starts with 2 BOS tokens. "
441
440
"Are you sure this is what you want?\n", __FUNCTION__);
442
441
}
443
- if (vocab.add_bos_token () && output.size() >= 2 && *(output.end()-2) == vocab.token_eos()) {
442
+ if (vocab.add_bos () && output.size() >= 2 && *(output.end()-2) == vocab.token_eos()) {
444
443
LLAMA_LOG_WARN(
445
444
"%s: Added a EOS token to the prompt as specified by the model but the prompt "
446
445
"also ends with a EOS token. So now the final prompt ends with 2 EOS tokens. "
@@ -1234,6 +1233,7 @@ struct llama_vocab::impl {
1234
1233
llama_token special_fim_sep_id = LLAMA_TOKEN_NULL; // file separator
1235
1234
1236
1235
// tokenizer flags
1236
+ // TODO: drop tokenizer_ prefix
1237
1237
bool tokenizer_add_space_prefix = false;
1238
1238
bool tokenizer_add_bos = false;
1239
1239
bool tokenizer_add_eos = false;
@@ -1745,7 +1745,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
1745
1745
}
1746
1746
}
1747
1747
1748
- // Handle add_bos_token and add_eos_token
1748
+ // Handle add_bos and add_eos
1749
1749
{
1750
1750
bool temp = true;
1751
1751
@@ -2911,11 +2911,11 @@ bool llama_vocab::add_space_prefix() const {
2911
2911
return pimpl->tokenizer_add_space_prefix;
2912
2912
}
2913
2913
2914
- bool llama_vocab::add_bos_token () const {
2914
+ bool llama_vocab::add_bos () const {
2915
2915
return pimpl->tokenizer_add_bos;
2916
2916
}
2917
2917
2918
- bool llama_vocab::add_eos_token () const {
2918
+ bool llama_vocab::add_eos () const {
2919
2919
return pimpl->tokenizer_add_eos;
2920
2920
}
2921
2921
@@ -3087,12 +3087,12 @@ llama_token llama_vocab_pad(const struct llama_vocab * vocab) {
3087
3087
return vocab->token_pad();
3088
3088
}
3089
3089
3090
- bool llama_vocab_add_bos (const struct llama_vocab * vocab) {
3091
- return vocab->add_bos_token ();
3090
+ bool llama_vocab_get_add_bos (const struct llama_vocab * vocab) {
3091
+ return vocab->add_bos ();
3092
3092
}
3093
3093
3094
- bool llama_vocab_add_eos (const struct llama_vocab * vocab) {
3095
- return vocab->add_eos_token ();
3094
+ bool llama_vocab_get_add_eos (const struct llama_vocab * vocab) {
3095
+ return vocab->add_eos ();
3096
3096
}
3097
3097
3098
3098
llama_token llama_vocab_fim_pre(const struct llama_vocab * vocab) {
@@ -3181,12 +3181,12 @@ llama_token llama_token_pad(const struct llama_vocab * vocab) {
3181
3181
3182
3182
// deprecated
3183
3183
bool llama_add_bos_token(const struct llama_vocab * vocab) {
3184
- return llama_vocab_add_bos (vocab);
3184
+ return llama_vocab_get_add_bos (vocab);
3185
3185
}
3186
3186
3187
3187
// deprecated
3188
3188
bool llama_add_eos_token(const struct llama_vocab * vocab) {
3189
- return llama_vocab_add_eos (vocab);
3189
+ return llama_vocab_get_add_eos (vocab);
3190
3190
}
3191
3191
3192
3192
// deprecated
0 commit comments