From 5844792253d84e2251a1a1d47bf12e4532df0693 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 18 Aug 2025 23:06:02 +0200 Subject: [PATCH 1/2] chat : clarify the meaning of reasoning_format --- common/chat.cpp | 1 - common/common.h | 6 ++++-- tests/test-chat.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/chat.cpp b/common/chat.cpp index 23d3828f9cc2d..5fe5643d38356 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -632,7 +632,6 @@ const char * common_reasoning_format_name(common_reasoning_format format) { case COMMON_REASONING_FORMAT_AUTO: return "auto"; case COMMON_REASONING_FORMAT_DEEPSEEK: return "deepseek"; case COMMON_REASONING_FORMAT_DEEPSEEK_LEGACY: return "deepseek-legacy"; - case COMMON_REASONING_FORMAT_GRANITE: return "granite"; default: throw std::runtime_error("Unknown reasoning format"); } diff --git a/common/common.h b/common/common.h index 75596e6b32979..0936212c2a1f8 100644 --- a/common/common.h +++ b/common/common.h @@ -239,12 +239,14 @@ struct common_params_diffusion { bool add_gumbel_noise = false; // add gumbel noise to the logits if temp > 0.0 }; +// reasoning API response format (not to be confused as chat template's reasoning format) enum common_reasoning_format { COMMON_REASONING_FORMAT_NONE, - COMMON_REASONING_FORMAT_AUTO, + COMMON_REASONING_FORMAT_AUTO, // Same as deepseek, using `message.reasoning_content` COMMON_REASONING_FORMAT_DEEPSEEK_LEGACY, // Extract thinking tag contents and return as `message.reasoning_content`, or leave inline in tags in stream mode COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`, including in streaming deltas. - COMMON_REASONING_FORMAT_GRANITE, // Extract thinking tag contents and return as `message.reasoning_content`, including in streaming deltas. + // do not extend this enum unless you absolutely have to + // in most cases, use COMMON_REASONING_FORMAT_AUTO }; diff --git a/tests/test-chat.cpp b/tests/test-chat.cpp index ea4060c8767d2..a6daa93a82b32 100644 --- a/tests/test-chat.cpp +++ b/tests/test-chat.cpp @@ -1408,7 +1408,7 @@ static void test_template_output_parsers() { /* is_partial= */ false, { /* .format = */ COMMON_CHAT_FORMAT_GRANITE, - /* .reasoning_format = */ COMMON_REASONING_FORMAT_GRANITE, + /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK, })); // Test parsing tool calls From a178e442bc4c9d1e271d74b5dab7fbc27e6ea8eb Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 18 Aug 2025 23:16:45 +0200 Subject: [PATCH 2/2] add link to this PR --- common/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/common.h b/common/common.h index 0936212c2a1f8..dfb63461bcc28 100644 --- a/common/common.h +++ b/common/common.h @@ -247,6 +247,7 @@ enum common_reasoning_format { COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`, including in streaming deltas. // do not extend this enum unless you absolutely have to // in most cases, use COMMON_REASONING_FORMAT_AUTO + // see: https://github.com/ggml-org/llama.cpp/pull/15408 };