mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-12-29 02:00:36 +08:00
[assets] fix installation (#9687)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -515,7 +515,7 @@ huggingface-cli login
|
|||||||
```bash
|
```bash
|
||||||
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
|
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
|
||||||
cd LLaMA-Factory
|
cd LLaMA-Factory
|
||||||
pip install -e ".[metrics]" --no-build-isolation
|
pip install -e ".[metrics]"
|
||||||
```
|
```
|
||||||
|
|
||||||
Optional dependencies available: `metrics`, `deepspeed`. Install with: `pip install -e ".[metrics,deepspeed]"`
|
Optional dependencies available: `metrics`, `deepspeed`. Install with: `pip install -e ".[metrics,deepspeed]"`
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ huggingface-cli login
|
|||||||
```bash
|
```bash
|
||||||
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
|
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
|
||||||
cd LLaMA-Factory
|
cd LLaMA-Factory
|
||||||
pip install -e ".[metrics]" --no-build-isolation
|
pip install -e ".[metrics]"
|
||||||
```
|
```
|
||||||
|
|
||||||
可选的额外依赖项:`metrics`、`deepspeed`。使用 `pip install -e ".[metrics,deepspeed]"` 安装。
|
可选的额外依赖项:`metrics`、`deepspeed`。使用 `pip install -e ".[metrics,deepspeed]"` 安装。
|
||||||
|
|||||||
@@ -1676,7 +1676,9 @@ register_template(
|
|||||||
register_template(
|
register_template(
|
||||||
name="minimax1",
|
name="minimax1",
|
||||||
format_user=StringFormatter(
|
format_user=StringFormatter(
|
||||||
slots=["<beginning_of_sentence>user name=user\n{{content}}<end_of_sentence>\n<beginning_of_sentence>ai name=assistant\n"]
|
slots=[
|
||||||
|
"<beginning_of_sentence>user name=user\n{{content}}<end_of_sentence>\n<beginning_of_sentence>ai name=assistant\n"
|
||||||
|
]
|
||||||
),
|
),
|
||||||
format_assistant=StringFormatter(slots=["{{content}}<end_of_sentence>\n"]),
|
format_assistant=StringFormatter(slots=["{{content}}<end_of_sentence>\n"]),
|
||||||
format_system=StringFormatter(
|
format_system=StringFormatter(
|
||||||
@@ -1684,7 +1686,9 @@ register_template(
|
|||||||
),
|
),
|
||||||
format_function=FunctionFormatter(slots=["{{content}}<end_of_sentence>\n"], tool_format="minimax1"),
|
format_function=FunctionFormatter(slots=["{{content}}<end_of_sentence>\n"], tool_format="minimax1"),
|
||||||
format_observation=StringFormatter(
|
format_observation=StringFormatter(
|
||||||
slots=["<beginning_of_sentence>tool name=tools\n{{content}}<end_of_sentence>\n<beginning_of_sentence>ai name=assistant\n"]
|
slots=[
|
||||||
|
"<beginning_of_sentence>tool name=tools\n{{content}}<end_of_sentence>\n<beginning_of_sentence>ai name=assistant\n"
|
||||||
|
]
|
||||||
),
|
),
|
||||||
format_tools=ToolFormatter(tool_format="minimax1"),
|
format_tools=ToolFormatter(tool_format="minimax1"),
|
||||||
default_system="You are a helpful assistant.",
|
default_system="You are a helpful assistant.",
|
||||||
|
|||||||
@@ -65,15 +65,15 @@ MINIMAX_M1_TOOL_PROMPT = (
|
|||||||
"You are provided with these tools:\n<tools>\n{tool_text}</tools>\n\n"
|
"You are provided with these tools:\n<tools>\n{tool_text}</tools>\n\n"
|
||||||
"If you need to call tools, please respond with <tool_calls></tool_calls> XML tags, and provide tool-name and "
|
"If you need to call tools, please respond with <tool_calls></tool_calls> XML tags, and provide tool-name and "
|
||||||
"json-object of arguments, following the format below:\n<tool_calls>\n"
|
"json-object of arguments, following the format below:\n<tool_calls>\n"
|
||||||
"{{\"name\": <tool-name-1>, \"arguments\": <args-json-object-1>}}\n...\n</tool_calls>"
|
"""{{"name": <tool-name-1>, "arguments": <args-json-object-1>}}\n...\n</tool_calls>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
MINIMAX_M2_TOOL_PROMPT = (
|
MINIMAX_M2_TOOL_PROMPT = (
|
||||||
"\n\n# Tools\n\nYou may call one or more tools to assist with the user query.\n"
|
"\n\n# Tools\n\nYou may call one or more tools to assist with the user query.\n"
|
||||||
"Here are the tools available in JSONSchema format:\n\n<tools>\n{tool_text}</tools>\n\n"
|
"Here are the tools available in JSONSchema format:\n\n<tools>\n{tool_text}</tools>\n\n"
|
||||||
"When making tool calls, use XML format to invoke tools and pass parameters:\n"
|
"When making tool calls, use XML format to invoke tools and pass parameters:\n"
|
||||||
"\n<minimax:tool_call>\n<invoke name=\"tool-name-1\">\n<parameter name=\"param-key-1\">param-value-1</parameter>\n"
|
"""\n<minimax:tool_call>\n<invoke name="tool-name-1">\n<parameter name="param-key-1">param-value-1</parameter>\n"""
|
||||||
"<parameter name=\"param-key-2\">param-value-2</parameter>\n...\n</invoke>\n</minimax:tool_call>"
|
"""<parameter name="param-key-2">param-value-2</parameter>\n...\n</invoke>\n</minimax:tool_call>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
QWEN_TOOL_PROMPT = (
|
QWEN_TOOL_PROMPT = (
|
||||||
@@ -334,9 +334,9 @@ class MiniMaxM2ToolUtils(ToolUtils):
|
|||||||
function_texts = []
|
function_texts = []
|
||||||
for func in functions:
|
for func in functions:
|
||||||
name, arguments = func.name, json.loads(func.arguments)
|
name, arguments = func.name, json.loads(func.arguments)
|
||||||
prompt = "<invoke name=\"" + name + "\">"
|
prompt = f'<invoke name="{name}">'
|
||||||
for key, value in arguments.items():
|
for key, value in arguments.items():
|
||||||
prompt += "\n<parameter name=\"" + key + "\">"
|
prompt += f'\n<parameter name="{key}">'
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
value = json.dumps(value, ensure_ascii=False)
|
value = json.dumps(value, ensure_ascii=False)
|
||||||
prompt += value + "</parameter>"
|
prompt += value + "</parameter>"
|
||||||
@@ -346,9 +346,7 @@ class MiniMaxM2ToolUtils(ToolUtils):
|
|||||||
@override
|
@override
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tool_extractor(content: str) -> Union[str, list["FunctionCall"]]:
|
def tool_extractor(content: str) -> Union[str, list["FunctionCall"]]:
|
||||||
regex = re.compile(
|
regex = re.compile(r"<minimax:tool_call>\s*(.+?)\s*</minimax:tool_call>", re.DOTALL)
|
||||||
r"<minimax:tool_call>\s*(.+?)\s*</minimax:tool_call>", re.DOTALL
|
|
||||||
)
|
|
||||||
tool_match = re.search(regex, content)
|
tool_match = re.search(regex, content)
|
||||||
if not tool_match:
|
if not tool_match:
|
||||||
return content
|
return content
|
||||||
|
|||||||
Reference in New Issue
Block a user