mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-01-13 09:30:34 +08:00
[refactor] rename lfm template to lfm2 and add LFM 2.5 to README (#9731)
This commit is contained in:
@@ -1331,18 +1331,18 @@ register_template(
|
||||
|
||||
|
||||
register_template(
|
||||
name="lfm",
|
||||
name="lfm2",
|
||||
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="lfm"),
|
||||
format_function=FunctionFormatter(slots=["{{content}}<|im_end|>\n"], tool_format="lfm2"),
|
||||
format_observation=StringFormatter(
|
||||
slots=[
|
||||
"<|im_start|>tool\n<|tool_response_start|>{{content}}<|tool_response_end|><|im_end|>\n"
|
||||
"<|im_start|>assistant\n"
|
||||
]
|
||||
),
|
||||
format_tools=ToolFormatter(tool_format="lfm"),
|
||||
format_tools=ToolFormatter(tool_format="lfm2"),
|
||||
default_system="You are a helpful AI assistant.",
|
||||
stop_words=["<|im_end|>"],
|
||||
tool_call_words=("<|tool_call_start|>", "<|tool_call_end|>"),
|
||||
@@ -1355,14 +1355,14 @@ 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="lfm"),
|
||||
format_function=FunctionFormatter(slots=["{{content}}<|im_end|>\n"], tool_format="lfm2"),
|
||||
format_observation=StringFormatter(
|
||||
slots=[
|
||||
"<|im_start|>tool\n<|tool_response_start|>{{content}}<|tool_response_end|><|im_end|>\n"
|
||||
"<|im_start|>assistant\n"
|
||||
]
|
||||
),
|
||||
format_tools=ToolFormatter(tool_format="lfm"),
|
||||
format_tools=ToolFormatter(tool_format="lfm2"),
|
||||
default_system="You are a helpful multimodal assistant by Liquid AI.",
|
||||
stop_words=["<|im_end|>"],
|
||||
tool_call_words=("<|tool_call_start|>", "<|tool_call_end|>"),
|
||||
|
||||
@@ -102,7 +102,7 @@ LING_TOOL_PROMPT = (
|
||||
""""arguments": <args-json-object>}}\n</tool_call>"""
|
||||
)
|
||||
|
||||
LFM_TOOL_PROMPT = "List of tools: <|tool_list_start|>{tool_text}<|tool_list_end|>"
|
||||
LFM2_TOOL_PROMPT = "List of tools: <|tool_list_start|>{tool_text}<|tool_list_end|>"
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -549,8 +549,8 @@ class LingToolUtils(QwenToolUtils):
|
||||
return LING_TOOL_PROMPT.format(tool_text=tool_text) + "\n" + "detailed thinking off"
|
||||
|
||||
|
||||
class LFMToolUtils(ToolUtils):
|
||||
r"""LFM 2.5 tool using template with Pythonic function call syntax."""
|
||||
class LFM2ToolUtils(ToolUtils):
|
||||
r"""LFM2.5 tool using template with Pythonic function call syntax."""
|
||||
|
||||
@override
|
||||
@staticmethod
|
||||
@@ -560,7 +560,7 @@ class LFMToolUtils(ToolUtils):
|
||||
tool = tool.get("function", tool) if tool.get("type") == "function" else tool
|
||||
tool_list.append(tool)
|
||||
|
||||
return LFM_TOOL_PROMPT.format(tool_text=json.dumps(tool_list, ensure_ascii=False))
|
||||
return LFM2_TOOL_PROMPT.format(tool_text=json.dumps(tool_list, ensure_ascii=False))
|
||||
|
||||
@override
|
||||
@staticmethod
|
||||
@@ -643,7 +643,7 @@ class LFMToolUtils(ToolUtils):
|
||||
for keyword in node.keywords:
|
||||
key = keyword.arg
|
||||
try:
|
||||
value = LFMToolUtils._ast_to_value(keyword.value)
|
||||
value = LFM2ToolUtils._ast_to_value(keyword.value)
|
||||
except (ValueError, SyntaxError):
|
||||
return content
|
||||
args_dict[key] = value
|
||||
@@ -657,7 +657,7 @@ TOOLS = {
|
||||
"default": DefaultToolUtils(),
|
||||
"glm4": GLM4ToolUtils(),
|
||||
"llama3": Llama3ToolUtils(),
|
||||
"lfm": LFMToolUtils(),
|
||||
"lfm2": LFM2ToolUtils(),
|
||||
"minimax1": MiniMaxM1ToolUtils(),
|
||||
"minimax2": MiniMaxM2ToolUtils(),
|
||||
"mistral": MistralToolUtils(),
|
||||
|
||||
@@ -1502,7 +1502,7 @@ register_model_group(
|
||||
DownloadSource.DEFAULT: "LiquidAI/LFM2.5-1.2B-Instruct",
|
||||
},
|
||||
},
|
||||
template="lfm",
|
||||
template="lfm2",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user