From: Daniel Bevenius Date: Fri, 15 Aug 2025 17:50:52 +0000 (+0200) Subject: common : fix double bos, use common_chat_templates for add_bos and add_eos (#15326) X-Git-Tag: upstream/0.0.6199~21 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=5e6229a8409ac786e62cb133d09f1679a9aec13e;p=pkg%2Fggml%2Fsources%2Fllama.cpp common : fix double bos, use common_chat_templates for add_bos and add_eos (#15326) This commit updates common_chat_templates_apply_jinja to use the the add_bos and add_eos parameters from the chat template instead of the inputs. The motivation for this is that currently if the `add_bos` and `add_eos` from the input parameters are used it is possible to there will be a missmatch between the model and the chat template which can lead to the the removal of duplicate BOS/EOS tokens in chat.cpp `apply` to not happen leading to two BOS tokens being added to the template. --- diff --git a/common/chat.cpp b/common/chat.cpp index 00f30994..23d3828f 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -2061,8 +2061,8 @@ static common_chat_params common_chat_templates_apply_jinja( params.enable_thinking = inputs.enable_thinking; params.grammar = inputs.grammar; params.now = inputs.now; - params.add_bos = inputs.add_bos; - params.add_eos = inputs.add_eos; + params.add_bos = tmpls->add_bos; + params.add_eos = tmpls->add_eos; params.extra_context = json::object(); for (auto el : inputs.chat_template_kwargs) {