Skip to content

Commit e18f734

Browse files
authored
grammar : revert the replacement of llama_token_to_piece with id_to_token (#4396)
1 parent fe680e3 commit e18f734

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llama.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7503,7 +7503,7 @@ void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * c
75037503

75047504
for (size_t i = 0; i < candidates->size; ++i) {
75057505
const llama_token id = candidates->data[i].id;
7506-
const std::string & piece = ctx->model.vocab.id_to_token[id].text;
7506+
const std::string piece = llama_token_to_piece(ctx, id);
75077507
if (id == eos) {
75087508
if (!allow_eos) {
75097509
candidates->data[i].logit = -INFINITY;
@@ -7715,7 +7715,7 @@ void llama_grammar_accept_token(struct llama_context * ctx, struct llama_grammar
77157715
GGML_ASSERT(false);
77167716
}
77177717

7718-
const std::string & piece = ctx->model.vocab.id_to_token[token].text;
7718+
const std::string piece = llama_token_to_piece(ctx, token);
77197719

77207720
// Note terminating 0 in decoded string
77217721
const auto decoded = decode_utf8(piece, grammar->partial_utf8);

0 commit comments

Comments
 (0)