Skip to content

Commit 473c01e

Browse files
author
ochafik
committed
fix command r7b's nothink w/ official template
1 parent cdea6a9 commit 473c01e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

common/chat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ static common_chat_params common_chat_params_init_command_r7b(const common_chat_
934934
} else {
935935
data.thinking_forced_open = true;
936936
}
937+
} else if (!inputs.enable_thinking && string_ends_with(data.prompt, "<|CHATBOT_TOKEN|>")) {
938+
data.prompt += "<|START_THINKING|><|END_THINKING|>";
937939
}
938940

939941
data.grammar_lazy = inputs.tool_choice != COMMON_CHAT_TOOL_CHOICE_REQUIRED;

tools/server/tests/unit/test_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def create_server():
3636
("Qwen-QwQ-32B", False, "<|im_start|>assistant\n<think>\n"),
3737
("Qwen-QwQ-32B", True, "<|im_start|>assistant\n<think>\n</think>"),
3838
39-
("CohereForAI-c4ai-command-r7b-12-2024-tool_use-think", False, "<|START_THINKING|>"),
40-
("CohereForAI-c4ai-command-r7b-12-2024-tool_use-think", True, "<|START_THINKING|><|END_THINKING|>"),
39+
("CohereForAI-c4ai-command-r7b-12-2024-tool_use", False, "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>"),
40+
("CohereForAI-c4ai-command-r7b-12-2024-tool_use", True, "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|><|END_THINKING|>"),
4141
])
4242
def test_nothink(template_name: str, nothink: bool, expected_end: str, tools: list[dict]):
4343
global server

0 commit comments

Comments
 (0)