8000 force printing </tool_call> on hermes 2 model if/as it's a special token · ochafik/llama.cpp@1029ff9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1029ff9

Browse files
author
Olivier Chafik
committed
force printing </tool_call> on hermes 2 model if/as it's a special token
1 parent 5add261 commit 1029ff9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

common/chat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ static common_chat_params common_chat_params_init_hermes_2_pro(const common_chat
691691
auto tool_call = "\"<tool_call>\" space " + builder.add_rule("tool_call", string_join(tool_rules, " | ")) + " \"</tool_call>\" space";
692692
builder.add_rule("root", inputs.parallel_tool_calls ? "(" + tool_call + ")+" : tool_call);
693693
data.grammar_triggers.push_back({"<tool_call>", /* .at_start = */ false});
694+
// Not really a trigger but need to print this special token to get a successful parse.
695+
data.grammar_triggers.push_back({"</tool_call>", /* .at_start = */ false});
694696
}, grammar_options);
695697

696698
data.prompt = tmpl.apply(inputs.messages, inputs.tools.empty() ? json() : inputs.tools, inputs.add_generation_prompt);

0 commit comments

Comments
 (0)
0