Skip to content

Commit efc411a

Browse files
committed
merge checks of eos and sep
1 parent f7c3ba0 commit efc411a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

common/common.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -903,19 +903,16 @@ struct common_init_result common_init_from_params(common_params & params) {
903903
ok = false;
904904
}
905905

906-
if (llama_vocab_eos(vocab) == LLAMA_TOKEN_NULL) {
907-
// Now we use SEP as a fallback, so only warn if both are missing
908-
if (llama_vocab_sep(vocab) == LLAMA_TOKEN_NULL) {
909-
LOG_WRN("%s: warning: vocab does not have an EOS token or SEP token, reranking will not work\n",
910-
__func__);
911-
ok = false;
912-
} else {
913-
LOG_WRN("%s: warning: vocab does not have an EOS token, using SEP token as fallback\n", __func__);
914-
}
915-
}
916-
917-
if (llama_vocab_sep(vocab) == LLAMA_TOKEN_NULL) {
918-
LOG_WRN("%s: warning: vocab does not have a SEP token, reranking will not work\n", __func__);
906+
bool has_eos = llama_vocab_eos(vocab) != LLAMA_TOKEN_NULL;
907+
bool has_sep = llama_vocab_sep(vocab) != LLAMA_TOKEN_NULL;
908+
909+
if (!has_eos && !has_sep) {
910+
LOG_WRN("%s: warning: vocab does not have an EOS token or SEP token, reranking will not work\n", __func__);
911+
ok = false;
912+
} else if (!has_eos) {
913+
LOG_WRN("%s: warning: vocab does not have an EOS token, using SEP token as fallback\n", __func__);
914+
} else if (!has_sep) {
915+
LOG_WRN("%s: warning: vocab does not have a SEP token, reranking will not work\n", __func__);
919916
ok = false;
920917
}
921918

0 commit comments

Comments
 (0)