You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: common/chat.cpp
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -988,10 +988,11 @@ static common_chat_params common_chat_params_init_llama_3_1_tool_calls(const com
988
988
"\"\\\"name\\\"\" space \":\" space \"\\\"" + name + "\\\"\" space \",\" space "
989
989
"\"\\\"parameters\\\"\" space \":\" space " + builder.add_schema(name + "-args", parameters) + ""
990
990
"\"}\" space"));
991
-
data.grammar_triggers.push_back({
992
-
COMMON_GRAMMAR_TRIGGER_TYPE_PATTERN_START,
993
-
"\\{\\s*(?:\"type\"\\s*:\\s*\"function\"\\s*,\\s*)?\"name\"\\s*:\\s*\"" + name + "\"[\\s\\S]*",
994
-
});
991
+
});
992
+
// Small models may hallucinate function names so we match anything (*at the start*) that looks like the JSON of a function call, regardless of the name.
993
+
data.grammar_triggers.push_back({
994
+
COMMON_GRAMMAR_TRIGGER_TYPE_PATTERN_START,
995
+
"\\{\\s*(?:\"type\"\\s*:\\s*\"function\"\\s*,\\s*)?\"name\"\\s*:\\s*\"", // + name + "\"[\\s\\S]*",
0 commit comments