[model] support granite4 (#8680)

This commit is contained in:
Steven sun
2025-07-21 14:15:36 +08:00
committed by GitHub
parent 1639e4b587
commit 9d6565d1a8
4 changed files with 30 additions and 0 deletions

View File

@@ -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"]),