mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-03-13 15:30:03 +00:00
fix grammar for Kimi-K2 (#1103)
* Update key-value separator and value end format * Sample grammar first if resampling --------- Co-authored-by: firecoperana <firecoperana>
This commit is contained in:
@@ -1279,8 +1279,8 @@ static common_chat_params common_chat_params_init_kimi_k2(const common_chat_temp
|
|||||||
form.tool_start = "<|tool_call_begin|>";
|
form.tool_start = "<|tool_call_begin|>";
|
||||||
form.tool_sep = "<|tool_call_argument_begin|>{";
|
form.tool_sep = "<|tool_call_argument_begin|>{";
|
||||||
form.key_start = "\"";
|
form.key_start = "\"";
|
||||||
form.key_val_sep = "\":";
|
form.key_val_sep = "\": ";
|
||||||
form.val_end = ",";
|
form.val_end = ", ";
|
||||||
form.tool_end = "}<|tool_call_end|>";
|
form.tool_end = "}<|tool_call_end|>";
|
||||||
form.scope_end = "<|tool_calls_section_end|>";
|
form.scope_end = "<|tool_calls_section_end|>";
|
||||||
form.raw_argval = false;
|
form.raw_argval = false;
|
||||||
|
|||||||
@@ -429,6 +429,12 @@ static llama_token llama_sampling_sample_impl(
|
|||||||
GGML_ASSERT(!original_logits.empty());
|
GGML_ASSERT(!original_logits.empty());
|
||||||
}
|
}
|
||||||
llama_token id = 0;
|
llama_token id = 0;
|
||||||
|
// Sample grammar first for resampling
|
||||||
|
if (ctx_sampling->grammar != NULL && is_resampling) {
|
||||||
|
float* logits = llama_get_logits_ith(ctx_main, idx);
|
||||||
|
// Apply grammar constraints to all candidates
|
||||||
|
llama_grammar_sample(ctx_sampling->grammar, ctx_main, &cur_p);
|
||||||
|
}
|
||||||
|
|
||||||
if (temp < 0.0) {
|
if (temp < 0.0) {
|
||||||
// greedy sampling, with probs
|
// greedy sampling, with probs
|
||||||
|
|||||||
Reference in New Issue
Block a user