LLaMA-Factory-Mirror/data/README.md

352 lines
9.8 KiB
Markdown
Raw Permalink Normal View History

2024-05-18 21:37:38 +08:00
The [dataset_info.json](dataset_info.json) contains all available datasets. If you are using a custom dataset, please **make sure** to add a *dataset description* in `dataset_info.json` and specify `dataset: dataset_name` before training to use it.
2024-05-18 21:15:20 +08:00
Currently we support datasets in **alpaca** and **sharegpt** format.
2023-07-19 20:59:15 +08:00
2023-05-28 18:09:04 +08:00
```json
"dataset_name": {
2023-12-18 19:09:31 +08:00
"hf_hub_url": "the name of the dataset repository on the Hugging Face hub. (if specified, ignore script_url and file_name)",
2024-05-18 21:15:20 +08:00
"ms_hub_url": "the name of the dataset repository on the Model Scope hub. (if specified, ignore script_url and file_name)",
2023-12-18 19:09:31 +08:00
"script_url": "the name of the directory containing a dataset loading script. (if specified, ignore file_name)",
2024-05-18 21:15:20 +08:00
"file_name": "the name of the dataset folder or dataset file in this directory. (required if above are not specified)",
"formatting": "the format of the dataset. (optional, default: alpaca, can be chosen from {alpaca, sharegpt})",
"ranking": "whether the dataset is a preference dataset or not. (default: False)",
2023-11-03 00:15:23 +08:00
"subset": "the name of the subset. (optional, default: None)",
2024-07-14 21:27:04 +08:00
"split": "the name of dataset split to be used. (optional, default: train)",
2023-12-09 20:53:18 +08:00
"folder": "the name of the folder of the dataset repository on the Hugging Face hub. (optional, default: None)",
2024-07-14 21:27:04 +08:00
"num_samples": "the number of samples in the dataset to be used. (optional, default: None)",
2024-02-10 16:39:19 +08:00
"columns (optional)": {
2024-01-21 22:17:48 +08:00
"prompt": "the column name in the dataset containing the prompts. (default: instruction)",
"query": "the column name in the dataset containing the queries. (default: input)",
"response": "the column name in the dataset containing the responses. (default: output)",
"history": "the column name in the dataset containing the histories. (default: None)",
"messages": "the column name in the dataset containing the messages. (default: conversations)",
"system": "the column name in the dataset containing the system prompts. (default: None)",
2024-04-26 05:34:58 +08:00
"tools": "the column name in the dataset containing the tool description. (default: None)",
2024-05-18 03:44:56 +08:00
"images": "the column name in the dataset containing the image inputs. (default: None)",
"chosen": "the column name in the dataset containing the chosen answers. (default: None)",
"rejected": "the column name in the dataset containing the rejected answers. (default: None)",
"kto_tag": "the column name in the dataset containing the kto tags. (default: None)"
2024-01-21 22:17:48 +08:00
},
2024-02-10 16:39:19 +08:00
"tags (optional, used for the sharegpt format)": {
2024-01-21 22:17:48 +08:00
"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)",
2024-02-09 02:32:20 +08:00
"function_tag": "the value of the role_tag represents the function call. (default: function_call)",
2024-05-30 00:04:26 +08:00
"system_tag": "the value of the role_tag represents the system prompt. (default: system, can override system column)"
}
2023-05-28 18:09:04 +08:00
}
```
2024-05-18 21:15:20 +08:00
## Alpaca Format
### Supervised Fine-Tuning Dataset
2024-05-18 21:37:38 +08:00
* [Example dataset](alpaca_en_demo.json)
2024-05-18 21:15:20 +08:00
In supervised fine-tuning, the `instruction` column will be concatenated with the `input` column and used as the human prompt, then the human prompt would be `instruction\ninput`. The `output` column represents the model response.
2024-03-31 18:29:50 +08:00
2024-05-18 21:15:20 +08:00
The `system` column will be used as the system prompt if specified.
2024-05-18 21:37:38 +08:00
The `history` column is a list consisting of string tuples representing prompt-response pairs in the history messages. Note that the responses in the history **will also be learned by the model** in supervised fine-tuning.
2023-11-03 00:15:23 +08:00
```json
[
{
2024-05-18 03:44:56 +08:00
"instruction": "human instruction (required)",
"input": "human input (optional)",
2023-11-03 00:15:23 +08:00
"output": "model response (required)",
2023-12-12 19:45:59 +08:00
"system": "system prompt (optional)",
2023-11-03 00:15:23 +08:00
"history": [
2024-05-18 03:44:56 +08:00
["human instruction in the first round (optional)", "model response in the first round (optional)"],
["human instruction in the second round (optional)", "model response in the second round (optional)"]
2023-11-03 00:15:23 +08:00
]
}
]
```
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2023-11-03 00:15:23 +08:00
```json
"dataset_name": {
2024-05-02 02:13:46 +08:00
"file_name": "data.json",
2023-11-03 00:15:23 +08:00
"columns": {
"prompt": "instruction",
"query": "input",
"response": "output",
2023-12-12 19:45:59 +08:00
"system": "system",
2023-11-03 00:15:23 +08:00
"history": "history"
}
}
```
2024-05-18 21:15:20 +08:00
### Pre-training Dataset
2023-11-03 00:15:23 +08:00
2024-05-18 21:37:38 +08:00
- [Example dataset](c4_demo.json)
In pre-training, only the `text` column will be used for model learning.
2023-11-03 00:15:23 +08:00
2024-05-02 02:13:46 +08:00
```json
[
{"text": "document"},
{"text": "document"}
]
```
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2023-08-22 19:46:09 +08:00
```json
2024-05-02 02:13:46 +08:00
"dataset_name": {
"file_name": "data.json",
"columns": {
"prompt": "text"
}
}
```
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
### Preference Dataset
Preference datasets are used for reward modeling, DPO training and ORPO training.
It requires a better response in `chosen` column and a worse response in `rejected` column.
2024-05-02 02:13:46 +08:00
```json
[
{
2024-05-18 21:15:20 +08:00
"instruction": "human instruction (required)",
"input": "human input (optional)",
"chosen": "chosen answer (required)",
"rejected": "rejected answer (required)"
2024-05-02 02:13:46 +08:00
}
]
```
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2024-05-02 02:13:46 +08:00
```json
"dataset_name": {
"file_name": "data.json",
"ranking": true,
"columns": {
"prompt": "instruction",
"query": "input",
2024-05-18 03:44:56 +08:00
"chosen": "chosen",
"rejected": "rejected"
2024-05-02 02:13:46 +08:00
}
}
```
2024-03-31 18:29:50 +08:00
2024-05-18 21:15:20 +08:00
### KTO Dataset
2023-11-03 00:15:23 +08:00
2024-05-18 21:37:38 +08:00
- [Example dataset](kto_en_demo.json)
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
KTO datasets require a extra `kto_tag` column containing the boolean human feedback.
```json
[
{
"instruction": "human instruction (required)",
"input": "human input (optional)",
"output": "model response (required)",
"kto_tag": "human feedback [true/false] (required)"
}
]
```
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2023-08-22 19:46:09 +08:00
```json
2024-05-18 21:15:20 +08:00
"dataset_name": {
"file_name": "data.json",
"columns": {
"prompt": "instruction",
"query": "input",
"response": "output",
"kto_tag": "kto_tag"
}
}
```
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
### Multimodal Dataset
2024-05-18 21:37:38 +08:00
- [Example dataset](mllm_demo.json)
Multimodal datasets require a `images` column containing the paths to the input images. Currently we only support one image.
2024-05-18 21:15:20 +08:00
```json
[
{
"instruction": "human instruction (required)",
"input": "human input (optional)",
"output": "model response (required)",
"images": [
"image path (required)"
]
}
]
```
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
```json
"dataset_name": {
"file_name": "data.json",
"columns": {
"prompt": "instruction",
"query": "input",
"response": "output",
"images": "images"
}
}
```
## Sharegpt Format
### Supervised Fine-Tuning Dataset
2024-05-18 21:37:38 +08:00
- [Example dataset](glaive_toolcall_en_demo.json)
Compared to the alpaca format, the sharegpt format allows the datasets have **more roles**, such as human, gpt, observation and function. They are presented in a list of objects in the `conversations` column.
2024-05-18 21:15:20 +08:00
Note that the human and observation should appear in odd positions, while gpt and function should appear in even positions.
2023-11-03 00:15:23 +08:00
```json
[
{
"conversations": [
{
"from": "human",
2024-05-18 21:15:20 +08:00
"value": "human instruction"
},
{
2024-05-18 21:37:38 +08:00
"from": "function_call",
"value": "tool arguments"
2024-05-18 21:15:20 +08:00
},
2023-11-03 00:15:23 +08:00
{
2024-05-18 21:37:38 +08:00
"from": "observation",
"value": "tool result"
2023-11-03 00:15:23 +08:00
},
{
"from": "gpt",
"value": "model response"
}
2023-12-12 19:45:59 +08:00
],
2024-01-21 22:17:48 +08:00
"system": "system prompt (optional)",
"tools": "tool description (optional)"
2023-11-03 00:15:23 +08:00
}
]
```
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2023-11-03 00:15:23 +08:00
```json
"dataset_name": {
2024-05-02 02:13:46 +08:00
"file_name": "data.json",
"formatting": "sharegpt",
2023-11-03 00:15:23 +08:00
"columns": {
"messages": "conversations",
2024-01-21 22:17:48 +08:00
"system": "system",
"tools": "tools"
2023-11-03 00:15:23 +08:00
}
}
```
2024-05-18 21:15:20 +08:00
### Preference Dataset
2024-05-18 21:37:38 +08:00
- [Example dataset](dpo_en_demo.json)
2024-05-18 21:15:20 +08:00
Preference datasets in sharegpt format also require a better message in `chosen` column and a worse message in `rejected` column.
```json
[
{
"conversations": [
{
"from": "human",
"value": "human instruction"
},
{
"from": "gpt",
"value": "model response"
},
{
"from": "human",
"value": "human instruction"
}
],
"chosen": {
"from": "gpt",
"value": "chosen answer (required)"
},
"rejected": {
"from": "gpt",
"value": "rejected answer (required)"
}
}
]
```
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
```json
"dataset_name": {
"file_name": "data.json",
"formatting": "sharegpt",
"ranking": true,
"columns": {
"messages": "conversations",
"chosen": "chosen",
"rejected": "rejected"
}
}
```
### OpenAI Format
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
The openai format is simply a special case of the sharegpt format, where the first message may be a system prompt.
2024-05-02 02:13:46 +08:00
```json
[
{
"messages": [
{
"role": "system",
"content": "system prompt (optional)"
},
{
"role": "user",
2024-05-18 03:44:56 +08:00
"content": "human instruction"
2024-05-02 02:13:46 +08:00
},
{
"role": "assistant",
"content": "model response"
}
]
}
]
```
2024-05-18 21:15:20 +08:00
Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
2024-05-02 02:13:46 +08:00
```json
"dataset_name": {
"file_name": "data.json",
"formatting": "sharegpt",
"columns": {
"messages": "messages"
2024-01-21 22:17:48 +08:00
},
"tags": {
2024-05-02 02:13:46 +08:00
"role_tag": "role",
"content_tag": "content",
"user_tag": "user",
"assistant_tag": "assistant",
"system_tag": "system"
2023-11-03 00:15:23 +08:00
}
}
```
2024-05-18 21:15:20 +08:00
The KTO datasets and multimodal datasets in sharegpt format are similar to the alpaca format.
2023-11-03 00:15:23 +08:00
2024-05-18 21:15:20 +08:00
Pre-training datasets are **incompatible** with the sharegpt format.