add array param format

Former-commit-id: 486cc8d3600397812e3927d43ab4181f4e86f5dd
This commit is contained in:
hiyouga 2024-01-21 22:17:48 +08:00
parent e606832a3c
commit 48cab43cb5
3 changed files with 51 additions and 25 deletions

View File

@ -12,14 +12,21 @@ If you are using a custom dataset, please provide your dataset definition in the
"ranking": "whether the dataset is a preference dataset or not. (default: false)", "ranking": "whether the dataset is a preference dataset or not. (default: false)",
"formatting": "the format of the dataset. (optional, default: alpaca, can be chosen from {alpaca, sharegpt})", "formatting": "the format of the dataset. (optional, default: alpaca, can be chosen from {alpaca, sharegpt})",
"columns": { "columns": {
"prompt": "the column name in the dataset containing the prompts. (default: instruction, for alpaca)", "prompt": "the column name in the dataset containing the prompts. (default: instruction)",
"query": "the column name in the dataset containing the queries. (default: input, for alpaca)", "query": "the column name in the dataset containing the queries. (default: input)",
"response": "the column name in the dataset containing the responses. (default: output, for alpaca)", "response": "the column name in the dataset containing the responses. (default: output)",
"history": "the column name in the dataset containing the histories. (default: None, for alpaca)", "history": "the column name in the dataset containing the histories. (default: None)",
"messages": "the column name in the dataset containing the messages. (default: conversations, for sharegpt)", "messages": "the column name in the dataset containing the messages. (default: conversations)",
"role": "the key in the message represents the identity. (default: from, for sharegpt)", "system": "the column name in the dataset containing the system prompts. (default: None)",
"content": "the key in the message represents the content. (default: value, for sharegpt)", "tools": "the column name in the dataset containing the tool description. (default: None)"
"system": "the column name in the dataset containing the system prompts. (default: None, for both)" },
"tags": {
"role_tag": "the key in the message represents the identity. (default: from)",
"content_tag": "the key in the message represents the content. (default: value)",
"user_tag": "the value of the role_tag represents the user. (default: human)",
"assistant_tag": "the value of the role_tag represents the assistant. (default: gpt)",
"observation_tag": "the value of the role_tag represents the tool results. (default: observation)",
"function_tag": "the value of the role_tag represents the function call. (default: function_call)"
} }
} }
``` ```
@ -91,7 +98,8 @@ The dataset in sharegpt format should follow the below format:
"value": "model response" "value": "model response"
} }
], ],
"system": "system prompt (optional)" "system": "system prompt (optional)",
"tools": "tool description (optional)"
} }
] ]
``` ```
@ -102,9 +110,12 @@ Regarding the above dataset, the `columns` in `dataset_info.json` should be:
"dataset_name": { "dataset_name": {
"columns": { "columns": {
"messages": "conversations", "messages": "conversations",
"role": "from", "system": "system",
"content": "value", "tools": "tools"
"system": "system" },
"tags": {
"role_tag": "from",
"content_tag": "value"
} }
} }
``` ```

View File

@ -12,14 +12,21 @@
"ranking": "是否为偏好数据集可选默认False", "ranking": "是否为偏好数据集可选默认False",
"formatting": "数据集格式可选默认alpaca可以为 alpaca 或 sharegpt", "formatting": "数据集格式可选默认alpaca可以为 alpaca 或 sharegpt",
"columns": { "columns": {
"prompt": "数据集代表提示词的表头名称默认instruction用于 alpaca 格式)", "prompt": "数据集代表提示词的表头名称默认instruction",
"query": "数据集代表请求的表头名称默认input用于 alpaca 格式)", "query": "数据集代表请求的表头名称默认input",
"response": "数据集代表回答的表头名称默认output用于 alpaca 格式)", "response": "数据集代表回答的表头名称默认output",
"history": "数据集代表历史对话的表头名称默认None用于 alpaca 格式)", "history": "数据集代表历史对话的表头名称默认None",
"messages": "数据集代表消息列表的表头名称默认conversations用于 sharegpt 格式)", "messages": "数据集代表消息列表的表头名称默认conversations",
"role": "消息中代表发送者身份的键名默认from用于 sharegpt 格式)", "system": "数据集代表系统提示的表头名称默认None",
"content": "消息中代表文本内容的键名默认value用于 sharegpt 格式)", "tools": "数据集代表工具描述的表头名称默认None"
"system": "数据集代表系统提示的表头名称默认None用于两种格式" },
"tags": {
"role_tag": "消息中代表发送者身份的键名默认from",
"content_tag": "消息中代表文本内容的键名默认value",
"user_tag": "消息中代表用户的 role_tag默认human",
"assistant_tag": "消息中代表助手的 role_tag默认gpt",
"observation_tag": "消息中代表工具返回结果的 role_tag默认observation",
"function_tag": "消息中代表工具调用的 role_tag默认function_call"
} }
} }
``` ```
@ -91,7 +98,8 @@
"value": "模型回答" "value": "模型回答"
} }
], ],
"system": "系统提示词(选填)" "system": "系统提示词(选填)",
"tools": "工具描述(选填)"
} }
] ]
``` ```
@ -102,9 +110,12 @@
"数据集名称": { "数据集名称": {
"columns": { "columns": {
"messages": "conversations", "messages": "conversations",
"role": "from", "system": "system",
"content": "value", "tools": "tools"
"system": "system" },
"tags": {
"role_tag": "from",
"content_tag": "value"
} }
} }
``` ```

View File

@ -31,12 +31,16 @@ def default_tool_formatter(tools: List[Dict[str, Any]]) -> str:
for name, param in tool["parameters"]["properties"].items(): for name, param in tool["parameters"]["properties"].items():
required = ", required" if name in tool["parameters"].get("required", []) else "" required = ", required" if name in tool["parameters"].get("required", []) else ""
enum = ", should be one of [{}]".format(", ".join(param["enum"])) if param.get("enum", None) else "" enum = ", should be one of [{}]".format(", ".join(param["enum"])) if param.get("enum", None) else ""
param_text += " - {name} ({type}{required}): {desc}{enum}\n".format( items = (
", where each item should be {}".format(param["items"].get("type", "")) if param.get("items") else ""
)
param_text += " - {name} ({type}{required}): {desc}{enum}{items}\n".format(
name=name, name=name,
type=param.get("type", ""), type=param.get("type", ""),
required=required, required=required,
desc=param.get("description", ""), desc=param.get("description", ""),
enum=enum, enum=enum,
items=items,
) )
tool_text += "> Tool Name: {name}\nTool Description: {desc}\nTool Args:\n{args}\n".format( tool_text += "> Tool Name: {name}\nTool Description: {desc}\nTool Args:\n{args}\n".format(