diff --git a/README.md b/README.md index 983d417d..db981f9f 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,7 @@ Choose your path: | [LLaVA-NeXT](https://huggingface.co/llava-hf) | 7B/8B/13B/34B/72B/110B | llava_next | | [LLaVA-NeXT-Video](https://huggingface.co/llava-hf) | 7B/34B | llava_next_video | | [MiMo](https://huggingface.co/XiaomiMiMo) | 7B | mimo | -| [MiniCPM](https://huggingface.co/openbmb) | 1B/2B/4B | cpm/cpm3 | +| [MiniCPM](https://huggingface.co/openbmb) | 0.5B/1B/2B/4B/8B | cpm/cpm3/cpm4 | | [MiniCPM-o-2.6/MiniCPM-V-2.6](https://huggingface.co/openbmb) | 8B | minicpm_o/minicpm_v | | [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral | | [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral | diff --git a/README_zh.md b/README_zh.md index b3edfdfe..216d9b6c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -282,7 +282,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc | [LLaVA-NeXT](https://huggingface.co/llava-hf) | 7B/8B/13B/34B/72B/110B | llava_next | | [LLaVA-NeXT-Video](https://huggingface.co/llava-hf) | 7B/34B | llava_next_video | | [MiMo](https://huggingface.co/XiaomiMiMo) | 7B | mimo | -| [MiniCPM](https://huggingface.co/openbmb) | 1B/2B/4B | cpm/cpm3 | +| [MiniCPM](https://huggingface.co/openbmb) | 0.5B/1B/2B/4B/8B | cpm/cpm3/cpm4 | | [MiniCPM-o-2.6/MiniCPM-V-2.6](https://huggingface.co/openbmb) | 8B | minicpm_o/minicpm_v | | [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral | | [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral | diff --git a/assets/wechat.jpg b/assets/wechat.jpg index f9c8be75..5038e363 100644 Binary files a/assets/wechat.jpg and b/assets/wechat.jpg differ diff --git a/assets/wechat_npu.jpg b/assets/wechat_npu.jpg index 1ab4d24d..2420a0f0 100644 Binary files a/assets/wechat_npu.jpg and b/assets/wechat_npu.jpg differ diff --git a/src/llamafactory/data/template.py b/src/llamafactory/data/template.py index 37a5558b..ac19b30b 100644 --- a/src/llamafactory/data/template.py +++ b/src/llamafactory/data/template.py @@ -501,7 +501,11 @@ def register_template( default_slots = ["{{content}}"] if efficient_eos else ["{{content}}", {"eos_token"}] default_user_formatter = StringFormatter(slots=["{{content}}"]) default_assistant_formatter = StringFormatter(slots=default_slots) - default_function_formatter = FunctionFormatter(slots=default_slots, tool_format="default") + if format_assistant is not None: + default_function_formatter = FunctionFormatter(slots=format_assistant.slots, tool_format="default") + else: + default_function_formatter = FunctionFormatter(slots=default_slots, tool_format="default") + default_tool_formatter = ToolFormatter(tool_format="default") default_prefix_formatter = EmptyFormatter() TEMPLATES[name] = template_class( @@ -798,6 +802,7 @@ register_template( format_user=StringFormatter(slots=["<|im_start|>user\n{{content}}<|im_end|>\n<|im_start|>assistant\n"]), format_assistant=StringFormatter(slots=["{{content}}<|im_end|>\n"]), format_system=StringFormatter(slots=["<|im_start|>system\n{{content}}<|im_end|>\n"]), + format_observation=StringFormatter(slots=["<|im_start|>tool\n{{content}}<|im_end|>\n<|im_start|>assistant\n"]), format_prefix=EmptyFormatter(slots=[{"bos_token"}]), stop_words=["<|im_end|>"], ) @@ -809,37 +814,9 @@ register_template( format_user=StringFormatter(slots=["<|im_start|>user\n{{content}}<|im_end|>\n<|im_start|>assistant\n"]), format_assistant=StringFormatter(slots=["{{content}}<|im_end|>\n"]), format_system=StringFormatter(slots=["<|im_start|>system\n{{content}}<|im_end|>\n"]), - format_function=FunctionFormatter(slots=["{{content}}<|im_end|>\n"], tool_format="default"), format_observation=StringFormatter(slots=["<|im_start|>tool\n{{content}}<|im_end|>\n<|im_start|>assistant\n"]), - format_tools=ToolFormatter(tool_format="default"), format_prefix=EmptyFormatter(slots=[{"bos_token"}]), - thought_words=("<|thought_start|>", "<|thought_end|>"), - stop_words=["<|im_end|>", "<|tool_call_start|>", "<|tool_call_end|>"], - default_system=( - "# Functions\n" - "Here is a list of functions that you can invoke:\n" - "```python\n" - "from enum import Enum\n" - "from typing import List, Dict, Optional\n" - "from pydantic import BaseModel, Field\n" - "```\n\n" - "# Function Call Rule and Output Format\n" - "- If the user's question can be answered without calling any function, please answer the user's question directly. In this situation, you should return your thought and answer the user's question directly.\n" - "- If the user cannot be answered without calling any function, and the user does not provide enough information to call functions, please ask the user for more information. In this situation, you should return your thought and ask the user for more information.\n" - "- If the user's question cannot be answered without calling any function, and the user has provided enough information to call functions to solve it, you should call the functions. In this situation, the assistant should return your thought and call the functions.\n" - "- Use default parameters unless the user has specified otherwise.\n" - "- You should answer in the following format:\n\n" - "<|thought_start|>\n" - "{explain why the user's question can be answered without calling a function or why you should ask the user for more information or why you should call one or more functions and your plan to solve the user's question.}\n" - "<|thought_end|>\n" - "<|tool_call_start|>\n" - "```python\n" - "func1(params_name=params_value, params_name2=params_value2...)\n" - "func2(params)\n" - "```\n" - "<|tool_call_end|>\n" - "{answer the user's question directly or ask the user for more information}" - ), + stop_words=["<|im_end|>"], ) diff --git a/src/llamafactory/extras/constants.py b/src/llamafactory/extras/constants.py index 90255b24..da19ebb7 100644 --- a/src/llamafactory/extras/constants.py +++ b/src/llamafactory/extras/constants.py @@ -1502,18 +1502,13 @@ register_model_group( template="cpm3", ) -register_model_group( - models={ - "MiniCPM4-0_5B-Chat": { - DownloadSource.DEFAULT: "openbmb/MiniCPM4-0.5B", - DownloadSource.MODELSCOPE: "OpenBMB/MiniCPM4-0.5B", - }, - }, - template="cpm4", -) register_model_group( models={ + "MiniCPM4-0.5B-Chat": { + DownloadSource.DEFAULT: "openbmb/MiniCPM4-0.5B", + DownloadSource.MODELSCOPE: "OpenBMB/MiniCPM4-0.5B", + }, "MiniCPM4-8B-Chat": { DownloadSource.DEFAULT: "openbmb/MiniCPM4-8B", DownloadSource.MODELSCOPE: "OpenBMB/MiniCPM4-8B", @@ -1522,6 +1517,7 @@ register_model_group( template="cpm4", ) + register_model_group( models={ "MiniCPM-o-2_6": {