Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed n vocab #9511

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6061,8 +6061,13 @@ static void llm_load_vocab(
vocab.special_mask_id = -1;
vocab.linefeed_id = -1;

// read vocab size from metadata
ml.get_key(LLM_KV_VOCAB_SIZE, vocab.n_vocab);
Xarbirus marked this conversation as resolved.
Show resolved Hide resolved

return;
} else if (tokenizer_model == "llama") {
}

if (tokenizer_model == "llama") {
vocab.type = LLAMA_VOCAB_TYPE_SPM;

// default special tokens
Expand Down Expand Up @@ -16577,7 +16582,7 @@ static int llama_decode_internal(
const uint32_t n_tokens_all = batch_all.n_tokens;

if (n_tokens_all == 0) {
LLAMA_LOG_ERROR("%s: n_tokens == 0", __func__);
LLAMA_LOG_ERROR("%s: n_tokens == 0\n", __func__);
return -1;
}

Expand All @@ -16590,7 +16595,7 @@ static int llama_decode_internal(
if (batch_all.token) {
for (uint32_t i = 0; i < n_tokens_all; ++i) {
if (batch_all.token[i] < 0 || (uint32_t)batch_all.token[i] >= model.vocab.n_vocab) {
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch_all.token[i]);
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d\n", __func__, i, batch_all.token[i]);
return -1;
}
}
Expand Down Expand Up @@ -16878,7 +16883,7 @@ static int llama_encode_internal(
const uint32_t n_tokens = batch.n_tokens;

if (n_tokens == 0) {
LLAMA_LOG_ERROR("%s: n_tokens == 0", __func__);
LLAMA_LOG_ERROR("%s: n_tokens == 0\n", __func__);
return -1;
}

Expand All @@ -16891,7 +16896,7 @@ static int llama_encode_internal(
if (batch.token) {
for (uint32_t i = 0; i < n_tokens; ++i) {
if (batch.token[i] < 0 || (uint32_t)batch.token[i] >= model.vocab.n_vocab) {
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch.token[i]);
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d\n", __func__, i, batch.token[i]);
return -1;
}
}
Expand Down
Loading