Skip to content

Commit 6e14286

Browse files
authored
cli : fix not copying preserved tokens (#24258)
1 parent 8ed274e commit 6e14286

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

tools/cli/cli.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ struct cli_context {
9797
task.params.chat_parser_params.parser.load(chat_params.parser);
9898
}
9999

100+
// Copy the preserved tokens into the sampling params
101+
const llama_vocab * vocab = llama_model_get_vocab(
102+
llama_get_model(ctx_server.get_llama_context()));
103+
for (const auto & token : chat_params.preserved_tokens) {
104+
auto ids = common_tokenize(vocab, token, false, true);
105+
if (ids.size() == 1) {
106+
task.params.sampling.preserved_tokens.insert(ids[0]);
107+
}
108+
}
109+
100110
// reasoning budget sampler
101111
if (!chat_params.thinking_end_tag.empty()) {
102-
const llama_vocab * vocab = llama_model_get_vocab(
103-
llama_get_model(ctx_server.get_llama_context()));
104-
105112
task.params.sampling.reasoning_budget_tokens = defaults.sampling.reasoning_budget_tokens;
106113
task.params.sampling.generation_prompt = chat_params.generation_prompt;
107114

0 commit comments

Comments
 (0)