Skip to content

Commit

Permalink
llama : fix llama_token_is_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Oct 11, 2024
1 parent 8131fce commit 6384002
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/llama-vocab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,14 +1865,14 @@ bool llama_token_is_prefix_impl(
char text_buf_0[128];
char text_buf_1[128];

const int32_t len0 = llama_token_to_piece_impl(vocab, token0, text_buf_0, 128, 0, false);
const int32_t len1 = llama_token_to_piece_impl(vocab, token1, text_buf_1, 128, 0, false);
const int32_t len0 = llama_token_to_piece_impl(vocab, token0, text_buf_0, sizeof(text_buf_0) - 1, 0, false);
const int32_t len1 = llama_token_to_piece_impl(vocab, token1, text_buf_1, sizeof(text_buf_1) - 1, 0, false);

if (len0 <= 0 || len1 <= 0) {
return false;
}

return len0 < len1 && memcmp(text_buf_0, text_buf_1, len0) == 0;
return len0 <= len1 && memcmp(text_buf_0, text_buf_1, len0) == 0;
}

int32_t llama_detokenize_impl(
Expand Down

0 comments on commit 6384002

Please sign in to comment.