diff --git a/README.md b/README.md index d7f8ae85..424d708d 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,7 @@ Choose your path: | [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | | [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | | [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | +| [Granite 4](https://huggingface.co/ibm-granite) | 7B | granite4 | | [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | | [Index](https://huggingface.co/IndexTeam) | 1.9B | index | | [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 | diff --git a/README_zh.md b/README_zh.md index 466f57d5..8570efc6 100644 --- a/README_zh.md +++ b/README_zh.md @@ -274,6 +274,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc | [GLM-4.1V](https://huggingface.co/THUDM)* | 9B | glm4v | | [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - | | [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 | +| [Granite 4](https://huggingface.co/ibm-granite) | 7B | granite4 | | [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan | | [Index](https://huggingface.co/IndexTeam) | 1.9B | index | | [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 | diff --git a/src/llamafactory/data/template.py b/src/llamafactory/data/template.py index 56deb84e..a07f159d 100644 --- a/src/llamafactory/data/template.py +++ b/src/llamafactory/data/template.py @@ -1071,6 +1071,23 @@ register_template( ) +register_template( + name="granite4", + format_user=StringFormatter( + slots=[ + "<|start_of_role|>user<|end_of_role|>{{content}}<|end_of_text|>\n<|start_of_role|>assistant<|end_of_role|>" + ] + ), + format_assistant=StringFormatter(slots=["{{content}}<|end_of_text|>\n"]), + format_system=StringFormatter(slots=["<|start_of_role|>system<|end_of_role|>{{content}}<|end_of_text|>\n"]), + format_function=FunctionFormatter(slots=["{{content}}<|end_of_text|>\n"], tool_format="default"), + format_observation=StringFormatter(slots=["<|start_of_role|>tool<|end_of_role|>{{content}}<|end_of_text|>\n<|start_of_role|>assistant\n"]), + format_tools=ToolFormatter(tool_format="default"), + stop_words=["<|end_of_text|>"], + default_system=("You are Granite, developed by IBM. You are a helpful AI assistant.") +) + + register_template( name="index", format_user=StringFormatter(slots=["reserved_0{{content}}reserved_1"]), diff --git a/src/llamafactory/extras/constants.py b/src/llamafactory/extras/constants.py index f75bfc56..c622c63b 100644 --- a/src/llamafactory/extras/constants.py +++ b/src/llamafactory/extras/constants.py @@ -1029,6 +1029,17 @@ register_model_group( ) +register_model_group( + models={ + "Granite-4.0-tiny-preview": { + DownloadSource.DEFAULT: "ibm-granite/granite-4.0-tiny-preview", + DownloadSource.MODELSCOPE: "ibm-granite/granite-4.0-tiny-preview", + }, + }, + template="granite4", +) + + register_model_group( models={ "Hunyuan-7B-Instruct": {