Skip to content

Commit 6384002

Browse files
committed
llama : fix llama_token_is_prefix
1 parent 8131fce commit 6384002

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/llama-vocab.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1865,14 +1865,14 @@ bool llama_token_is_prefix_impl(
18651865
char text_buf_0[128];
18661866
char text_buf_1[128];
18671867

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

18711871
if (len0 <= 0 || len1 <= 0) {
18721872
return false;
18731873
}
18741874

1875-
return len0 < len1 && memcmp(text_buf_0, text_buf_1, len0) == 0;
1875+
return len0 <= len1 && memcmp(text_buf_0, text_buf_1, len0) == 0;
18761876
}
18771877

18781878
int32_t llama_detokenize_impl(

0 commit comments

Comments
 (0)