mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-13 04:00:16 +00:00
minja
: fix llama_chat_apply_template + adde use_jinja param to validate_model_chat_template
This commit is contained in:
parent
e983c9d0de
commit
45b243b4a5
@ -1512,7 +1512,18 @@ std::string llama_detokenize(llama_context * ctx, const std::vector<llama_token>
|
|||||||
|
|
||||||
bool llama_chat_verify_template(const std::string & tmpl, bool use_jinja) {
|
bool llama_chat_verify_template(const std::string & tmpl, bool use_jinja) {
|
||||||
llama_chat_message chat[] = {{"user", "test"}};
|
llama_chat_message chat[] = {{"user", "test"}};
|
||||||
int res = llama_chat_apply_template(nullptr, tmpl.c_str(), chat, 1, true, nullptr, 0, use_jinja);
|
int res = llama_chat_apply_template(
|
||||||
|
nullptr,
|
||||||
|
tmpl.c_str(),
|
||||||
|
chat,
|
||||||
|
1,
|
||||||
|
/* add_ass= */ true,
|
||||||
|
/* buffer= */ nullptr,
|
||||||
|
/* length= */ 0,
|
||||||
|
use_jinja,
|
||||||
|
/* tools= */ nullptr,
|
||||||
|
"<s>",
|
||||||
|
"</s>");
|
||||||
return res >= 0;
|
return res >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,10 +659,10 @@ struct server_context {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validate_model_chat_template() const {
|
bool validate_model_chat_template(bool use_jinja) const {
|
||||||
llama_chat_message chat[] = {{"user", "test"}};
|
llama_chat_message chat[] = {{"user", "test"}};
|
||||||
|
|
||||||
const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0);
|
const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0, use_jinja);
|
||||||
|
|
||||||
return res > 0;
|
return res > 0;
|
||||||
}
|
}
|
||||||
@ -3183,7 +3183,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
// if a custom chat template is not supplied, we will use the one that comes with the model (if any)
|
// if a custom chat template is not supplied, we will use the one that comes with the model (if any)
|
||||||
if (params.chat_template.empty()) {
|
if (params.chat_template.empty()) {
|
||||||
if (!ctx_server.validate_model_chat_template()) {
|
if (!ctx_server.validate_model_chat_template(params.use_jinja)) {
|
||||||
LOG_WRN("%s: The chat template that comes with this model is not yet supported, falling back to chatml. This may cause the model to output suboptimal responses\n", __func__);
|
LOG_WRN("%s: The chat template that comes with this model is not yet supported, falling back to chatml. This may cause the model to output suboptimal responses\n", __func__);
|
||||||
params.chat_template = "chatml";
|
params.chat_template = "chatml";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user