diff --git a/README.md b/README.md index 641ea94d6..d0883f8dd 100644 --- a/README.md +++ b/README.md @@ -195,10 +195,18 @@ XTuner provides tools to chat with pretrained / fine-tuned LLMs. xtuner chat ${NAME_OR_PATH_TO_LLM} --adapter {NAME_OR_PATH_TO_ADAPTER} [optional arguments] ``` -For example, we can start the chat with Llama2-7b with adapter trained from MOSS-003-SFT by +For example, we can start the chat with + +InternLM-7B with adapter trained from Alpaca-enzh: + +```shell +xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-alpaca-enzh --prompt-template internlm_chat --system-template alpaca +``` + +Llama2-7b with adapter trained from MOSS-003-SFT: ```shell -xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer +xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --system-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer ``` For more examples, please see [chat.md](./docs/en/user_guides/chat.md). diff --git a/README_zh-CN.md b/README_zh-CN.md index a9d41948f..d7d237edd 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -194,10 +194,18 @@ XTuner 提供与大语言模型对话的工具。 xtuner chat ${NAME_OR_PATH_TO_LLM} --adapter {NAME_OR_PATH_TO_ADAPTER} [optional arguments] ``` -例如,与 Llama2-7b + MOSS-003-SFT adapter 对话: +例如: + +与 InternLM-7B + Alpaca-enzh adapter 对话: + +```shell +xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-alpaca-enzh --prompt-template internlm_chat --system-template alpaca +``` + +与 Llama2-7b + MOSS-003-SFT adapter 对话: ```shell -xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer +xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --system-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer ``` 更多示例,请查阅[文档](./docs/zh_cn/user_guides/chat.md)。 diff --git a/docs/en/user_guides/chat.md b/docs/en/user_guides/chat.md index 38c8d5057..ec7d69f1e 100644 --- a/docs/en/user_guides/chat.md +++ b/docs/en/user_guides/chat.md @@ -1,129 +1,3 @@ # Chat with fine-tuned LLMs -## Chat with [InternLM](https://github.com/InternLM/InternLM) - -- InternLM-7B, oasst1 - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-oasst1 --prompt-template openassistant - ``` - -- InternLM-7B, Arxiv Gentitle - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-arxiv-gentitle --prompt-template title - ``` - -- InternLM-7B, Colorist - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-colorist --prompt-template colorist - ``` - -- InternLM-7B, Coder - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-coder --prompt-template code - ``` - -- InternLM-7B, SQL - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-sql --prompt-template sql - ``` - -- InternLM-7B, Lawyer - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-lawyer --prompt-template lawyer - ``` - -- InternLM-7B, Open-Platypus - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-open-platypus --prompt-template alpaca - ``` - -- InternLM-7B, Alpaca-enzh - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-alpaca-enzh --prompt-template alpaca - ``` - -## Chat with [Llama2](https://github.com/facebookresearch/llama) - -> Don't forget to use `huggingface-cli login` and input your access token first to access Llama2! See [here](https://huggingface.co/docs/hub/security-tokens#user-access-tokens) to learn how to obtain your access token. - -- Llama2-7B, MOSS-003-SFT **(plugins!)** - - ```shell - export SERPER_API_KEY="xxx" # Please get the key from https://serper.dev to support google search! - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer - ``` - -- Llama2-7B, Arxiv Gentitle - - ```shell - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-arxiv-gentitle --prompt-template title - ``` - -- Llama2-7B, Colorist - - ```shell - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-colorist --prompt-template colorist - ``` - -## Chat with [Qwen](https://github.com/QwenLM) - -- Qwen-7B, MOSS-003-SFT **(plugins!)** - - ```shell - export SERPER_API_KEY="xxx" # Please get the key from https://serper.dev to support google search! - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-moss-003-sft --bot-name Qwen --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" - ``` - -- Qwen-7B, oasst1 - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-oasst1 --prompt-template openassistant --answer-stop-word '<|endoftext|>' - ``` - -- Qwen-7B, Arxiv Gentitle - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-arxiv-gentitle --prompt-template title --answer-stop-word '<|endoftext|>' - ``` - -- Qwen-7B, Alpaca-enzh - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-alpaca-enzh --prompt-template alpaca --answer-stop-word '<|endoftext|>' - ``` - -## Chat with [Baichuan](https://github.com/baichuan-inc) - -- Baichuan-7B, oasst1 - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-oasst1 --prompt-template openassistant - ``` - -- Baichuan-7B, Arxiv Gentitle - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-arxiv-gentitle --prompt-template title --no-streamer - ``` - -- Baichuan-7B, Alpaca-enzh - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-alpaca-enzh --prompt-template alpaca - ``` - - ## Chat with [CodeLlama](https://github.com/facebookresearch/codellama) - -- CodeLlama-7B, Instruct - - ```shell - xtuner chat codellama/CodeLlama-7b-Instruct-hf --prompt-template code_llama_chat - ``` +Coming soon. diff --git a/docs/en/user_guides/dataset_format.md b/docs/en/user_guides/dataset_format.md index 673860e95..46e3d6f80 100644 --- a/docs/en/user_guides/dataset_format.md +++ b/docs/en/user_guides/dataset_format.md @@ -1,11 +1,18 @@ # Dataset Format +- [Incremental Pre-training Dataset Format](#incremental-pre-training-dataset-format) +- [Single-turn Dialogue Dataset Format](#single-turn-dialogue-dataset-format) +- [Multi-turn Dialogue Dataset Format](#multi-turn-dialogue-dataset-format) + - [Method 1](#method-1) + - [Method 2](#method-2) + - [Method in XTuner](#method-in-xtuner) + The Supervised Finetune (SFT) of large language models aims to improve the performance of pre-trained models on specific tasks through supervised fine-tuning. To support as many downstream tasks as possible, XTuner supports three dataset formats: incremental pre-training, single-turn dialogue, and multi-turn dialogue. - The incremental pre-training dataset is used to enhance the model's capabilities in a specific domain or task. - Single-turn and multi-turn dialogue datasets are often used in the instruction tuning stage to enhance the model's ability to respond to specific instructions. -In the instruction tuning phase, our goal is to train the language model to answer based on human instructions. **Therefore, generally only the loss of the response part (Output) is used for gradient backpropagation, while the loss of the instruction part (Input) is not used for weight updates.** Based on this, we introduce "input" and "output" fields when preprocessing the dataset. The "input" field is used to save fields that do not need to compute loss, such as user instructions, whereas the "output" field is used to save fields that do need to compute loss, such as the GroundTruth answers corresponding to input instructions. +In the instruction tuning phase, our goal is to train the language model to answer based on human instructions. **Therefore, generally only the loss of the response part (Output) is used for gradient backpropagation, while the loss of the instruction part (System, Input) is not used for weight updates.** Based on this, we introduce "system", "input" and "output" fields when preprocessing the dataset. The "system", "input" fields are used to save fields that do not need to compute loss, such as system and user instructions, whereas the "output" field is used to save fields that do need to compute loss, such as the GroundTruth answers corresponding to input instructions. To unify the incremental pre-training, single-turn dialogue, and multi-turn dialogue dataset formats, we set the dataset format to the following form: @@ -13,6 +20,7 @@ To unify the incremental pre-training, single-turn dialogue, and multi-turn dial [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -21,6 +29,7 @@ To unify the incremental pre-training, single-turn dialogue, and multi-turn dial { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -32,22 +41,23 @@ To unify the incremental pre-training, single-turn dialogue, and multi-turn dial }] ``` -Throughout the training phase, we amalgamate several "input" and "output" pairs from a single data instance, which we then feed into the model. Loss is computed concurrently at each position, yet only the loss associated with the "output" component participates in the gradient backpropagation process. This process is elucidated in the figure below. +Throughout the training phase, we amalgamate several "system", "input" and "output" pairs from a single data instance, which we then feed into the model. Loss is computed concurrently at each position, yet only the loss associated with the "output" component participates in the gradient backpropagation process. This process is elucidated in the figure below.
-Image +Image
Note that the token and token are used to indicate the start and end of a sentence or text. ## Incremental Pre-training Dataset Format -As incremental pre-training is intended to help the model learn language knowledge and expressive abilities tailored for specific downstream tasks, the loss corresponding to the entire content of the dataset should be used for gradient backpropagation. Therefore, the "input" of the dataset is left empty, while the "output" consists of an entire piece of corpus data. The dataset format corresponding to the incremental pre-training task is shown as follows: +As incremental pre-training is intended to help the model learn language knowledge and expressive abilities tailored for specific downstream tasks, the loss corresponding to the entire content of the dataset should be used for gradient backpropagation. Therefore, the "system" and "input" of the dataset are left empty, while the "output" consists of an entire piece of corpus data. The dataset format corresponding to the incremental pre-training task is shown as follows: ```json [{ "conversation":[ { + "system": "", "input": "", "output": "I am an artificial intelligence (AI) assistant named Puyu. I was created by the Shanghai AI Laboratory and my purpose is to assist users with various tasks through natural language processing technology." } @@ -56,6 +66,7 @@ As incremental pre-training is intended to help the model learn language knowled { "conversation":[ { + "system": "", "input": "", "output": "I am an artificial intelligence programmed to assist with various types of tasks, including answering questions, providing information, and performing automated processes." } @@ -69,38 +80,39 @@ As incremental pre-training is intended to help the model learn language knowled ## Single-turn Dialogue Dataset Format -The single-turn dialogue dataset typically consists of a single instruction (or question) and its corresponding GroundTruth answer. Since only the answer part should be used for gradient backpropagation, the "input" field of the dataset is the input instruction, and the "output" field is the corresponding answer. The format of the single-turn dialogue dataset is shown as follows: +The single-turn dialogue dataset typically consists of a single instruction (or question) and its corresponding GroundTruth answer. Since only the answer part should be used for gradient backpropagation, the "system" and "input" fields of the dataset are the input instruction, and the "output" field is the corresponding answer. The format of the single-turn dialogue dataset is shown as follows: ```json [{ - "conversation": - [ - { - "input": "Give three tips for staying healthy.", - "output": "1.Eat a balanced diet. 2. Exercise regularly. 3. Get enough sleep." - } - ] + "conversation":[ + { + "system": "You are an AI asssistant." + "input": "Give three tips for staying healthy.", + "output": "1.Eat a balanced diet. 2. Exercise regularly. 3. Get enough sleep." + } + ] }, { - "conversation": - [ - { - "input": "How to study English?", - "output": "1. Set clear goals. 2. Create a study plan. 3. Build vocabulary. 4. Practice speaking." - } - ] + "conversation":[ + { + "system": "You are an AI asssistant." + "input": "How to study English?", + "output": "1. Set clear goals. 2. Create a study plan. 3. Build vocabulary. 4. Practice speaking." + } + ] }] ```
-Image +Image
## Multi-turn Dialogue Dataset Format -The multi-turn dialogue dataset typically consists of multiple rounds of instructions (or questions) and their corresponding GroundTruth answers. Suppose we have a piece of multi-turn dialogue data. For ease of introduction, for the nth round of dialogue, we set the output corresponding to User and Assistant as Usern and Assistantn. +The multi-turn dialogue dataset typically consists of multiple rounds of instructions (or questions) and their corresponding GroundTruth answers. Suppose we have a piece of multi-turn dialogue data. For ease of introduction, for the nth round of dialogue, we set the output corresponding to User and Assistant as UserN and AssistantN. ```text +System: You are an AI asssistant. User1:Hello? Assistant1:Hello! How can I help you? User2:What's the date today? @@ -113,10 +125,10 @@ How can we use the above multi-turn dialogue data to train large models? Current ### Method 1 -The text of User1, Assistant1, User2, Assistant2, and User3 is all considered as the input part of the model, while the text of Assistant3 is viewed as the prediction part of the model. Only the loss from the Assistant3 part is involved in the weight update. +The text of System, User1, Assistant1, User2, Assistant2, and User3 is all considered as the input part of the model, while the text of Assistant3 is viewed as the prediction part of the model. Only the loss from the Assistant3 part is involved in the weight update.
-Image +Image
The downside of this method is that it does not fully utilize the multi-turn dialogue training data because the content of Assistant1 and Assistant2 does not participate in model training, leading to a low utilization rate of training data. @@ -126,7 +138,7 @@ The downside of this method is that it does not fully utilize the multi-turn dia Split a piece of multi-turn dialogue data into multiple pieces of data. For example, the above instance can be split into the following three pieces of data.
-Image +Image
Compared to Method 1, Method 2 can fully utilize the data from each round of dialogue, but it requires splitting one piece of data containing n rounds of dialogue into n pieces of data, which reduces the training efficiency by 1/n. @@ -136,7 +148,7 @@ Compared to Method 1, Method 2 can fully utilize the data from each round of dia When XTuner trains multi-turn dialogue models, it adopts a more comprehensive and efficient method, as shown in the figure below.
-Image +Image
We concatenate multi-turn dialogues, then input them into the model. The loss at each position is computed in parallel, but only the loss from the Output part participates in backpropagation. Therefore, the format of the multi-turn dialogue dataset in XTuner is shown as follows: @@ -145,6 +157,7 @@ We concatenate multi-turn dialogues, then input them into the model. The loss at [{ "conversation":[ { + "system": "You are an AI asssistant." "input": "Hello?", "output": "Hello! How can I help you?" }, @@ -161,6 +174,7 @@ We concatenate multi-turn dialogues, then input them into the model. The loss at { "conversation":[ { + "system": "You are an AI asssistant." "input": "Hello?", "output": "Hello! How can I help you?" }, diff --git a/docs/en/user_guides/dataset_prepare.md b/docs/en/user_guides/dataset_prepare.md index 64113bf09..8e6481f23 100644 --- a/docs/en/user_guides/dataset_prepare.md +++ b/docs/en/user_guides/dataset_prepare.md @@ -1,5 +1,11 @@ # Dataset Prepare +- [HuggingFace datasets](#huggingface-datasets) +- [Others](#others) + - [Arxiv Gentitle](#arxiv-gentitle) + - [MOSS-003-SFT](#moss-003-sft) + - [Chinese Lawyer](#chinese-lawyer) + ## HuggingFace datasets For datasets on HuggingFace Hub, such as [alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca), you can quickly utilize them. For more details, please refer to [single_turn_conversation.md](./single_turn_conversation.md) and [multi_turn_conversation.md](./multi_turn_conversation.md). diff --git a/docs/en/user_guides/incremental_pretraining.md b/docs/en/user_guides/incremental_pretraining.md index 607e91b3e..6ff43457c 100644 --- a/docs/en/user_guides/incremental_pretraining.md +++ b/docs/en/user_guides/incremental_pretraining.md @@ -1,14 +1,15 @@ # Incremental Pre-training Data Pipeline -Incremental pre-training aims to enhance the model's capability in a specific domain or task. +- [Using Dataset in HuggingFace Hub](#using-dataset-in-huggingface-hub) +- [Using Custom Datasets](#using-custom-datasets) -## Dataset Construction +Incremental pre-training aims to enhance the model's capability in a specific domain or task. XTuner supports using HuggingFace Hub datasets or custom datasets for SFT (Supervised FineTune). The main difference between them is that when using HuggingFace Hub datasets, it is necessary to map the original data to the [incremental pre-training data format](./dataset_format.md#incremental-pre-training-dataset-format)defined by XTuner. For custom datasets, users are recommended to construct the dataset according to the [incremental pre-training data format](./dataset_format.md#incremental-pre-training-dataset-format). -### Using Dataset in HuggingFace Hub +## Using Dataset in HuggingFace Hub -#### Step 1, Map Original Dataset to Standard Format +### Step 1, Map Original Dataset to Standard Format Since different datasets have different formats, it is necessary to map the original data to the [incremental pre-training data format](./dataset_format.md#incremental-pre-training-dataset-format) defined by XTuner. XTuner supports the implementation of format mapping through the map function. The following uses the [oasst1 dataset](https://huggingface.co/datasets/OpenAssistant/oasst1) as an example to explain how to implement data mapping. @@ -42,7 +43,7 @@ Therefore, you can map the original data to the standard format using the follow ```python # Suppose the function is stored in ./map_fn.py -def oasst1_incremental_map_fn(example): +def custom_map_fn(example): """ >>> train_ds = ds['train'].map(oasst1_map_fn) >>> train_ds @@ -57,7 +58,7 @@ def oasst1_incremental_map_fn(example): ``` -#### Step 2, List Candidate Model Names +### Step 2, List Candidate Model Names XTuner provides several ready-to-use configuration files. Users can view them with the following command: @@ -67,7 +68,7 @@ xtuner list-cfg -p internlm `-p` is used for fuzzy search. If you want to train other models, you can replace internlm with other model names supported by XTuner. -#### Step 3, Export the Config File +### Step 3, Export the Config File If the provided configuration file does not meet your needs, please export the provided configuration file and make corresponding changes: @@ -81,15 +82,15 @@ For example, you can export the config named \`internlm_7b_qlora_oasst1_e3\`\` t xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -#### Step 4, Modify the Config File +### Step 4, Modify the Config File The following modifications need to be made to the config file copied in Step 3: 1. Import the mapping function `oasst1_incremental_map_fn` implemented in Step 1. -2. Replace the `dataset_map_fn` in `train_dataset` with `oasst1_incremental_map_fn`. -3. Set the `template_map_fn` in `train_dataset` to None (because there is no need to add the dialogue template to the incremental pre-training dataset). +2. Replace the `dataset_map_fn` in `train_dataset` with `custom_map_fn`. +3. Set the `template_map_fn` in `train_dataset` to \`None\`\` (because there is no need to add the dialogue template to the incremental pre-training dataset). 4. Adjust the path of the original dataset. For operations related to `load_dataset`, refer to the [user document](https://huggingface.co/docs/datasets/loading). -5. (Optional) If you wish to use XTuner's `EvaluateChatHook` to view the model's generation results during training, you also need to turn off `prompt_template` to remove the conversation template. (Note: Since the model only has a continuation function during incremental pre-training and doesn't have the conversation function, the model may not be able to stop generating normally in the dialogue results printed by `EvaluateChatHook`.) +5. Close the `EvaluateChatHook`, since the model only has a continuation function during incremental pre-training and doesn't have the conversation function. ```diff from xtuner.dataset import process_hf_dataset @@ -97,13 +98,13 @@ from datasets import load_dataset - from xtuner.dataset.map_fns import oasst1_map_fn, template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import oasst1_incremental_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' -- prompt_template = PROMPT_TEMPLATE.openassistant +- prompt_template = PROMPT_TEMPLATE.internlm_chat + data_path = 'path/to/your/data' ####################################################################### # STEP 3 Dataset & Dataloader # @@ -114,20 +115,13 @@ train_dataset = dict( tokenizer=tokenizer, max_length=max_length, - dataset_map_fn=oasst1_map_fn, -+ dataset_map_fn=oasst1_incremental_map_fn, ++ dataset_map_fn=custom_map_fn, - template_map_fn=dict( - type=template_map_fn_factory, template=prompt_template), + template_map_fn=None, remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ####################################################################### # PART 5 Runtime # @@ -135,32 +129,32 @@ train_dataloader = dict( # Log the dialogue periodically during the training process, optional custom_hooks = [ dict(type=DatasetInfoHook, tokenizer=tokenizer), - dict( - type=EvaluateChatHook, - tokenizer=tokenizer, - every_n_iters=evaluation_freq, - evaluation_inputs=evaluation_inputs, -- instruction=prompt_template.INSTRUCTION_START) -+ ) +- dict( +- type=EvaluateChatHook, +- tokenizer=tokenizer, +- every_n_iters=evaluation_freq, +- evaluation_inputs=evaluation_inputs, +- system=SYSTEM, +- instruction=prompt_template.INSTRUCTION) ] ... ``` -#### Step 5, Log Processed Dataset (Optional) +### Step 5, Check custom Dataset (Optional) -After modifying the config file, you can print the first data of the processed dataset to verify whether the dataset has been constructed correctly. +After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` `$CONFIG` represents the file path of the modified configuration file in Step 4. -### Using Custom Datasets +## Using Custom Datasets When using custom datasets for incremental pre-training, we recommend constructing the dataset according to the [incremental pre-training data format](./dataset_format.md#incremental-pre-training-dataset-format) defined by XTuner. If the custom dataset is in other formats such as oasst1, refer to the section on [Using Dataset in HuggingFace Hub](#using-dataset-in-huggingface-hub). -#### Step 1, Data Preparation +### Step 1, Data Preparation Prepare custom data according to the [incremental pre-training data format](./dataset_format.md#incremental-pre-training-dataset-format) defined by XTuner: @@ -185,7 +179,7 @@ Prepare custom data according to the [incremental pre-training data format](./da ] ``` -#### Step 2, List Candidate Model Names +### Step 2, List Candidate Model Names ```bash xtuner list-cfg -p internlm @@ -193,20 +187,20 @@ xtuner list-cfg -p internlm The `-p` option is for fuzzy search. If you want to train other models, you can replace internlm with the name of any other model supported by XTuner. -#### Step 3, Export the Config File +### Step 3, Export the Config File ```bash xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -#### Step 4, Modify the config file +### Step 4, Modify the config file Modifications need to be made to the config file obtained in Step 3 as follows: 1. Adjust the path of the original dataset -2. Since the dataset format is already standardized, set `dataset_map_fn` in `train_dataset` to None -3. Set `template_map_fn` in `train_dataset` to None, because there is no need to add conversation templates to the incremental pre-training dataset -4. (Optional) Set a chat template to call `EvaluateChatHook` to record the results of the model's dialogues at various stages of training +2. Since the dataset format is already standardized, set `dataset_map_fn` in `train_dataset` to `None` +3. Set `template_map_fn` in `train_dataset` to `None`, because there is no need to add conversation templates to the incremental pre-training dataset +4. Close the `EvaluateChatHook`, since the model only has a continuation function during incremental pre-training and doesn't have the conversation function. ```diff from xtuner.dataset import process_hf_dataset @@ -238,13 +232,6 @@ train_dataset = dict( remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ####################################################################### # PART 5 Runtime # @@ -252,18 +239,18 @@ train_dataloader = dict( # Log the dialogue periodically during the training process, optional custom_hooks = [ dict(type=DatasetInfoHook, tokenizer=tokenizer), - dict( - type=EvaluateChatHook, - tokenizer=tokenizer, - every_n_iters=evaluation_freq, - evaluation_inputs=evaluation_inputs, -- instruction=prompt_template.INSTRUCTION_START) -+ ) +- dict( +- type=EvaluateChatHook, +- tokenizer=tokenizer, +- every_n_iters=evaluation_freq, +- evaluation_inputs=evaluation_inputs, +- system=SYSTEM, +- instruction=prompt_template.INSTRUCTION) ] ... ``` -#### Step 5, Check custom Dataset (Optional) +### Step 5, Check custom Dataset (Optional) After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. diff --git a/docs/en/user_guides/multi_turn_conversation.md b/docs/en/user_guides/multi_turn_conversation.md index e265af305..783d2ec68 100644 --- a/docs/en/user_guides/multi_turn_conversation.md +++ b/docs/en/user_guides/multi_turn_conversation.md @@ -1,9 +1,9 @@ # Multi-turn Dialogue Data Pipeline -The purpose of multi-turn dialogue command fine-tuning is to enhance the model's ability for multi-turn dialogues. The data processing process can be divided into the following two parts: +- [Using Dataset in HuggingFace Hub](#using-dataset-in-huggingface-hub) +- [Using Custom Datasets](#using-custom-datasets) -1. Construct data according to the corresponding dataset format -2. Insert dialogue templates into the dataset (optional) +The purpose of multi-turn dialogue command fine-tuning is to enhance the model's ability for multi-turn dialogues. XTuner supports the use of HuggingFace Hub datasets or custom datasets for SFT (Supervised FineTune). The main difference between them is that when using the HuggingFace Hub dataset, the original data needs to be mapped to the [multi-turn dialogue data format](./dataset_format.md#multi-turn-dialogue-dataset-format) defined by XTuner. For custom datasets, it is recommended that users construct the dataset according to the [multi-turn dialogue data format](./dataset_format.md#multi-turn-dialogue-dataset-format). @@ -34,6 +34,7 @@ It's clear that the oasst1 dataset can not only be used as an incremental pre-tr [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -46,6 +47,7 @@ It's clear that the oasst1 dataset can not only be used as an incremental pre-tr { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -61,7 +63,8 @@ Therefore, the original data can be mapped to a standard format using the follow ```python # Suppose the function is stored in ./map_fn.py -def oasst1_multi_turns_map_fn(example): +SYSTEM_OASST1 = '' # oasst1 does not set the system text +def custom_map_fn(example): r""" Example before preprocessing: example['text'] = '### Human: Can you explain xxx' @@ -96,7 +99,11 @@ def oasst1_multi_turns_map_fn(example): data.pop() conversation = [] for i in range(0, len(data), 2): - single_turn_conversation = {'input': data[i], 'output': data[i + 1]} + system = SYSTEM_OASST1 if i == 0 else '' + single_turn_conversation = { + 'system': system, + 'input': data[i], + 'output': data[i + 1]} conversation.append(single_turn_conversation) return {'conversation': conversation} ``` @@ -125,30 +132,13 @@ For example, use the following command to export the config named `internlm_7b_q xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -### Step 4, Set Conversation Templates (Optional) - -Conversation templates refer to predefined patterns or structures used for generating dialogues. These templates may include questions, answers, or different roles' speeches in multi-turn dialogues. Adding conversation templates to the training dataset helps the model generate structured and logical dialogues and provide more accurate, consistent, and reasonable responses. - -Different datasets and language models may correspond to different conversation templates. For instance, the conversation template of the [oasst1 dataset](https://huggingface.co/datasets/OpenAssistant/oasst1) is as follows: - -``` -### Human: -xxx - -### Assistant: -xxx -``` - -XTuner provides a series of conversation templates, which you can find in `xtuner/utils/templates.py`. Among them, `INSTRUCTION_START` and `INSTRUCTION` represent the conversation templates used for the first round dialogue and subsequent rounds of dialogues, respectively. - -### Step 5, Modify Config Files +### Step 4, Modify Config Files The config file copied in Step 3 needs to be modified as follows: -1. Import the map function `oasst1_multi_turns_map_fn` implemented in Step 1. -2. Replace `dataset_map_fn` in `train_dataset` with `oasst1_multi_turns_map_fn`. -3. (Optional) Set the conversation template corresponding to the `oasst1` dataset via `prompt_template = PROMPT_TEMPLATE.openassistant`. -4. Adjust the path of the original dataset. You can refer to the [user documentation](https://huggingface.co/docs/datasets/loading) for operations related to `load_dataset`. +1. Import the map function `custom_map_fn` implemented in Step 1. +2. Replace `dataset_map_fn` in `train_dataset` with `custom_map_fn`. +3. Adjust the path of the original dataset. You can refer to the [user documentation](https://huggingface.co/docs/datasets/loading) for operations related to `load_dataset`. ```diff from xtuner.dataset import process_hf_dataset @@ -157,15 +147,13 @@ from datasets import load_dataset + from xtuner.dataset.map_fns import template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import oasst1_multi_turns_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' + data_path = 'path/to/your/data' - -+ prompt_template = PROMPT_TEMPLATE.openassistant ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -175,31 +163,25 @@ train_dataset = dict( dataset=dict(type=load_dataset, path=data_path), tokenizer=tokenizer, max_length=max_length, -+ dataset_map_fn=oasst1_multi_turns_map_fn, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), +- dataset_map_fn=oasst1_map_fn, ++ dataset_map_fn=custom_map_fn, + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, Log Processed Dataset (Optional) +### Step 5, Check custom Dataset (Optional) -After modifying the config file, you can print the first data of the processed dataset to verify whether the dataset has been constructed correctly. +After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` -`$CONFIG` represents the file path of the modified configuration file in Step 5. +`$CONFIG` represents the file path of the modified configuration file in Step 4. ## Using Custom Datasets @@ -213,6 +195,7 @@ Prepare your custom data according to the [multi-turn dialogue data format](./da [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -225,6 +208,7 @@ Prepare your custom data according to the [multi-turn dialogue data format](./da { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -250,17 +234,12 @@ xtuner list-cfg -p internlm xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -### Step 4, Setting Dialogue Template (Optional) - -Refer to [Setting the Dialogue Template](#step-4-set-conversation-templates-optional). - -### Step 5, Modify Config File +### Step 4, Modify Config File The config file copied in Step 3 needs to be modified as follows: 1. Adjust the path of the original dataset -2. Since the dataset format is already in the standard format, set `dataset_map_fn` in `train_dataset` to None -3. Set the dialogue template +2. Since the dataset format is already in the standard format, set `dataset_map_fn` in `train_dataset` to `None` ```diff from xtuner.dataset import process_hf_dataset @@ -273,8 +252,6 @@ from datasets import load_dataset ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' + data_path = 'path/to/your/json/data' - -+ prompt_template = PROMPT_TEMPLATE.openassistant ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -286,23 +263,17 @@ train_dataset = dict( + type=load_dataset, path='json', data_files=dict(train=data_path)), tokenizer=tokenizer, max_length=max_length, +- dataset_map_fn=oasst1_map_fn, + dataset_map_fn=None, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, Check Processed Dataset (Optional) +### Step 5, Check custom Dataset (Optional) After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. @@ -310,4 +281,4 @@ After modifying the config file, you can execute the 'xtuner/tools/check_custom_ xtuner check-custom-dataset $CONFIG ``` -`$CONFIG` represents the file path of the modified configuration file in Step 5. +`$CONFIG` represents the file path of the modified configuration file in Step 4. diff --git a/docs/en/user_guides/single_turn_conversation.md b/docs/en/user_guides/single_turn_conversation.md index 683c73647..8e5f98f7a 100644 --- a/docs/en/user_guides/single_turn_conversation.md +++ b/docs/en/user_guides/single_turn_conversation.md @@ -1,9 +1,11 @@ # Single-turn Dialogue Data Pipeline -Single-turn dialogue instruction fine-tuning aims to enhance the model's ability to respond to specific instructions. Its data processing flow can be divided into the following two parts: +- [Using Dataset in HuggingFace Hub](#using-dataset-in-huggingface-hub) +- [Using Custom Datasets](#using-custom-datasets) + - [Using Alpaca Format Custom Datasets](#using-alpaca-format-custom-datasets) + - [Using Other Format Custom Datasets](#using-other-format-custom-datasets) -1. Construct data according to the corresponding dataset format -2. Insert dialogue templates into the dataset (optional) +Single-turn dialogue instruction fine-tuning aims to enhance the model's ability to respond to specific instructions. XTuner offers support for utilizing HuggingFace Hub datasets, Alpaca-Format custom datasets, or other format custom datasets for SFT (Supervised FineTune). The main differences between these options are as follows: @@ -36,6 +38,7 @@ The "Alpaca Train" dataset comprises 52,002 records, organized into four distinc [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -44,6 +47,7 @@ The "Alpaca Train" dataset comprises 52,002 records, organized into four distinc { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -55,23 +59,16 @@ Therefore, the original data can be mapped to a standard format using the follow ```python # Suppose the function is stored in ./map_fn.py -def alpaca_map_fn(example): - """ - >>> train_ds = ds['train'].map(alpaca_map_fn) - >>> train_ds - Dataset({ - features: ['instruction', 'input', 'output', 'text', 'conversation'], - num_rows: 52002 - }) - >>> train_ds[0]['conversation'] - [{'input': 'xxx', 'output': 'xxx'}] - """ - if example.get('output', '') == '': - return {'conversation': [{'input': '', 'output': ''}]} +SYSTEM_ALPACA = ('Below is an instruction that describes a task. ' + 'Write a response that appropriately completes the request.\n') +def custom_map_fn(example): + if example.get('output') == '': + return {'conversation': []} else: return { 'conversation': [{ - 'input': example['input'], + 'system': SYSTEM_ALPACA, + 'input': f"{example['instruction']}\n{example['input']}", 'output': example['output'] }] } @@ -101,32 +98,13 @@ For example, use the following command to export the config named `internlm_7b_q xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -### Step 4, Set Conversation Templates (Optional) - -Conversation templates refer to predefined patterns or structures used for generating dialogues. These templates may include questions, answers, or different roles' speeches in multi-turn dialogues. Adding conversation templates to the training dataset helps the model generate structured and logical dialogues and provide more accurate, consistent, and reasonable responses. - -Different datasets and language models may correspond to different conversation templates. For instance, the conversation template of the [alpaca dataset](https://huggingface.co/datasets/tatsu-lab/alpaca) is as follows: - -``` -Below is an instruction that describes a task. Write a response that appropriately completes the request. - -### Instruction: -xxx - -### Assistant: -xxx -``` - -XTuner provides a series of conversation templates, which you can find in `xtuner/utils/templates.py`. Among them, `INSTRUCTION_START` and `INSTRUCTION` represent the conversation templates used for the first round dialogue and subsequent rounds of dialogues, respectively. Only `INSTRUCTION_START` is used in a single-turn conversation dataset such as `alpaca`. - -### Step 5, Modify Config Files +### Step 4, Modify Config Files The config file copied in Step 3 needs to be modified as follows: -1. Import the map function `alpaca_map_fn` implemented in Step 1. -2. Replace `dataset_map_fn` in `train_dataset` with `alpaca_map_fn`. -3. (Optional) Set the conversation template corresponding to the `alpaca` dataset via `prompt_template = PROMPT_TEMPLATE.alpaca`. -4. Adjust the path of the original dataset. You can refer to the [user documentation](https://huggingface.co/docs/datasets/loading) for operations related to `load_dataset`. +1. Import the map function `custom_map_fn` implemented in Step 1. +2. Replace `dataset_map_fn` in `train_dataset` with `custom_map_fn`. +3. Adjust the path of the original dataset. You can refer to the [user documentation](https://huggingface.co/docs/datasets/loading) for operations related to `load_dataset`. ```diff from xtuner.dataset import process_hf_dataset @@ -135,15 +113,13 @@ from datasets import load_dataset + from xtuner.dataset.map_fns import template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import alpaca_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/data' - -+ prompt_template = PROMPT_TEMPLATE.alpaca ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -153,31 +129,25 @@ train_dataset = dict( dataset=dict(type=load_dataset, path=data_path), tokenizer=tokenizer, max_length=max_length, -+ dataset_map_fn=alpaca_map_fn, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), +- dataset_map_fn=alpaca_map_fn, ++ dataset_map_fn=custom_map_fn, + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, Log Processed Dataset (Optional) +### Step 5, Check custom Dataset (Optional) -After modifying the config file, you can print the first data of the processed dataset to verify whether the dataset has been constructed correctly. +After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` -`$CONFIG` represents the file path of the modified configuration file in Step 5. +`$CONFIG` represents the file path of the modified configuration file in Step 4. ## Using Custom Datasets @@ -205,11 +175,7 @@ As the custom dataset follows the Alpaca format, 'CONFIG_NAME' should select the xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -#### Step 3, Setting Dialogue Template (Optional) - -Refer to [Setting the Dialogue Template](#step-4-set-conversation-templates-optional). - -#### Step 4, Modify Config File +#### Step 3, Modify Config File The config copied in Step 2 needs to be modified as follows: @@ -222,10 +188,8 @@ from xtuner.utils import PROMPT_TEMPLATE ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/json/data' - -prompt_template = PROMPT_TEMPLATE.alpaca ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -243,19 +207,12 @@ train_dataset = dict( remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` ### Using Other Format Custom Datasets -### Step 1, Dataset Preparation +#### Step 1, Dataset Preparation Prepare your custom data according to the [single-turn dialogue data format](./dataset_format.md#single-turn-dialogue-dataset-format) defined by XTuner: @@ -263,6 +220,7 @@ Prepare your custom data according to the [single-turn dialogue data format](./d [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -271,6 +229,7 @@ Prepare your custom data according to the [single-turn dialogue data format](./d { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -278,7 +237,7 @@ Prepare your custom data according to the [single-turn dialogue data format](./d }] ``` -### Step 2, List Candidate Model Names +#### Step 2, List Candidate Model Names ```bash xtuner list-cfg -p internlm @@ -286,23 +245,18 @@ xtuner list-cfg -p internlm `-p` is for fuzzy search. If you want to train other models, you can replace `internlm` with other model names supported by XTuner. -### Step 3, Export the Config File +#### Step 3, Export the Config File ```bash xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -### Step 4, Setting Dialogue Template (Optional) - -Refer to [Setting the Dialogue Template](#step-4-set-conversation-templates-optional). - -### Step 5, Modify Config File +#### Step 4, Modify Config File The config file copied in Step 3 needs to be modified as follows: 1. Adjust the path of the original dataset -2. Since the dataset format is already in the standard format, set `dataset_map_fn` in `train_dataset` to None -3. Set the dialogue template +2. Since the dataset format is already in the standard format, set `dataset_map_fn` in `train_dataset` to `None` ```diff from xtuner.dataset import process_hf_dataset @@ -313,10 +267,9 @@ from datasets import load_dataset ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/json/data' - -+ prompt_template = PROMPT_TEMPLATE.alpaca +... ####################################################################### # STEP 3 Dataset & Dataloader # ####################################################################### @@ -327,23 +280,17 @@ train_dataset = dict( + type=load_dataset, path='json', data_files=dict(train=data_path)), tokenizer=tokenizer, max_length=max_length, +- dataset_map_fn=alpaca_map_fn, + dataset_map_fn=None, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, Check Processed Dataset (Optional) +#### Step 5, Check custom Dataset (Optional) After modifying the config file, you can execute the 'xtuner/tools/check_custom_dataset.py' script to verify the correct construction of the dataset. @@ -351,4 +298,4 @@ After modifying the config file, you can execute the 'xtuner/tools/check_custom_ xtuner check-custom-dataset $CONFIG ``` -`$CONFIG` represents the file path of the modified configuration file in Step 5. +`$CONFIG` represents the file path of the modified configuration file in Step 4. diff --git a/docs/zh_cn/user_guides/chat.md b/docs/zh_cn/user_guides/chat.md index 18cc0ba0f..930ca18c9 100644 --- a/docs/zh_cn/user_guides/chat.md +++ b/docs/zh_cn/user_guides/chat.md @@ -1,129 +1,3 @@ # 与微调后的大语言模型 LLMs 对话 -## 与微调后的 [InternLM](https://github.com/InternLM/InternLM) 对话 - -- InternLM-7B, oasst1 - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-oasst1 --prompt-template openassistant - ``` - -- InternLM-7B, Arxiv Gentitle - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-arxiv-gentitle --prompt-template title - ``` - -- InternLM-7B, Colorist - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-colorist --prompt-template colorist - ``` - -- InternLM-7B, Coder - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-coder --prompt-template code - ``` - -- InternLM-7B, SQL - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-sql --prompt-template sql - ``` - -- InternLM-7B, Lawyer - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-lawyer --prompt-template lawyer - ``` - -- InternLM-7B, Open-Platypus - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-open-platypus --prompt-template alpaca - ``` - -- InternLM-7B, Alpaca-enzh - - ```shell - xtuner chat internlm/internlm-7b --adapter xtuner/internlm-7b-qlora-alpaca-enzh --prompt-template alpaca - ``` - -## 与微调后的 [Llama2](https://github.com/facebookresearch/llama) 对话 - -> 在使用 Llama2 之前,请先使用 `huggingface-cli login` 输入你的访问令牌(access token)!点击[这里](https://huggingface.co/docs/hub/security-tokens#user-access-tokens)了解如何获取访问令牌。 - -- Llama2-7B, MOSS-003-SFT **(支持调用插件)** - - ```shell - export SERPER_API_KEY="xxx" # 请从 https://serper.dev 获得API_KEY,以此支持谷歌搜索! - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-moss-003-sft --bot-name Llama2 --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" --no-streamer - ``` - -- Llama2-7B, Arxiv Gentitle - - ```shell - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-arxiv-gentitle --prompt-template title - ``` - -- Llama2-7B, Colorist - - ```shell - xtuner chat meta-llama/Llama-2-7b-hf --adapter xtuner/Llama-2-7b-qlora-colorist --prompt-template colorist - ``` - -## 与微调后的 [Qwen](https://github.com/QwenLM) 对话 - -- Qwen-7B, MOSS-003-SFT **(支持调用插件)** - - ```shell - export SERPER_API_KEY="xxx" # 请从 https://serper.dev 获得API_KEY,以此支持谷歌搜索! - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-moss-003-sft --bot-name Qwen --prompt-template moss_sft --with-plugins calculate solve search --command-stop-word "" --answer-stop-word "" - ``` - -- Qwen-7B, oasst1 - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-oasst1 --prompt-template openassistant --answer-stop-word '<|endoftext|>' - ``` - -- Qwen-7B, Arxiv Gentitle - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-arxiv-gentitle --prompt-template title --answer-stop-word '<|endoftext|>' - ``` - -- Qwen-7B, Alpaca-enzh - - ```shell - xtuner chat Qwen/Qwen-7B --adapter xtuner/Qwen-7B-qlora-alpaca-enzh --prompt-template alpaca --answer-stop-word '<|endoftext|>' - ``` - -## 与微调后的 [Baichuan](https://github.com/baichuan-inc) 对话 - -- Baichuan-7B, oasst1 - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-oasst1 --prompt-template openassistant - ``` - -- Baichuan-7B, Arxiv Gentitle - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-arxiv-gentitle --prompt-template title --no-streamer - ``` - -- Baichuan-7B, Alpaca-enzh - - ```shell - xtuner chat baichuan-inc/Baichuan-7B --adapter xtuner/Baichuan-7B-qlora-alpaca-enzh --prompt-template alpaca - ``` - - ## 与 [CodeLlama](https://github.com/facebookresearch/codellama) 对话 - -- CodeLlama-7B, Instruct - - ```shell - xtuner chat codellama/CodeLlama-7b-Instruct-hf --prompt-template code_llama_chat - ``` +敬请期待。 diff --git a/docs/zh_cn/user_guides/dataset_format.md b/docs/zh_cn/user_guides/dataset_format.md index a471fcd2a..356824196 100644 --- a/docs/zh_cn/user_guides/dataset_format.md +++ b/docs/zh_cn/user_guides/dataset_format.md @@ -1,11 +1,18 @@ # 数据集格式 +- [增量预训练数据集格式](#增量预训练数据集格式) +- [单轮对话数据集格式](#单轮对话数据集格式) +- [多轮对话数据集格式](#多轮对话数据集格式) + - [方法 1](#方法-1) + - [方法 2](#方法-2) + - [XTuner 方法介绍](#xtuner-方法介绍) + 大语言模型 Supervised Finetune(SFT)旨在通过有监督的微调来提高预训练模型在特定任务上的性能。为支持尽可能多的下游任务,XTuner 支持了增量预训练、单轮对话、多轮对话三种数据集格式。 - 增量预训练数据集用于提升模型在特定领域或任务的能力。 - 单轮对话和多轮对话数据集则经常用于指令微调(instruction tuning)阶段,以提升模型回复特定指令的能力。 -在指令微调阶段,我们的目标是训练语言模型根据人类指令给出回答。 **因此,一般只有回答部分(Output)的 loss 会用于梯度回传,而指令部分(Input)部分的 loss 则不会用于权重更新。** 基于此,我们在对数据集进行预处理的时候引入了 "input" 和 "output" 两个字段,"input" 字段用于保存不需要计算 loss 的字段,例如用户指令,而 "output" 字段则用于保存需要计算 loss 的字段,例如输入指令对应的 GroundTruth 回答。 +在指令微调阶段,我们的目标是训练语言模型根据人类指令给出回答。 **因此,一般只有回答部分(Output)的 loss 会用于梯度回传,而指令部分(System、Input)部分的 loss 则不会用于权重更新。** 基于此,我们在对数据集进行预处理的时候引入了 "system"、"input" 和 "output" 三个字段,"system"、"input" 字段用于保存不需要计算 loss 的文本,例如系统或用户指令,而 "output" 字段则用于保存需要计算 loss 的文本,例如输入指令对应的 GroundTruth 回答。 为了统一增量预训练、单轮对话和多轮对话三种数据集格式,我们将数据集格式设置为以下形式: @@ -13,6 +20,7 @@ [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -21,6 +29,7 @@ { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -32,22 +41,23 @@ }] ``` -在训练过程中,我们会将一条数据中的多组 "input" 和 "output" 进行拼接,之后输入模型,并行计算每个位置的 loss ,但只有 "output" 部分对应的 loss 参与梯度回传,如下图所示。 +在训练过程中,我们会将一条数据中的多组 "system"、"input" 和 "output" 进行拼接,之后输入模型,并行计算每个位置的 loss ,但只有 "output" 部分对应的 loss 参与梯度回传,如下图所示。
-Image +Image
其中 \ token 和 \ token 用于表示句子或文本的开始和结束。 ## 增量预训练数据集格式 -由于增量预训练旨在帮助模型学习针对特定下游任务的语言知识和表达能力,因此数据集的全部内容对应的loss都应该用于梯度回传。因此,数据集的 "input" 为空,而 "output" 为一整条语料数据。增量预训练任务对应的数据集格式如下所示: +由于增量预训练旨在帮助模型学习针对特定下游任务的语言知识和表达能力,因此数据集的全部内容对应的 loss 都应该用于梯度回传。因此,数据集的 "system"、"input" 为空,而 "output" 为一整条语料数据。增量预训练任务对应的数据集格式如下所示: ```json [{ "conversation":[ { + "system": "", "input": "", "output": "I am an artificial intelligence (AI) assistant named Puyu. I was created by the Shanghai AI Laboratory and my purpose is to assist users with various tasks through natural language processing technology." } @@ -56,6 +66,7 @@ { "conversation":[ { + "system": "", "input": "", "output": "I am an artificial intelligence programmed to assist with various types of tasks, including answering questions, providing information, and performing automated processes." } @@ -69,39 +80,40 @@ ## 单轮对话数据集格式 -单轮对话数据集往往由一条指令(或问题)及其对应 GroundTruth 回答组成。由于只有回答部分需要对 loss 进行回传,因此数据集的 "input" 字段为输入指令,"output" 字段为对应回答。单轮对话数据集格式如下所示: +单轮对话数据集往往由一条指令(或问题)及其对应 GroundTruth 回答组成。由于只有回答部分需要对 loss 进行回传,因此数据集的 "system"、"input" 字段为输入指令,"output" 字段为对应回答。单轮对话数据集格式如下所示: ```json [{ - "conversation": - [ - { - "input": "Give three tips for staying healthy.", - "output": "1.Eat a balanced diet. 2. Exercise regularly. 3. Get enough sleep." - } - ] + "conversation":[ + { + "system": "You are an AI asssistant." + "input": "Give three tips for staying healthy.", + "output": "1.Eat a balanced diet. 2. Exercise regularly. 3. Get enough sleep." + } + ] }, { - "conversation": - [ - { - "input": "How to study English?", - "output": "1. Set clear goals. 2. Create a study plan. 3. Build vocabulary. 4. Practice speaking." - } - ] + "conversation":[ + { + "system": "You are an AI asssistant." + "input": "How to study English?", + "output": "1. Set clear goals. 2. Create a study plan. 3. Build vocabulary. 4. Practice speaking." + } + ] }] ```
-Image +Image
## 多轮对话数据集格式 多轮对话数据集往往由多轮指令(或问题)+ 对应 GroundTruth 回答组成。假设我们现在有一条多轮对话数据,内容如下。 -为方便介绍,对于第 n 轮对话,我们将 User 和 Assistant 对应的输出设为 Usern 和 Assistantn。 +为方便介绍,对于第 n 轮对话,我们将 User 和 Assistant 对应的输出设为 UserN 和 AssistantN。 ```text +System: You are an AI asssistant. User1:Hello? Assistant1:Hello! How can I help you? User2:What's the date today? @@ -114,10 +126,10 @@ Assistant3:You are welcome. ### 方法 1 -User1、Assistant1、User2、Assistant2、User3的文本都视为模型的输入部分,将 Assistant3 的文本视为模型的预测部分,只有 Assistant3 部分的 loss 参与权重更新。 +System、User1、Assistant1、User2、Assistant2、User3的文本都视为模型的输入部分,将 Assistant3 的文本视为模型的预测部分,只有 Assistant3 部分的 loss 参与权重更新。
-Image +Image
这种方法的弊端在于没有充分利用多轮对话的训练数据,因为 Assistant1 和 Assistant2 的内容没有参与模型训练,导致训练数据利用率较低。 @@ -127,7 +139,7 @@ User1、Assistant1、User2、Assistant2、User3的文本都视为模型的输入 将一条多轮对话数据,拆分成多条数据。例如将以上示例拆分成如下三条数据。
-Image +Image
相比于方法1,方法2可以充分利用每一轮对话的数据,但需要将一条包含 n 轮对话的数据拆分为 n 条数据, @@ -138,7 +150,7 @@ User1、Assistant1、User2、Assistant2、User3的文本都视为模型的输入 XTuner 训练多轮对话模型时,采取了一种更加充分高效的方法,如下图所示。
-Image +Image
我们将多轮对话进行拼接,之后输入模型,并行计算每个位置的 loss,而只有 Output 部分的 loss 参与回传。因此 XTuner 中多轮对话数据集格式如下所示: @@ -147,6 +159,7 @@ XTuner 训练多轮对话模型时,采取了一种更加充分高效的方法 [{ "conversation":[ { + "system": "You are an AI asssistant." "input": "Hello?", "output": "Hello! How can I help you?" }, @@ -163,6 +176,7 @@ XTuner 训练多轮对话模型时,采取了一种更加充分高效的方法 { "conversation":[ { + "system": "You are an AI asssistant." "input": "Hello?", "output": "Hello! How can I help you?" }, diff --git a/docs/zh_cn/user_guides/dataset_prepare.md b/docs/zh_cn/user_guides/dataset_prepare.md index 7009e0b10..cfad38927 100644 --- a/docs/zh_cn/user_guides/dataset_prepare.md +++ b/docs/zh_cn/user_guides/dataset_prepare.md @@ -1,5 +1,11 @@ # 数据集准备 +- [HuggingFace 数据集](#huggingface-数据集) +- [其他](#其他) + - [Arxiv Gentitle 生成题目](#arxiv-gentitle-生成题目) + - [MOSS-003-SFT](#moss-003-sft) + - [Chinese Lawyer](#chinese-lawyer) + ## HuggingFace 数据集 针对 HuggingFace Hub 中的数据集,比如 [alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca),用户可以快速使用它们。更多使用指南请参照[单轮对话文档](./single_turn_conversation.md)和[多轮对话文档](./multi_turn_conversation.md)。 diff --git a/docs/zh_cn/user_guides/incremental_pretraining.md b/docs/zh_cn/user_guides/incremental_pretraining.md index 852d35915..6be76fdd7 100644 --- a/docs/zh_cn/user_guides/incremental_pretraining.md +++ b/docs/zh_cn/user_guides/incremental_pretraining.md @@ -1,14 +1,15 @@ # 增量预训练 data pipeline -增量预训练旨在提升模型在特定领域或任务的能力。 +- [使用 HuggingFace Hub 数据集](#使用-huggingface-hub-数据集) +- [使用自定义数据集](#使用自定义数据集) -## 数据集构建 +增量预训练旨在提升模型在特定领域或任务的能力。 XTuner 支持使用 HuggingFace Hub 数据集或自定义数据集进行 SFT(Supervised FineTune)。二者的主要区别在于,使用 HuggingFace Hub 数据集时需要将原始数据映射为 XTuner 定义的[增量预训练数据格式](./dataset_format.md#增量预训练数据集格式)。而对于自定义数据集则推荐用户按照[增量预训练数据格式](./dataset_format.md#增量预训练数据集格式)构造数据集。 -### 使用 HuggingFace Hub 数据集 +## 使用 HuggingFace Hub 数据集 -#### Step 1, 映射原始数据集为标准格式 +### Step 1, 映射原始数据集为标准格式 由于不同数据集的格式各有不同,因此需要将原始数据映射为 XTuner 定义的[增量预训练数据格式](./dataset_format.md#增量预训练数据集格式)。XTuner 支持通过 map function 来实现格式的映射。下面以 [oasst1](https://huggingface.co/datasets/OpenAssistant/oasst1) 数据集为例介绍如何实现数据映射。 @@ -42,7 +43,7 @@ Dataset({ ```python # 假设将该函数存放在./map_fn.py文件中 -def oasst1_incremental_map_fn(example): +def custom_map_fn(example): """ >>> train_ds = ds['train'].map(oasst1_map_fn) >>> train_ds @@ -57,7 +58,7 @@ def oasst1_incremental_map_fn(example): ``` -#### Step 2, 列出候选模型名字 +### Step 2, 列出候选模型名字 XTuner 提供多个开箱即用的配置文件,用户可以通过下列命令查看: @@ -67,7 +68,7 @@ xtuner list-cfg -p internlm `-p`为模糊查找,若想训练其他模型,可以修改`internlm`为 XTuner 支持的其他模型名称。 -#### Step 3, 导出 config 文件 +### Step 3, 导出 config 文件 如果所提供的配置文件不能满足使用需求,请导出所提供的配置文件并进行相应更改: @@ -81,15 +82,15 @@ xtuner copy-cfg ${CONFIG_NAME} ${SAVE_DIR} xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -#### Step 4, 修改 config 文件 +### Step 4, 修改 config 文件 对 Step 3 复制得到的 config 文件需要进行如下修改: -1. 导入 Step 1 中实现的映射函数 `oasst1_incremental_map_fn` -2. 使用 `oasst1_incremental_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` +1. 导入 Step 1 中实现的映射函数 `custom_map_fn` +2. 使用 `custom_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` 3. 将 `train_dataset` 中的 `template_map_fn` 置为None(因为无需将对话模板加入至增量预训练数据集中) 4. 调整原始数据集的路径,关于 `load_dataset` 的相关操作可以参考[用户文档](https://huggingface.co/docs/datasets/loading) -5. (可选)如果你希望利用 XTuner 提供的 `EvaluateChatHook` 在训练中查看模型的生成结果,你还需要关闭 `prompt_template` 以去除对话模版。(注意:由于增量预训练时的模型只具备续写功能,不具备对话功能,因此在 `EvaluateChatHook`打印的对话结果中,模型可能会无法正常停止生成。) +5. 关闭 `EvaluateChatHook`。由于增量预训练时的模型只具备续写功能,不具备对话功能,如果开启 `EvaluateChatHook`打印对话结果的话,模型会无法正常停止生成。 ```diff from xtuner.dataset import process_hf_dataset @@ -97,13 +98,13 @@ from datasets import load_dataset - from xtuner.dataset.map_fns import oasst1_map_fn, template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import oasst1_incremental_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' -- prompt_template = PROMPT_TEMPLATE.openassistant +- prompt_template = PROMPT_TEMPLATE.internlm_chat + data_path = 'path/to/your/data' ####################################################################### # STEP 3 Dataset & Dataloader # @@ -114,20 +115,13 @@ train_dataset = dict( tokenizer=tokenizer, max_length=max_length, - dataset_map_fn=oasst1_map_fn, -+ dataset_map_fn=oasst1_incremental_map_fn, ++ dataset_map_fn=custom_map_fn, - template_map_fn=dict( - type=template_map_fn_factory, template=prompt_template), + template_map_fn=None, remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ####################################################################### # PART 5 Runtime # @@ -135,32 +129,32 @@ train_dataloader = dict( # Log the dialogue periodically during the training process, optional custom_hooks = [ dict(type=DatasetInfoHook, tokenizer=tokenizer), - dict( - type=EvaluateChatHook, - tokenizer=tokenizer, - every_n_iters=evaluation_freq, - evaluation_inputs=evaluation_inputs, -- instruction=prompt_template.INSTRUCTION_START) -+ ) +- dict( +- type=EvaluateChatHook, +- tokenizer=tokenizer, +- every_n_iters=evaluation_freq, +- evaluation_inputs=evaluation_inputs, +- system=SYSTEM, +- instruction=prompt_template.INSTRUCTION) ] ... ``` -#### Step 5, 打印数据集(可选) +### Step 5, 检查数据集(可选) -在修改配置文件后,可以打印处理后数据集的第一条数据,以验证数据集是否正确构建。 +在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` 其中 `$CONFIG` 是 Step 4 修改过的 config 的文件路径。 -### 使用自定义数据集 +## 使用自定义数据集 在使用自定义数据集进行增量预训练时,我们推荐将数据集构造为 XTuner 定义的[增量预训练数据格式](./dataset_format.md#增量预训练数据集格式)。若自定义数据集格式为 `oasst1` 等其他格式,可参考[使用HuggingFace Hub数据集](#使用huggingface-hub数据集)一节。 -#### Step 1, 数据准备 +### Step 1, 数据准备 按照 XTuner 定义的[增量预训练数据格式](./dataset_format.md#增量预训练数据集格式)准备自定义数据: @@ -185,28 +179,28 @@ xtuner log-dataset $CONFIG ] ``` -#### Step 2, 列出候选模型名字 +### Step 2, 列出候选模型名字 ```bash xtuner list-cfg -p internlm ``` -`-p`为模糊查找,若想训练其他模型,可以修改 `internlm` 为 XTuner 支持的其他模型名称。 +`-p` 为模糊查找,若想训练其他模型,可以修改 `internlm` 为 XTuner 支持的其他模型名称。 -#### Step 3, 复制 config 文件 +### Step 3, 复制 config 文件 ```bash xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -#### Step 4, 修改 config 文件 +### Step 4, 修改 config 文件 对 Step 3 复制得到的 config 文件需要进行如下修改: 1. 调整原始数据集的路径 -2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为None -3. 将 `train_dataset` 中的 `template_map_fn` 置为None,因为不需要将对话模板加入至增量预训练数据集中 -4. (可选)设置对话模板以调用 `EvaluateChatHook` 在训练的各个阶段记录模型的对话结果 +2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为 `None` +3. 将 `train_dataset` 中的 `template_map_fn` 置为 `None`,因为不需要将对话模板加入至增量预训练数据集中 +4. 关闭 `EvaluateChatHook`。由于增量预训练时的模型只具备续写功能,不具备对话功能,如果开启 `EvaluateChatHook`打印对话结果的话,模型会无法正常停止生成。 ```diff from xtuner.dataset import process_hf_dataset @@ -238,13 +232,6 @@ train_dataset = dict( remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ####################################################################### # PART 5 Runtime # @@ -252,18 +239,18 @@ train_dataloader = dict( # Log the dialogue periodically during the training process, optional custom_hooks = [ dict(type=DatasetInfoHook, tokenizer=tokenizer), - dict( - type=EvaluateChatHook, - tokenizer=tokenizer, - every_n_iters=evaluation_freq, - evaluation_inputs=evaluation_inputs, -- instruction=prompt_template.INSTRUCTION_START) -+ ) +- dict( +- type=EvaluateChatHook, +- tokenizer=tokenizer, +- every_n_iters=evaluation_freq, +- evaluation_inputs=evaluation_inputs, +- system=SYSTEM, +- instruction=prompt_template.INSTRUCTION) ] ... ``` -#### Step 5, 检查数据集(可选) +### Step 5, 检查数据集(可选) 在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 diff --git a/docs/zh_cn/user_guides/multi_turn_conversation.md b/docs/zh_cn/user_guides/multi_turn_conversation.md index b52dd5ea8..cec40aa93 100644 --- a/docs/zh_cn/user_guides/multi_turn_conversation.md +++ b/docs/zh_cn/user_guides/multi_turn_conversation.md @@ -1,9 +1,9 @@ # 多轮对话 data pipeline -多轮对话指令微调旨在提升模型的多轮对话能力,其数据处理流程可以分为以下两部分: +- [使用 HuggingFace Hub 数据集](#使用-huggingface-hub-数据集) +- [使用自定义数据集](#使用自定义数据集) -1. 按照相应数据集格式构造数据 -2. 向数据集中插入对话模板(可选) +多轮对话指令微调旨在提升模型的多轮对话能力,在数据处理阶段需要将原始数据转换为XTuner支持的数据集格式。 XTuner 支持使用 HuggingFace Hub 数据集或自定义数据集进行 SFT(Supervised FineTune)。二者的主要区别在于,使用 HuggingFace Hub 数据集时需要将原始数据映射为 XTuner 定义的[多轮对话数据格式](./dataset_format.md#多轮对话数据集格式),而对于自定义数据集则推荐用户按照[多轮对话数据格式](./dataset_format.md#多轮对话数据集格式)构造数据集。 @@ -34,6 +34,7 @@ Dataset({ [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -46,6 +47,7 @@ Dataset({ { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -61,7 +63,8 @@ Dataset({ ```python # 假设将该函数存放在./map_fn.py文件中 -def oasst1_multi_turns_map_fn(example): +SYSTEM_OASST1 = '' # oasst1 并未使用 system 字段 +def custom_map_fn(example): r""" Example before preprocessing: example['text'] = '### Human: Can you explain xxx' @@ -96,7 +99,11 @@ def oasst1_multi_turns_map_fn(example): data.pop() conversation = [] for i in range(0, len(data), 2): - single_turn_conversation = {'input': data[i], 'output': data[i + 1]} + system = SYSTEM_OASST1 if i == 0 else '' + single_turn_conversation = { + 'system': system, + 'input': data[i], + 'output': data[i + 1]} conversation.append(single_turn_conversation) return {'conversation': conversation} ``` @@ -125,30 +132,13 @@ xtuner copy-cfg ${CONFIG_NAME} ${SAVE_DIR} xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -### Step 4, 设置对话模板(可选) - -对话模板是指用于生成对话的预定义模式或结构。这些模板可以包含问句、回答或多轮对话中的不同角色的发言。在训练数据集中加入对话模板有利于模型生成有结构和逻辑的对话,并提供更准确、一致和合理的回答。 - -不同数据集、不同语言模型可能对应着不同的对话模板。例如,[oasst1](https://huggingface.co/datasets/OpenAssistant/oasst1) 数据集的对话模板如下: - -``` -### Human: -xxx - -### Assistant: -xxx -``` - -XTuner提供了一系列对话模板,你可以在 `xtuner/utils/templates.py` 中找到。其中,`INSTRUCTION_START` 和 `INSTRUCTION` 分别代表第一轮对话和后续若干轮对话所使用的对话模板。 - -### Step 5, 修改 config 文件 +### Step 4, 修改 config 文件 对 Step 3 复制得到的 config 文件需要进行如下修改: -1. 导入 Step 1 中实现的 map function `oasst1_multi_turns_map_fn` -2. 用 `oasst1_multi_turns_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` -3. (可选)通过 `prompt_template = PROMPT_TEMPLATE.openassistant` 来设置 `oasst1` 数据集对应的对话模板。 -4. 调整原始数据集的路径,关于 `load_dataset` 的相关操作可以参考[用户文档](https://huggingface.co/docs/datasets/loading) +1. 导入 Step 1 中实现的映射函数 `custom_map_fn` +2. 用 `custom_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` +3. 调整原始数据集的路径,关于 `load_dataset` 的相关操作可以参考[用户文档](https://huggingface.co/docs/datasets/loading) ```diff from xtuner.dataset import process_hf_dataset @@ -157,15 +147,13 @@ from datasets import load_dataset + from xtuner.dataset.map_fns import template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import oasst1_multi_turns_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' + data_path = 'path/to/your/data' - -+ prompt_template = PROMPT_TEMPLATE.openassistant ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -175,31 +163,25 @@ train_dataset = dict( dataset=dict(type=load_dataset, path=data_path), tokenizer=tokenizer, max_length=max_length, -+ dataset_map_fn=oasst1_multi_turns_map_fn, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), +- dataset_map_fn=oasst1_map_fn, ++ dataset_map_fn=custom_map_fn, + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, 打印数据集(可选) +### Step 5, 检查数据集(可选) -在修改配置文件后,可以打印处理后数据集的第一条数据,以验证数据集是否正确构建。 +在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` -其中 `$CONFIG` 是 Step 5 修改过的 config 的文件路径。 +其中 `$CONFIG` 是 Step 4 修改过的 config 的文件路径。 ## 使用自定义数据集 @@ -213,6 +195,7 @@ xtuner log-dataset $CONFIG [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -225,6 +208,7 @@ xtuner log-dataset $CONFIG { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" }, @@ -250,17 +234,12 @@ xtuner list-cfg -p internlm xtuner copy-cfg internlm_7b_qlora_oasst1_e3 . ``` -### Step 4, 设置对话模板(可选) - -参考[设置对话模板](#step-4-设置对话模板可选) - -### Step 5, 修改 config 文件 +### Step 4, 修改 config 文件 对 Step 3 复制得到的 config 文件需要进行如下修改: 1. 调整原始数据集的路径 -2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为 None -3. 设置对话模板 +2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为 `None` ```diff from xtuner.dataset import process_hf_dataset @@ -273,8 +252,6 @@ from datasets import load_dataset ####################################################################### - data_path = 'timdettmers/openassistant-guanaco' + data_path = 'path/to/your/json/data' - -+ prompt_template = PROMPT_TEMPLATE.openassistant ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -286,23 +263,17 @@ train_dataset = dict( + type=load_dataset, path='json', data_files=dict(train=data_path)), tokenizer=tokenizer, max_length=max_length, +- dataset_map_fn=oasst1_map_fn, + dataset_map_fn=None, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, 检查数据集(可选) +### Step 5, 检查数据集(可选) 在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 @@ -310,4 +281,4 @@ train_dataloader = dict( xtuner check-custom-dataset $CONFIG ``` -其中 `$CONFIG` 是 Step 5 修改过的 config 的文件路径。 +其中 `$CONFIG` 是 Step 4 修改过的 config 的文件路径。 diff --git a/docs/zh_cn/user_guides/single_turn_conversation.md b/docs/zh_cn/user_guides/single_turn_conversation.md index e7c9ff958..dd0e52905 100644 --- a/docs/zh_cn/user_guides/single_turn_conversation.md +++ b/docs/zh_cn/user_guides/single_turn_conversation.md @@ -1,9 +1,11 @@ # 单轮对话 data pipeline -单轮对话指令微调旨在提升模型回复特定指令的能力,其数据处理流程可以分为以下两部分: +- [使用 HuggingFace Hub 数据集](#使用-huggingface-hub-数据集) +- [使用自定义数据集](#使用自定义数据集) + - [使用 Alpaca 格式的自定义数据集](#使用-alpaca-格式的自定义数据集) + - [使用其他格式自定义数据集](#使用其他格式自定义数据集) -1. 按照相应数据集格式构造数据 -2. 向数据集中插入对话模板(可选) +单轮对话指令微调旨在提升模型回复特定指令的能力,在数据处理阶段需要将原始数据转换为XTuner支持的数据集格式。 XTuner 支持使用 HuggingFace Hub 数据集、Alpaca 格式的自定义数据集以及其他格式的自定义数据集进行 SFT(Supervised FineTune)。三者的主要区别在于: @@ -36,6 +38,7 @@ Dataset({ [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -44,6 +47,7 @@ Dataset({ { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -55,23 +59,16 @@ Dataset({ ```python # 假设将该函数存放在./map_fn.py文件中 -def alpaca_map_fn(example): - """ - >>> train_ds = ds['train'].map(alpaca_map_fn) - >>> train_ds - Dataset({ - features: ['instruction', 'input', 'output', 'text', 'conversation'], - num_rows: 52002 - }) - >>> train_ds[0]['conversation'] - [{'input': 'xxx', 'output': 'xxx'}] - """ - if example.get('output', '') == '': - return {'conversation': [{'input': '', 'output': ''}]} +SYSTEM_ALPACA = ('Below is an instruction that describes a task. ' + 'Write a response that appropriately completes the request.\n') +def custom_map_fn(example): + if example.get('output') == '': + return {'conversation': []} else: return { 'conversation': [{ - 'input': example['input'], + 'system': SYSTEM_ALPACA, + 'input': f"{example['instruction']}\n{example['input']}", 'output': example['output'] }] } @@ -101,32 +98,13 @@ xtuner copy-cfg ${CONFIG_NAME} ${SAVE_DIR} xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -### Step 4 设置对话模板(可选) +### Step 4, 修改 config 文件 -对话模板是指用于生成对话的预定义模式或结构。这些模板可以包含问句、回答或多轮对话中的不同角色的发言。在训练数据集中加入对话模板有利于模型生成有结构和逻辑的对话,并提供更准确、一致和合理的回答。 - -不同数据集、不同语言模型可能对应着不同的对话模板。例如,[alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca) 数据集的对话模板如下: - -``` -Below is an instruction that describes a task. Write a response that appropriately completes the request. - -### Instruction: -xxx - -### Assistant: -xxx -``` - -XTuner提供了一系列对话模板,你可以在 `xtuner/utils/templates.py` 中找到。其中,`INSTRUCTION_START` 和 `INSTRUCTION` 分别代表第一轮对话和后续若干轮对话所使用的对话模板。在单轮对话数据集(如 `alpaca`)中只会用到 `INSTRUCTION_START`。 - -### Step 5, 修改 config 文件 - -对Step 3 复制得到的 config 文件需要进行如下修改: +对 Step 3 复制得到的 config 文件需要进行如下修改: -1. 导入 Step 1 中实现的映射函数 `alpaca_map_fn` -2. 用 `alpaca_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` -3. (可选)通过 `prompt_template = PROMPT_TEMPLATE.alpaca` 来设置 `alpaca` 数据集对应的对话模板。 -4. 调整原始数据集的路径,关于 `load_dataset` 的相关操作可以参考[用户文档](https://huggingface.co/docs/datasets/loading) +1. 导入 Step 1 中实现的映射函数 `custom_map_fn` +2. 用 `custom_map_fn` 替换 `train_dataset` 中的 `dataset_map_fn` +3. 调整原始数据集的路径,关于 `load_dataset` 的相关操作可以参考[用户文档](https://huggingface.co/docs/datasets/loading) ```diff from xtuner.dataset import process_hf_dataset @@ -135,15 +113,13 @@ from datasets import load_dataset + from xtuner.dataset.map_fns import template_map_fn_factory + from mmengine.config import read_base + with read_base(): -+ from .map_fn import alpaca_map_fn ++ from .map_fn import custom_map_fn ... ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/data' - -+ prompt_template = PROMPT_TEMPLATE.alpaca ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -153,35 +129,29 @@ train_dataset = dict( dataset=dict(type=load_dataset, path=data_path), tokenizer=tokenizer, max_length=max_length, -+ dataset_map_fn=alpaca_map_fn, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), +- dataset_map_fn=alpaca_map_fn, ++ dataset_map_fn=custom_map_fn, + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, 打印数据集(可选) +### Step 5, 检查数据集(可选) -在修改配置文件后,可以打印处理后数据集的第一条数据,以验证数据集是否正确构建。 +在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 ```bash -xtuner log-dataset $CONFIG +xtuner check-custom-dataset $CONFIG ``` -其中 `$CONFIG` 是 Step 5 修改过的 config 的文件路径。 +其中 `$CONFIG` 是 Step 4 修改过的 config 的文件路径。 ## 使用自定义数据集 -### 使用 Alpaca 格式自定义数据集 +### 使用 Alpaca 格式的自定义数据集 若自定义数据集的数据格式满足`alpaca`格式,可以参考以下步骤进行 SFT 训练。 @@ -207,13 +177,9 @@ xtuner copy-cfg ${CONFIG_NAME} ${SAVE_DIR} xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -#### Step 3, 设置对话模板(可选) - -参考[设置对话模板](#step-4-设置对话模板可选) - -#### Step 4, 修改 config 文件 +#### Step 3, 修改 config 文件 -对 Step 3 复制得到的 config 文件需要进行如下修改: +对 Step 2 复制得到的 config 文件需要进行如下修改: ```diff from xtuner.dataset import process_hf_dataset @@ -224,10 +190,8 @@ from xtuner.utils import PROMPT_TEMPLATE ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/json/data' - -prompt_template = PROMPT_TEMPLATE.alpaca ... ####################################################################### # STEP 3 Dataset & Dataloader # @@ -245,13 +209,6 @@ train_dataset = dict( remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` @@ -265,6 +222,7 @@ train_dataloader = dict( [{ "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -273,6 +231,7 @@ train_dataloader = dict( { "conversation":[ { + "system": "xxx", "input": "xxx", "output": "xxx" } @@ -294,17 +253,12 @@ xtuner list-cfg -p internlm xtuner copy-cfg internlm_7b_qlora_alpaca_e3 . ``` -#### Step 4, 设置对话模板(可选) - -参考[设置对话模板](#step-4-设置对话模板可选) - -#### Step 5, 修改 config 文件 +#### Step 4, 修改 config 文件 对 Step 3 复制得到的 config 文件需要进行如下修改: 1. 调整原始数据集的路径 -2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为 None -3. 设置对话模板 +2. 由于数据集格式已经是标准格式了,需要将 `train_dataset` 中的 `dataset_map_fn` 置为 `None` ```diff from xtuner.dataset import process_hf_dataset @@ -315,10 +269,9 @@ from datasets import load_dataset ####################################################################### # PART 1 Settings # ####################################################################### -- alpaca_en_path = 'tatsu-lab/alpaca' +- data_path = 'tatsu-lab/alpaca' + data_path = 'path/to/your/json/data' - -+ prompt_template = PROMPT_TEMPLATE.alpaca +... ####################################################################### # STEP 3 Dataset & Dataloader # ####################################################################### @@ -329,23 +282,17 @@ train_dataset = dict( + type=load_dataset, path='json', data_files=dict(train=data_path)), tokenizer=tokenizer, max_length=max_length, +- dataset_map_fn=alpaca_map_fn, + dataset_map_fn=None, -+ template_map_fn=dict( -+ type=template_map_fn_factory, template=prompt_template), + template_map_fn=dict( + type=template_map_fn_factory, template=prompt_template), remove_unused_columns=True, shuffle_before_pack=True, pack_to_max_length=pack_to_max_length) - -train_dataloader = dict( - batch_size=batch_size, - num_workers=dataloader_num_workers, - dataset=train_dataset, - sampler=dict(type=DefaultSampler, shuffle=True), - collate_fn=dict(type=default_collate_fn)) ... ``` -#### Step 6, 检查数据集(可选) +#### Step 5, 检查数据集(可选) 在修改配置文件后,可以运行`xtuner/tools/check_custom_dataset.py`脚本验证数据集是否正确构建。 @@ -353,4 +300,4 @@ train_dataloader = dict( xtuner check-custom-dataset $CONFIG ``` -其中 `$CONFIG` 是 Step 5 修改过的 config 的文件路径。 +其中 `$CONFIG` 是 Step 4 修改过的 config 的文件路径。 diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_e3.py index 6e657c2ce..dafe3b712 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_e3.py index 738bdb411..91288d451 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_oasst1_e3.py index a716ab5c6..b135ba146 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_zh_e3.py index be10bbdbb..5bb43fbed 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_arxiv_gentitle_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_arxiv_gentitle_e3.py index 587088594..5555f886b 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_code_alpaca_e3.py index 1b01ddd23..b15b8adea 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_colorist_e5.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_colorist_e5.py index ff015a263..e4a5f2756 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_colorist_e5.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_lawyer_e3.py index 7c5da43da..3653b7d52 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_512_e3.py index eb604b8e9..04bb84093 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_e3.py index 71537289d..46ffdce06 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_open_platypus_e3.py index 9a9bfa90d..146265982 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_sql_e3.py b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_sql_e3.py index f4b51853c..098538a2e 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_sql_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_base/baichuan2_13b_base_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_e3.py index 48f676012..d929474de 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_e3.py index d8e3eb546..f8b3e8382 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_oasst1_e3.py index c4f9d7470..978622883 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_zh_e3.py index 84560a36f..d1524b3ea 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_code_alpaca_e3.py index 17f863450..0c03e961a 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_lawyer_e3.py index ea3d6996c..370ffcbb0 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_512_e3.py index 97bb8993c..8f1d4fa6b 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_e3.py index b7ad395c4..cec58460d 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_open_platypus_e3.py index 5d15e186a..a19e01060 100644 --- a/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan2_13b_chat/baichuan2_13b_chat_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_e3.py index 3500806e3..448d4672e 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_e3.py index 2ec4464d3..5dd4c5cee 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_oasst1_e3.py index e18bf308b..fb58077e6 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_zh_e3.py index 988f75b90..d79190ec0 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_arxiv_gentitle_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_arxiv_gentitle_e3.py index 1e1ad6924..0aca5928c 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_code_alpaca_e3.py index 8c1d31968..336e9a078 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_colorist_e5.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_colorist_e5.py index 11075ad8b..fae416f7e 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_colorist_e5.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_lawyer_e3.py index 589747804..f317e5b61 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_512_e3.py index 2efef99c4..ccbf3b1c3 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_e3.py index f1458f2b6..ccc5e6add 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_open_platypus_e3.py index 7a9471bbd..fc9ab40e9 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_sql_e3.py b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_sql_e3.py index 24862b83d..8f9ac534f 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_sql_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_base/baichuan2_7b_base_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.baichuan2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_e3.py index 4c6e309e3..6f5c90e00 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_e3.py index cac420819..8e5304687 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py index 16cb2396c..d5f03a788 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_zh_e3.py index 1e91bb7f3..8e59d94a7 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_code_alpaca_e3.py index 8d29890df..676c2bfa0 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_lawyer_e3.py index 387aa9d79..c43ce574b 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_512_e3.py index aafc7a093..4306d7a57 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_e3.py index bbde74682..03b37a54d 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_open_platypus_e3.py index a7483b9da..589a31e17 100644 --- a/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan2_7b_chat/baichuan2_7b_chat_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_e3.py index cf37b932b..3ec1e4d97 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_e3.py index ea29101a5..04dd26a65 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_oasst1_e3.py index 51f358936..195b0d4a0 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_zh_e3.py index ad4c4116e..afc3ccdb9 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_arxiv_gentitle_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_arxiv_gentitle_e3.py index ef55c81e3..cdb340186 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_code_alpaca_e3.py index 8d6c223a5..83a5db2e7 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_colorist_e5.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_colorist_e5.py index 8cbb042c6..fb133b242 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_colorist_e5.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_lawyer_e3.py index 08c958f1f..ee4d32ba1 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_medical_e1.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_medical_e1.py index d3eb2011c..612896678 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_medical_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e1.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e1.py index 8b0ec0eb7..c06106024 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e2_gpu8.py index 79756cf4b..158b342c8 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_plugins_e1.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_plugins_e1.py index c9d61821c..a54741115 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -132,7 +133,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_512_e3.py index 2b298a83b..ba3514fbf 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_e3.py index 95429dab4..ed8fdbb51 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_open_platypus_e3.py index 53da5752b..24aa5b338 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_openorca_e1.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_openorca_e1.py index 9a777d23e..a7ddae0ad 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_openorca_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_sql_e3.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_sql_e3.py index 266644aca..9c0b70e81 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_sql_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_tiny_codes_e1.py b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_tiny_codes_e1.py index 8e292901e..5366890af 100644 --- a/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_tiny_codes_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_base/baichuan_13b_base_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_e3.py index ccb5b4d54..f94a54725 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_e3.py index 7ed56b427..05ef453be 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_oasst1_e3.py index 17c531f61..747fcf3e0 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_zh_e3.py index e42308b48..5f8baf7ad 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_arxiv_gentitle_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_arxiv_gentitle_e3.py index fc7430c8f..62fc9e7e9 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_code_alpaca_e3.py index 1091a8ce3..86245a5df 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_colorist_e5.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_colorist_e5.py index f59ba7bca..14a0bdcf9 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_colorist_e5.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_lawyer_e3.py index 9c99cdb5c..c723e897f 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_medical_e1.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_medical_e1.py index c5a4ab796..6a7a6299d 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_medical_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_512_e3.py index f1e232ac2..1ae252c38 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_e3.py index d33e94b81..100a9a110 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_open_platypus_e3.py index 319d3c09e..5adda4265 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_openorca_e1.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_openorca_e1.py index 7b651ac51..9c0d82e98 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_openorca_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_openorca_e1.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_sql_e3.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_sql_e3.py index 13b804d7b..64b967bdb 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_sql_e3.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_tiny_codes_e1.py b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_tiny_codes_e1.py index 82f98a7cd..d6fb78b82 100644 --- a/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_tiny_codes_e1.py +++ b/xtuner/configs/baichuan/baichuan_13b_chat/baichuan_13b_chat_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_e3.py index fa6138025..3f6f0d25a 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_e3.py index 267d81270..91f538d8e 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_oasst1_e3.py index e89d44615..21f22df58 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_zh_e3.py index a1ceaccbb..d0d3f836a 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_arxiv_gentitle_e3.py index b8f229978..b30bf1278 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_code_alpaca_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_code_alpaca_e3.py index b2d0b7c4b..c7232f30f 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_colorist_e5.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_colorist_e5.py index 9cd2a165a..4ab59797c 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_colorist_e5.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_lawyer_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_lawyer_e3.py index 91b44c27f..2d568ebbe 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_medical_e1.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_medical_e1.py index 599973f79..b5f6accba 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_medical_e1.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e1.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e1.py index 1960d8b75..2b919a46f 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e2_gpu8.py index 72ea096d8..415a7f276 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_plugins_e1.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_plugins_e1.py index 1bcbadcab..16195e5e1 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -132,7 +133,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_512_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_512_e3.py index 88bd91018..0bc07e255 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_e3.py index ed28430f1..9ec2b8eed 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_open_platypus_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_open_platypus_e3.py index 128aa560d..c96fd79e8 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_openorca_e1.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_openorca_e1.py index 2599836c4..f1a6aa1a6 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_openorca_e1.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_sql_e3.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_sql_e3.py index 34beb33fa..640f2be06 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_sql_e3.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_tiny_codes_e1.py b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_tiny_codes_e1.py index 4ad7b8855..d4e4afc01 100644 --- a/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/baichuan/baichuan_7b/baichuan_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.baichuan_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_e3.py index 90a2a63b2..0a6766e01 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_e3.py index a986cc515..d65d4326c 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_oasst1_e3.py index 5088a571f..f3aa2b534 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_zh_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_zh_e3.py index 0bef8dc42..9074c54ea 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_arxiv_gentitle_e3.py index b77fd4ee8..eab4cc16e 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_code_alpaca_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_code_alpaca_e3.py index bbd8bb44a..b38584221 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_colorist_e5.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_colorist_e5.py index dca506d10..e2bae6a2d 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_colorist_e5.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_lawyer_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_lawyer_e3.py index 620055786..1104834e9 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_lawyer_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_medical_e1.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_medical_e1.py index 8d738cc12..4aec8949b 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_medical_e1.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_512_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_512_e3.py index f8df0bf8d..020e5793e 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_e3.py index f5a275ae2..1c6da4c3b 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_open_platypus_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_open_platypus_e3.py index 9a27b4a7a..b8f5a8697 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_open_platypus_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_openorca_e1.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_openorca_e1.py index 4f625a017..453e92fb3 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_openorca_e1.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_openorca_e1.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_sql_e3.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_sql_e3.py index acef2bfb8..7d97488a2 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_sql_e3.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_tiny_codes_e1.py b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_tiny_codes_e1.py index 903e8ac84..c03c48dee 100644 --- a/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/chatglm2/chatglm2_6b/chatglm2_6b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_e3.py index cd5465243..3177a79f1 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_e3.py index 085a0e3c0..bff56c658 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_oasst1_e3.py index ea85b942d..b90f78416 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_zh_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_zh_e3.py index db3b83101..6e9549959 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_arxiv_gentitle_e3.py index 336bb7377..d19c07faa 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_code_alpaca_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_code_alpaca_e3.py index f0ee64035..6dd725fce 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_colorist_e5.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_colorist_e5.py index a66a48fab..e1d973138 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_colorist_e5.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_lawyer_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_lawyer_e3.py index e537d19cb..a804f95f3 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_lawyer_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_512_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_512_e3.py index 0c1108c00..335fb000c 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_e3.py index 8a8701ac0..723a51c0e 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_open_platypus_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_open_platypus_e3.py index a8c3c85a1..10ff36983 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_open_platypus_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_sql_e3.py b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_sql_e3.py index 799bbd1c8..64f142d08 100644 --- a/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_sql_e3.py +++ b/xtuner/configs/internlm/internlm_20b/internlm_20b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_e3.py index 42313ccc5..30e20a449 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_e3.py @@ -12,7 +12,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -22,7 +22,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -39,6 +39,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -116,7 +117,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_e3.py index 1c629ca85..574875bce 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_e3.py @@ -13,7 +13,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -24,7 +24,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -41,6 +41,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -134,7 +135,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_oasst1_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_oasst1_e3.py index ee1dfffcf..78e1b0a5b 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_enzh_oasst1_e3.py @@ -13,7 +13,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -147,7 +148,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_zh_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_zh_e3.py index b211071f4..cc3777c2f 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_zh_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_alpaca_zh_e3.py @@ -12,7 +12,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -22,7 +22,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -39,6 +39,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -116,7 +117,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_oasst1_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_oasst1_e3.py index bd955a7a7..9772f3fe7 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_full_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_full_oasst1_e3.py @@ -22,7 +22,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -39,6 +39,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -117,7 +118,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_e3.py index 5ed5e733c..c2e5aef85 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_e3.py index 2edca4553..3b6c33520 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_oasst1_e3.py index da9294eb2..c9b4ff35e 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_zh_e3.py index 7ebb226d2..d48c574c5 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_arxiv_gentitle_e3.py index ac7c6f709..aa96320fc 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_code_alpaca_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_code_alpaca_e3.py index 7c7606e5e..903c7f70c 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_colorist_e5.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_colorist_e5.py index c60e39a5c..bd1a479db 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_colorist_e5.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_lawyer_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_lawyer_e3.py index cddde9779..b41ccafbd 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_medical_e1.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_medical_e1.py index 6946d0b72..e8ebe9257 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_medical_e1.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e1.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e1.py index 1a24cab30..f96ce5f26 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e2_gpu8.py index c2826cdf3..b504535de 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_plugins_e1.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_plugins_e1.py index 40594bf62..80f5aac57 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -132,7 +133,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_512_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_512_e3.py index 4dbbbc9d1..fcefddc78 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3.py index 48231fd53..942a7a104 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3_hf.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3_hf.py index c2c9a00da..e8a5a5d39 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3_hf.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_oasst1_e3_hf.py @@ -14,7 +14,7 @@ dataset_name_or_path = 'timdettmers/openassistant-guanaco' max_length = 2048 pack_to_max_length = True -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat trainer = Trainer diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_open_platypus_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_open_platypus_e3.py index e1f3a77e1..f7c4ba77e 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_openorca_e1.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_openorca_e1.py index 73a188b97..e152900f5 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_openorca_e1.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_sql_e3.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_sql_e3.py index 2b06ff1c6..9cd2273c6 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_sql_e3.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_tiny_codes_e1.py b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_tiny_codes_e1.py index c1a559b0f..8c1d80151 100644 --- a/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/internlm/internlm_7b/internlm_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_e3.py index fc029750a..57ee1d888 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_e3.py index 5b9325020..3144710a7 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_oasst1_e3.py index 66f1e7869..9bd50ea3f 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_zh_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_zh_e3.py index 48e9859db..aa7f853ea 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_code_alpaca_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_code_alpaca_e3.py index 9b148a0d4..7e9b51fd8 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_lawyer_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_lawyer_e3.py index 7e65e7671..c4d835ff6 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_lawyer_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_512_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_512_e3.py index 7beeec614..f7fff8868 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_e3.py index 4c43ba018..0f9a4c923 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_open_platypus_e3.py b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_open_platypus_e3.py index 9b3cc3286..f1a878a0a 100644 --- a/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_open_platypus_e3.py +++ b/xtuner/configs/internlm/internlm_chat_20b/internlm_chat_20b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = prompt_template = PROMPT_TEMPLATE.internlm_chat +prompt_template = PROMPT_TEMPLATE.internlm_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_e3.py index 578d99b31..3a0b4c397 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_e3.py index f9f97f9e3..0026d5812 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_oasst1_e3.py index 8fdfc3462..b1d81c302 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_zh_e3.py index 6f191d216..6ac69c832 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_arxiv_gentitle_e3.py index 51f2407b0..0ba0ba2d4 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_code_alpaca_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_code_alpaca_e3.py index 787d88ffe..9fd8d6437 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_colorist_e5.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_colorist_e5.py index 6e12ed705..059bd3164 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_colorist_e5.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_lawyer_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_lawyer_e3.py index c1bfb69f5..779bc00c6 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_medical_e1.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_medical_e1.py index 2dc8efa88..2e073201c 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_medical_e1.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_512_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_512_e3.py index de72b571e..da04f58a6 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_e3.py index 35d101a32..cafd0724f 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_open_platypus_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_open_platypus_e3.py index a2b83d87f..0f80f9a94 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_openorca_e1.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_openorca_e1.py index ff783dbc7..bc914fe42 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_openorca_e1.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_openorca_e1.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_sql_e3.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_sql_e3.py index 11027a78d..ac69c2c48 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_sql_e3.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_tiny_codes_e1.py b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_tiny_codes_e1.py index 9db9a7134..b33ce7fdc 100644 --- a/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/internlm/internlm_chat_7b/internlm_chat_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1.py b/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1.py index 6238e8e65..7f7a0b485 100644 --- a/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1.py +++ b/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1.py @@ -14,7 +14,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -24,7 +24,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -41,6 +41,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -129,7 +130,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1_hf.py b/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1_hf.py index ea0531224..1819ea544 100644 --- a/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1_hf.py +++ b/xtuner/configs/llama/llama2_70b/llama2_70b_int8_lora_open_platypus_e1_hf.py @@ -14,7 +14,7 @@ dataset_name_or_path = 'garage-bAInd/Open-Platypus' max_length = 2048 pack_to_max_length = True -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat trainer = Trainer diff --git a/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1.py b/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1.py index f6e692f0f..6c8ccd1b9 100644 --- a/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1.py +++ b/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -138,7 +139,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1_hf.py b/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1_hf.py index 3fca30999..7ee147c03 100644 --- a/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1_hf.py +++ b/xtuner/configs/llama/llama2_70b/llama2_70b_qlora_open_platypus_e1_hf.py @@ -14,7 +14,7 @@ dataset_name_or_path = 'garage-bAInd/Open-Platypus' max_length = 2048 pack_to_max_length = True -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat trainer = Trainer diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_full_wizardlm_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_full_wizardlm_e1.py index 2bf5a44e8..7a6203606 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_full_wizardlm_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_full_wizardlm_e1.py @@ -22,7 +22,7 @@ # Data data_path = 'WizardLM/WizardLM_evol_instruct_V2_196k' -prompt_template = PROMPT_TEMPLATE.wizardlm +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -39,6 +39,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -117,7 +118,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_e3.py index 07a0d160f..843bfd390 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_e3.py index 25ae97dda..b869d2bc8 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_oasst1_e3.py index 5e170e8e9..3389df798 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_zh_e3.py index 753e301ab..ee6dba9d9 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_arxiv_gentitle_e3.py index e089b01e9..835ee4722 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_code_alpaca_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_code_alpaca_e3.py index 375994f20..0a4496372 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_colorist_e5.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_colorist_e5.py index 0fa560760..231df869e 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_colorist_e5.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_lawyer_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_lawyer_e3.py index 2d1f8a2f3..cf3147d9f 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_medical_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_medical_e1.py index 0247c1902..aa98020c5 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_medical_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e1.py index e03e289de..95223f9a6 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e2_gpu8.py index 22c39cad1..867f9d727 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_plugins_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_plugins_e1.py index c3381aa34..72a9639b9 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -132,7 +133,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_512_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_512_e3.py index 1422fb3d4..84ee8d69a 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_e3.py index 91076c897..cdf88e60e 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_open_platypus_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_open_platypus_e3.py index 704edf3d3..93e3e67f9 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_openorca_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_openorca_e1.py index 1bef36c79..e84ed750e 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_openorca_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_sql_e3.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_sql_e3.py index e9d3ce650..220515565 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_sql_e3.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_tiny_codes_e1.py b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_tiny_codes_e1.py index c7737ca04..ec95d73cf 100644 --- a/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/llama/llama2_7b/llama2_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_e3.py index ddb6a63dd..efbed02bc 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_e3.py index 962d5d2ee..aa6d16d54 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py index f784c168f..c89e517c4 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_zh_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_zh_e3.py index b83601ec0..4c47d9e66 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_arxiv_gentitle_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_arxiv_gentitle_e3.py index 2688dd320..88b6578e5 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_code_alpaca_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_code_alpaca_e3.py index e898af0bd..985348f6e 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_code_alpaca_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_colorist_e5.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_colorist_e5.py index 3755161b4..09bc751b6 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_colorist_e5.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_lawyer_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_lawyer_e3.py index 2c694e87a..6a0f37160 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_lawyer_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_medical_e1.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_medical_e1.py index d18ce4517..59b01a023 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_medical_e1.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_512_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_512_e3.py index ed3b2dcc6..3419717c6 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_512_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_e3.py index 3ac897403..d253cf892 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_open_platypus_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_open_platypus_e3.py index f69316478..d4df0326a 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_open_platypus_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_openorca_e1.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_openorca_e1.py index a6171b61a..942674ed3 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_openorca_e1.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_sql_e3.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_sql_e3.py index e928af389..e8b544c00 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_sql_e3.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_tiny_codes_e1.py b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_tiny_codes_e1.py index f7b56a5fb..ed6c4d933 100644 --- a/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_tiny_codes_e1.py +++ b/xtuner/configs/llama/llama2_7b_chat/llama2_7b_chat_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.llama_2_chat +prompt_template = PROMPT_TEMPLATE.llama2_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_e3.py index 5252723e4..2366670e9 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_e3.py index 7ab11723f..d51478d37 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -155,7 +156,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_oasst1_e3.py index 6bb9a15b4..ff02e242c 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -168,7 +169,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_zh_e3.py index 8622b9731..2cdfe8ccb 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_arxiv_gentitle_e3.py index 459ae06f0..7ada31276 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -172,7 +173,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_code_alpaca_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_code_alpaca_e3.py index 38cea2e10..3077eea3c 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_colorist_e5.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_colorist_e5.py index afc73d7ec..8005013b7 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_colorist_e5.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_lawyer_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_lawyer_e3.py index 5420e5774..b54b11e56 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -163,7 +164,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_medical_e1.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_medical_e1.py index f8f983749..b53d972f0 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_medical_e1.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -139,7 +140,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e1.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e1.py index 7683037b1..e215dd775 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e2_gpu8.py index 1023837ba..8e14d5439 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -146,7 +147,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_plugins_e1.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_plugins_e1.py index ab182f1cd..86177f9a9 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -132,7 +133,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_512_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_512_e3.py index 39e33dbf0..2527cdda1 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.default max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_e3.py index 23ac319a5..5cbed4b10 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_open_platypus_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_open_platypus_e3.py index 1be317d1c..5c3f49fe4 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_openorca_e1.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_openorca_e1.py index 0f43495a5..d814e4e4f 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_openorca_e1.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -137,7 +138,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_sql_e3.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_sql_e3.py index 8b913f3b4..de63c0714 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_sql_e3.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/llama/llama_7b/llama_7b_qlora_tiny_codes_e1.py b/xtuner/configs/llama/llama_7b/llama_7b_qlora_tiny_codes_e1.py index 9f88cd3cf..c788158e4 100644 --- a/xtuner/configs/llama/llama_7b/llama_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/llama/llama_7b/llama_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -141,7 +142,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_e3.py index 878af6254..110e9201c 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_e3.py index 0e74728de..9a0d4489f 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -156,7 +158,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_oasst1_e3.py index c29cd826d..a5650a11f 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -28,7 +28,7 @@ alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' alpaca_en_path = 'tatsu-lab/alpaca' oasst1_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -56,7 +57,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -169,7 +171,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_zh_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_zh_e3.py index 75e633c2a..1fd9f8099 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data alpaca_zh_path = 'silk-road/alpaca-data-gpt4-chinese' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_arxiv_gentitle_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_arxiv_gentitle_e3.py index 68cfd48e7..e5de6fe35 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -27,7 +27,7 @@ # 1. Download data from https://kaggle.com/datasets/Cornell-University/arxiv # 2. Process data by `xtuner preprocess arxiv ${DOWNLOADED_DATA} ./data/arxiv_data.json [optional arguments]` # noqa: E501 data_path = './data/arxiv_data.json' -prompt_template = PROMPT_TEMPLATE.title +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -87,7 +88,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -173,7 +175,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_code_alpaca_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_code_alpaca_e3.py index c58ed6e21..f578621c4 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_code_alpaca_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'HuggingFaceH4/CodeAlpaca_20K' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_colorist_e5.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_colorist_e5.py index ef929839e..301dc6ea8 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_colorist_e5.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'burkelibbey/colors' -prompt_template = PROMPT_TEMPLATE.colorist +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_lawyer_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_lawyer_e3.py index e847e0995..ff1a9c6e0 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_lawyer_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -29,7 +29,7 @@ # download data from https://github.com/LiuHC0428/LAW-GPT crime_kg_assitant_path = './data/CrimeKgAssitant清洗后_52k.json' law_reference_data_path = './data/训练数据_带法律依据_92k.json' -prompt_template = PROMPT_TEMPLATE.lawyer +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -164,7 +166,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_medical_e1.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_medical_e1.py index e3e952425..806a17bbf 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_medical_e1.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -26,7 +26,7 @@ # Data data_path = 'shibing624/medical' data_config_name = 'finetune' -prompt_template = PROMPT_TEMPLATE.medical +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -140,7 +142,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e1.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e1.py index 4962f78eb..4bd57b0aa 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e1.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -146,7 +148,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e2_gpu8.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e2_gpu8.py index e1ad75e7f..14b4e1349 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e2_gpu8.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_all_e2_gpu8.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -40,6 +40,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -146,7 +148,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_plugins_e1.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_plugins_e1.py index eb1fce96c..f2f5edd52 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_plugins_e1.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_moss_sft_plugins_e1.py @@ -13,7 +13,7 @@ from xtuner.dataset.collate_fns import default_collate_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -39,6 +39,7 @@ max_norm = 1 # grad clip # Evaluate the generation performance during the training +SYSTEM = SYSTEM_TEMPLATE.moss_sft prompt_template = PROMPT_TEMPLATE.moss_sft evaluation_freq = 500 evaluation_inputs = [ @@ -52,7 +53,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -132,7 +134,8 @@ every_n_iters=evaluation_freq, stop_word='', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_512_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_512_e3.py index e2bc77598..85282a4cf 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_512_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_512_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 512 pack_to_max_length = False @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_e3.py index cf7e468de..88a052ef5 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_oasst1_e3.py @@ -25,7 +25,7 @@ # Data data_path = 'timdettmers/openassistant-guanaco' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_open_platypus_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_open_platypus_e3.py index 5e6723556..8e2bac41e 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_open_platypus_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'garage-bAInd/Open-Platypus' -prompt_template = PROMPT_TEMPLATE.alpaca +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_openorca_e1.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_openorca_e1.py index 340fc781e..f6e764a56 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_openorca_e1.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_openorca_e1.py @@ -25,7 +25,7 @@ # Data data_path = 'Open-Orca/OpenOrca' -prompt_template = PROMPT_TEMPLATE.openassistant +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_sql_e3.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_sql_e3.py index 2acfcfa91..04371ad95 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_sql_e3.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'b-mc2/sql-create-context' -prompt_template = PROMPT_TEMPLATE.sql +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_tiny_codes_e1.py b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_tiny_codes_e1.py index 88bb26bd6..e7416ae10 100644 --- a/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_tiny_codes_e1.py +++ b/xtuner/configs/qwen/qwen_7b/qwen_7b_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -25,7 +25,7 @@ # Data data_path = 'nampdn-ai/tiny-codes' -prompt_template = PROMPT_TEMPLATE.coder +prompt_template = PROMPT_TEMPLATE.qwen_chat max_length = 2048 pack_to_max_length = True @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|endoftext|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|endoftext|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_e3.py index ba3462a99..d796fb8f8 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_e3.py index 1b4e81d39..1b7fe82a2 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_e3.py @@ -16,7 +16,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -156,7 +158,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_oasst1_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_oasst1_e3.py index 0830fb3a8..f201ff7c8 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_oasst1_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_enzh_oasst1_e3.py @@ -16,7 +16,7 @@ oasst1_map_fn, template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -56,7 +57,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -169,7 +171,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_zh_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_zh_e3.py index 96a211cc5..64e63fd7b 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_zh_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_alpaca_zh_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_zh_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_arxiv_gentitle_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_arxiv_gentitle_e3.py index 3d819b50b..6bee80e81 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_arxiv_gentitle_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_arxiv_gentitle_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import arxiv_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -44,6 +44,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.arxiv_gentile evaluation_inputs = [ ('We present InternLM, a multilingual foundational language ' 'model with 104B parameters. InternLM is pre-trained on a large ' @@ -87,7 +88,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -173,7 +175,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_code_alpaca_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_code_alpaca_e3.py index 6c897a475..4d540bc85 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_code_alpaca_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_code_alpaca_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import code_alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 100 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_colorist_e5.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_colorist_e5.py index e52d4da5f..1d5ee97b9 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_colorist_e5.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_colorist_e5.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import colors_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = SYSTEM_TEMPLATE.colorist evaluation_inputs = [ '请给我一个像天空一样清澈透明的蓝色。', 'Please give me a clear blue like the sky.' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_lawyer_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_lawyer_e3.py index 701887f46..456fe4c00 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_lawyer_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_lawyer_e3.py @@ -17,7 +17,7 @@ template_map_fn_factory) from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -46,6 +46,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.lawyer evaluation_inputs = ['请问离婚需要准备什么材料?', '销售鳄鱼皮包违法吗?'] ####################################################################### @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -164,7 +166,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_medical_e1.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_medical_e1.py index 7646595da..7a137a19c 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_medical_e1.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_medical_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import medical_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -43,6 +43,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.medical evaluation_inputs = [ '我有家族遗传性的过敏,请问可以可以献血吗?', '我爷爷有高血压,请问他可以喝咖啡吗?', '我女儿今年3岁了,从昨天晚上九点开始腹泻,到现在已经八个小时了,请问应该怎么办?' @@ -55,7 +56,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -140,7 +142,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_512_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_512_e3.py index 1756c2c79..3dad3666e 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_512_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_512_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_e3.py index 14ba257c5..0cf0932a3 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_oasst1_e3.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_open_platypus_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_open_platypus_e3.py index 5f1c1808d..ae1602fd4 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_open_platypus_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_open_platypus_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import alpaca_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.alpaca evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_openorca_e1.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_openorca_e1.py index 29623f455..991b1ec5d 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_openorca_e1.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_openorca_e1.py @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 5000 +SYSTEM = '' evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] @@ -53,7 +54,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -138,7 +140,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_sql_e3.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_sql_e3.py index 8eea6249d..79b14171b 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_sql_e3.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_sql_e3.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import sql_map_fn, template_map_fn_factory from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.sql evaluation_inputs = [ ('CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)\n' 'Find the name, latitude, and city of stations with latitude ' @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_tiny_codes_e1.py b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_tiny_codes_e1.py index 4ae82bb71..08b2764b4 100644 --- a/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_tiny_codes_e1.py +++ b/xtuner/configs/qwen/qwen_7b_chat/qwen_7b_chat_qlora_tiny_codes_e1.py @@ -15,7 +15,7 @@ from xtuner.dataset.map_fns import template_map_fn_factory, tiny_codes_map_fn from xtuner.engine import DatasetInfoHook, EvaluateChatHook from xtuner.model import SupervisedFinetune -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE ####################################################################### # PART 1 Settings # @@ -42,6 +42,7 @@ # Evaluate the generation performance during the training evaluation_freq = 500 +SYSTEM = SYSTEM_TEMPLATE.coder evaluation_inputs = [ ('写一个Python函数,将十六进制颜色代码(如#0066ee)转换为对应的' '红、绿、蓝(RGB)三个颜色分量值,并以元组的形式返回。'), @@ -57,7 +58,8 @@ type=AutoTokenizer.from_pretrained, pretrained_model_name_or_path=pretrained_model_name_or_path, trust_remote_code=True, - padding_side='right') + padding_side='right', + eos_token='<|im_end|>') model = dict( type=SupervisedFinetune, @@ -142,7 +144,8 @@ every_n_iters=evaluation_freq, stop_word='<|im_end|>', evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/configs/starcoder/starcoder_qlora_stack_exchange_example.py b/xtuner/configs/starcoder/starcoder_qlora_stack_exchange_example.py index ad143049e..218c1a7f3 100644 --- a/xtuner/configs/starcoder/starcoder_qlora_stack_exchange_example.py +++ b/xtuner/configs/starcoder/starcoder_qlora_stack_exchange_example.py @@ -26,7 +26,7 @@ # Data data_path = 'ArmelR/stack-exchange-instruction' -prompt_template = PROMPT_TEMPLATE.stack_exchange +prompt_template = PROMPT_TEMPLATE.default max_length = 2048 # randomly select 20000 samples from the original dataset max_dataset_length = 20000 @@ -45,6 +45,7 @@ # Evaluate the generation performance during the training evaluation_freq = 200 +SYSTEM = '' evaluation_inputs = [ 'from typing import List def has_close_elements(numbers: List[float], threshold: float) -> bool: """ Check if in given list of numbers, are any two numbers closer to each other than given threshold. >>> has_close_elements([1.0, 2.0, 3.0], 0.5) False >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) True """' # noqa: E501 ] @@ -146,7 +147,8 @@ tokenizer=tokenizer, every_n_iters=evaluation_freq, evaluation_inputs=evaluation_inputs, - instruction=prompt_template.INSTRUCTION_START) + system=SYSTEM, + prompt_template=prompt_template) ] # configure default hooks diff --git a/xtuner/dataset/map_fns/dataset_map_fns/alpaca_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/alpaca_map_fn.py index 130fe2d30..cd0f782d5 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/alpaca_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/alpaca_map_fn.py @@ -1,13 +1,15 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def alpaca_map_fn(example): if example.get('output') == '': - return {'conversation': [{'input': '', 'output': ''}]} + return {'conversation': []} else: return { 'conversation': [{ - 'input': - '{instruction}\n{input}'.format(**example), - 'output': - example['output'] + 'system': SYSTEM_TEMPLATE.alpaca, + 'input': f"{example['instruction']}\n{example['input']}", + 'output': example['output'] }] } diff --git a/xtuner/dataset/map_fns/dataset_map_fns/alpaca_zh_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/alpaca_zh_map_fn.py index 94e4502b7..b94f7ea83 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/alpaca_zh_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/alpaca_zh_map_fn.py @@ -1,10 +1,12 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def alpaca_zh_map_fn(example): return { 'conversation': [{ - 'input': - '{instruction_zh}\n{input_zh}'.format(**example), - 'output': - example['output_zh'] + 'system': SYSTEM_TEMPLATE.alpaca, + 'input': f"{example['instruction_zh']}\n{example['input_zh']}", + 'output': example['output_zh'] }] } diff --git a/xtuner/dataset/map_fns/dataset_map_fns/arxiv_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/arxiv_map_fn.py index f2f06a0fe..52bcc4e34 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/arxiv_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/arxiv_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def arxiv_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.arxiv_gentile, 'input': example['abstract'], 'output': example['title'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/code_alpaca_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/code_alpaca_map_fn.py index cd54d4ec9..ece86ff20 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/code_alpaca_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/code_alpaca_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def code_alpaca_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.coder, 'input': example['prompt'], 'output': example['completion'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/colors_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/colors_map_fn.py index 8ebc18aae..17d08bf20 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/colors_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/colors_map_fn.py @@ -1,4 +1,13 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def colors_map_fn(example): desc = ':'.join(example['description'].split(':')[1:]).strip() - return {'conversation': [{'input': desc, 'output': example['color']}]} + return { + 'conversation': [{ + 'system': SYSTEM_TEMPLATE.colorist, + 'input': desc, + 'output': example['color'] + }] + } diff --git a/xtuner/dataset/map_fns/dataset_map_fns/crime_kg_assitant_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/crime_kg_assitant_map_fn.py index 10eefe4fc..b7511a98d 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/crime_kg_assitant_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/crime_kg_assitant_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def crime_kg_assitant_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.lawyer, 'input': example['input'], 'output': example['output'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/law_reference_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/law_reference_map_fn.py index 74e687927..297086fa0 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/law_reference_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/law_reference_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def law_reference_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.lawyer, 'input': example['question'], 'output': example['answer'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/medical_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/medical_map_fn.py index 497b8231f..60a955454 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/medical_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/medical_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def medical_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.medical, 'input': '{instruction}\n{input}'.format(**example), 'output': example['output'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/openai_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/openai_map_fn.py index 1c14a106c..64ed642f6 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/openai_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/openai_map_fn.py @@ -12,30 +12,33 @@ def openai_map_fn(example): Example after preprocessing: example["conversation"] = [ { - "input": "You are an assistant that occasionally misspells - words. Tell me a story.", + "system": "You are an assistant that occasionally misspells + words.", + "input": "Tell me a story.", "output": "One day a student went to schoool." } ] """ messages = example['messages'] - if len(messages) == 0: - return {'conversation': [{'input': '', 'output': ''}]} - if messages[0]['role'] == 'system': - messages[1][ - 'content'] = messages[0]['content'] + ' ' + messages[1]['content'] - messages = messages[1:] - if len(messages) % 2: - # The last round of conversation solely consists of input - # without any output. - # Discard the input part of the last round, as this part is ignored in - # the loss calculation. - messages.pop() + system = '' + input = '' conversation = [] - for i in range(0, len(messages), 2): - single_turn_conversation = { - 'input': messages[i]['content'], - 'output': messages[i + 1]['content'] - } - conversation.append(single_turn_conversation) + while messages and messages[0]['role'] == 'assistant': + # Skip the first one if it is from assistant + messages = messages[1:] + for msg in messages: + if msg['role'] == 'system': + system = msg['content'] + elif msg['role'] == 'user': + input += msg['content'] + elif msg['role'] == 'assistant': + conversation.append({ + 'system': system, + 'input': input, + 'output': msg['content'] + }) + system = '' + input = '' + else: + raise NotImplementedError return {'conversation': conversation} diff --git a/xtuner/dataset/map_fns/dataset_map_fns/openorca_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/openorca_map_fn.py index 74c992447..45e58f3b9 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/openorca_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/openorca_map_fn.py @@ -2,6 +2,7 @@ def openorca_map_fn(example): return { 'conversation': [{ + 'system': example['system_prompt'], 'input': example['question'], 'output': example['response'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/sql_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/sql_map_fn.py index f74b5d654..c83434f8d 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/sql_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/sql_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def sql_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.sql, 'input': '{context}\n{question}'.format(**example), 'output': example['answer'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/tiny_codes_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/tiny_codes_map_fn.py index a3498c47a..fe0cc02b4 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/tiny_codes_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/tiny_codes_map_fn.py @@ -1,7 +1,11 @@ # Copyright (c) OpenMMLab. All rights reserved. +from xtuner.utils import SYSTEM_TEMPLATE + + def tiny_codes_map_fn(example): return { 'conversation': [{ + 'system': SYSTEM_TEMPLATE.coder, 'input': example['prompt'], 'output': example['response'] }] diff --git a/xtuner/dataset/map_fns/dataset_map_fns/wizardlm_map_fn.py b/xtuner/dataset/map_fns/dataset_map_fns/wizardlm_map_fn.py index 4a41fd50b..0174760d0 100644 --- a/xtuner/dataset/map_fns/dataset_map_fns/wizardlm_map_fn.py +++ b/xtuner/dataset/map_fns/dataset_map_fns/wizardlm_map_fn.py @@ -1,20 +1,17 @@ # Copyright (c) OpenMMLab. All rights reserved. def wizardlm_map_fn(example): - data = example['conversations'] - while data and data[0]['from'] != 'human': - # Skip the first one if it is not from human - data = data[1:] - - if len(data) % 2: - # The last round of conversation solely consists of input - # without any output. - # Discard the input part of the last round, as this part is ignored in - # the loss calculation. - data.pop() - + messages = example['conversations'] + input = '' conversation = [] - for i in range(0, len(data), 2): - assert data[i]['from'] == 'human' and data[i + 1]['from'] == 'gpt' - human, gpt = data[i]['value'], data[i + 1]['value'] - conversation.append({'input': human, 'output': gpt}) + while messages and messages[0]['from'] == 'gpt': + # Skip the first one if it is from gpt + messages = messages[1:] + for msg in messages: + if msg['from'] == 'human': + input += msg['value'] + elif msg['from'] == 'gpt': + conversation.append({'input': input, 'output': msg['value']}) + input = '' + else: + raise NotImplementedError return {'conversation': conversation} diff --git a/xtuner/dataset/map_fns/template_map_fn.py b/xtuner/dataset/map_fns/template_map_fn.py index 620a8775e..a2b6bdf92 100644 --- a/xtuner/dataset/map_fns/template_map_fn.py +++ b/xtuner/dataset/map_fns/template_map_fn.py @@ -6,13 +6,12 @@ def template_map_fn(example, template): conversation = example.get('conversation', []) for i, single_turn_conversation in enumerate(conversation): input = single_turn_conversation['input'] - if i == 0: - single_turn_conversation[ - 'input'] = template.INSTRUCTION_START.format( - input=input, round=i + 1) - else: - single_turn_conversation['input'] = template.INSTRUCTION.format( - input=input, round=i + 1) + input = template.INSTRUCTION.format(input=input, round=i + 1) + system = single_turn_conversation.get('system', '') + if system != '': + system = template.SYSTEM.format(system=system) + input = system + input + single_turn_conversation['input'] = input return {'conversation': conversation} diff --git a/xtuner/dataset/utils.py b/xtuner/dataset/utils.py index 31dc2c845..6e1d33f80 100644 --- a/xtuner/dataset/utils.py +++ b/xtuner/dataset/utils.py @@ -38,8 +38,7 @@ def encode_fn(example, tokenizer, max_length, input_ids_with_output=True): """ if tokenizer.__class__.__name__ == 'QWenTokenizer': bos_token_id = [] - eos_token_id = tokenizer.encode( - '<|endoftext|>', add_special_tokens=False) + eos_token_id = tokenizer.eos_token_id elif tokenizer.__class__.__name__ == 'ChatGLMTokenizer': bos_token_id = [] eos_token_id = tokenizer.eos_token_id diff --git a/xtuner/engine/hooks/evaluate_chat_hook.py b/xtuner/engine/hooks/evaluate_chat_hook.py index 2565a8f33..78caf2197 100644 --- a/xtuner/engine/hooks/evaluate_chat_hook.py +++ b/xtuner/engine/hooks/evaluate_chat_hook.py @@ -12,16 +12,23 @@ class EvaluateChatHook(Hook): def __init__(self, tokenizer, evaluation_inputs, - instruction=None, + system='', + prompt_template=None, every_n_iters=None, max_new_tokens=600, stop_word=None): self.evaluation_inputs = evaluation_inputs if isinstance(self.evaluation_inputs, str): self.evaluation_inputs = [self.evaluation_inputs] - if instruction == '' or instruction is None: + if prompt_template is None: instruction = '{input}' + else: + instruction = prompt_template.get('INSTRUCTION', '{input}') + if system != '': + system = prompt_template.get( + 'SYSTEM', '{system}\n').format(system=system) self.instruction = instruction + self.system = system self.every_n_iters = every_n_iters self.max_new_tokens = max_new_tokens self.tokenizer = BUILDER.build(tokenizer) @@ -60,7 +67,7 @@ def _generate_samples(self, runner, max_new_tokens=None): model.eval() for sample_input in self.evaluation_inputs: - inputs = self.instruction.format( + inputs = (self.system + self.instruction).format( input=sample_input, round=1, **runner.cfg) input_ids = self.tokenizer( inputs, return_tensors='pt')['input_ids'] @@ -81,7 +88,7 @@ def _generate_samples(self, runner, max_new_tokens=None): model.train() def before_train(self, runner): - runner.logger.info('before_train in EvaluateChatHook .') + runner.logger.info('before_train in EvaluateChatHook.') self._generate_samples(runner, max_new_tokens=50) def after_train_iter(self, @@ -92,11 +99,15 @@ def after_train_iter(self, if self.every_n_iters is None or (batch_idx + 1) % self.every_n_iters != 0: return - runner.logger.info('after_train_iter in EvaluateChatHook .') + runner.logger.info('after_train_iter in EvaluateChatHook.') + self._generate_samples(runner) + + def after_train(self, runner): + runner.logger.info('after_train in EvaluateChatHook.') self._generate_samples(runner) def after_val(self, runner) -> None: if self.every_n_iters is not None: return - runner.logger.info('after_val in EvaluateChatHook .') + runner.logger.info('after_val in EvaluateChatHook.') self._generate_samples(runner) diff --git a/xtuner/entry_point.py b/xtuner/entry_point.py index b7e4edf91..27360d945 100644 --- a/xtuner/entry_point.py +++ b/xtuner/entry_point.py @@ -44,7 +44,7 @@ 4-3. Split HuggingFace's LLM to the smallest sharded one: xtuner convert split $NAME_OR_PATH_TO_LLM $SAVE_PATH 5. Chat with LLMs with HuggingFace's model and adapter: - xtuner chat $NAME_OR_PATH_TO_LLM --adapter $NAME_OR_PATH_TO_ADAPTER --prompt-template $PROMPT_TEMPLATE + xtuner chat $NAME_OR_PATH_TO_LLM --adapter $NAME_OR_PATH_TO_ADAPTER --prompt-template $PROMPT_TEMPLATE --system-template $SYSTEM_TEMPLATE 6-1. Preprocess arxiv dataset: xtuner preprocess arxiv $SRC_FILE $DST_FILE --start-date $START_DATE --categories $CATEGORIES 7-1. Log processed dataset: diff --git a/xtuner/tools/chat.py b/xtuner/tools/chat.py index da7a0750b..951c43bb9 100644 --- a/xtuner/tools/chat.py +++ b/xtuner/tools/chat.py @@ -8,7 +8,7 @@ BitsAndBytesConfig, GenerationConfig) from xtuner.tools.utils import get_chat_utils, update_stop_criteria -from xtuner.utils import PROMPT_TEMPLATE +from xtuner.utils import PROMPT_TEMPLATE, SYSTEM_TEMPLATE def remove_prefix(state_dict, prefix): @@ -30,8 +30,16 @@ def parse_args(): parser.add_argument( '--prompt-template', choices=PROMPT_TEMPLATE.keys(), + default=PROMPT_TEMPLATE.default, + help='Specify a prompt template') + system_group = parser.add_mutually_exclusive_group() + system_group.add_argument( + '--system', default=None, help='Specify the system text') + system_group.add_argument( + '--system-template', + choices=SYSTEM_TEMPLATE.keys(), default=None, - help='Specify a prompt option') + help='Specify a system template') parser.add_argument( '--bits', type=int, @@ -110,7 +118,7 @@ def main(): solve_open = False search_open = False else: - assert args.prompt_template == 'moss_sft' + assert args.prompt_template == args.system_template == 'moss_sft' from plugins import plugins_api inner_thoughts_open = True calculate_open = 'calculate' in args.with_plugins @@ -188,34 +196,41 @@ def main(): if text.strip() == 'EXIT': print('Log: Exit!') exit(0) - if args.prompt_template is not None: - template = PROMPT_TEMPLATE[args.prompt_template] - if 'INSTRUCTION_START' in template and n_turn == 0: - prompt_text = template['INSTRUCTION_START'].format( - input=text, round=n_turn + 1, bot_name=args.bot_name) - else: - prompt_text = template['INSTRUCTION'].format( - input=text, round=n_turn + 1, bot_name=args.bot_name) - if args.prompt_template == 'moss_sft': - if not inner_thoughts_open: - prompt_text.replace('- Inner thoughts: enabled.', - '- Inner thoughts: disabled.') - if not calculate_open: - prompt_text.replace( - '- Calculator: enabled. API: Calculate(expression)', - '- Calculator: disabled.') - if not solve_open: - prompt_text.replace( - '- Equation solver: enabled. API: Solve(equation)', - '- Equation solver: disabled.') - if not search_open: - prompt_text.replace( - '- Web search: enabled. API: Search(query)', - '- Web search: disabled.') - inputs += prompt_text - else: - inputs += text + template = PROMPT_TEMPLATE[args.prompt_template] + prompt_text = '' + if 'SYSTEM' in template and n_turn == 0: + system_text = None + if args.system_template is not None: + system_text = SYSTEM_TEMPLATE[args.system_template].format( + round=n_turn + 1, bot_name=args.bot_name) + elif args.system is not None: + system_text = args.system + if system_text is not None: + prompt_text += template['SYSTEM'].format( + system=system_text, + round=n_turn + 1, + bot_name=args.bot_name) + prompt_text += template['INSTRUCTION'].format( + input=text, round=n_turn + 1, bot_name=args.bot_name) + if args.prompt_template == args.system_template == 'moss_sft': + if not inner_thoughts_open: + prompt_text.replace('- Inner thoughts: enabled.', + '- Inner thoughts: disabled.') + if not calculate_open: + prompt_text.replace( + '- Calculator: enabled. API: Calculate(expression)', + '- Calculator: disabled.') + if not solve_open: + prompt_text.replace( + '- Equation solver: enabled. API: Solve(equation)', + '- Equation solver: disabled.') + if not search_open: + prompt_text.replace( + '- Web search: enabled. API: Search(query)', + '- Web search: disabled.') + + inputs += prompt_text ids = tokenizer.encode(inputs, return_tensors='pt') streamer = Streamer(tokenizer) if Streamer is not None else None if args.with_plugins is not None: diff --git a/xtuner/utils/__init__.py b/xtuner/utils/__init__.py index 81547e6d9..bb3e1528f 100644 --- a/xtuner/utils/__init__.py +++ b/xtuner/utils/__init__.py @@ -1,9 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. from .constants import DEFAULT_PAD_TOKEN_INDEX, IGNORE_INDEX from .stop_criteria import StopWordStoppingCriteria -from .templates import PROMPT_TEMPLATE +from .templates import PROMPT_TEMPLATE, SYSTEM_TEMPLATE __all__ = [ 'IGNORE_INDEX', 'DEFAULT_PAD_TOKEN_INDEX', 'PROMPT_TEMPLATE', - 'StopWordStoppingCriteria' + 'SYSTEM_TEMPLATE', 'StopWordStoppingCriteria' ] diff --git a/xtuner/utils/templates.py b/xtuner/utils/templates.py index 21c3a1eee..2d870f959 100644 --- a/xtuner/utils/templates.py +++ b/xtuner/utils/templates.py @@ -2,96 +2,66 @@ from mmengine.config import ConfigDict PROMPT_TEMPLATE = ConfigDict( - title=dict( - INSTRUCTION_START=( - 'If you are an expert in writing papers, please generate ' - "a good paper title for this paper based on other authors' " - 'descriptions of their abstracts.\n\n' - '### Descriptions:\n{input}\n\n### Title: '), - INSTRUCTION='### Descriptions:\n{input}\n\n### Title: '), - moss_sft=dict( - INSTRUCTION_START=( - 'You are an AI assistant whose name is {bot_name}.\n' - 'Capabilities and tools that {bot_name} can possess.\n' - '- Inner thoughts: enabled.\n' - '- Web search: enabled. API: Search(query)\n' - '- Calculator: enabled. API: Calculate(expression)\n' - '- Equation solver: enabled. API: Solve(equation)\n' - '- Text-to-image: disabled.\n' - '- Image edition: disabled.\n' - '- Text-to-speech: disabled.\n' - '<|Human|>: {input}'), - INSTRUCTION='<|Human|>: {input}'), - alpaca=dict( - INSTRUCTION_START=( - 'Below is an instruction that describes a task. ' - 'Write a response that appropriately completes the request.\n\n' - '### Instruction:\n{input}\n\n' - '### Response: '), - INSTRUCTION='### Instruction:\n{input}\n\n### Response: '), - openassistant=dict( - INSTRUCTION_START='### Human: {input}\n### Assistant: ', - INSTRUCTION='### Human: {input}\n### Assistant: '), - medical=dict( - INSTRUCTION_START=('如果你是一名医生,请根据患者的描述回答医学问题。\n\n### Input: {input}\n\n' - '### Response: '), - INSTRUCTION='### Input: {input}\n\n### Response: '), - llama_2_chat=dict( - INSTRUCTION_START=( + default=dict( + SYSTEM='<|System|>:{system}\n', + INSTRUCTION='<|User|>:{input}\n<|Bot|>:'), + internlm_chat=dict( + SYSTEM='<|System|>:{system}\n', + INSTRUCTION='<|User|>:{input}\n<|Bot|>:'), + moss_sft=dict(SYSTEM='{system}\n', INSTRUCTION='<|Human|>: {input}'), + llama2_chat=dict( + SYSTEM=( '[INST] <>\n You are a helpful, respectful and honest ' 'assistant. Always answer as helpfully as possible, while being ' 'safe. Your answers should not include any harmful, unethical, ' 'racist, sexist, toxic, dangerous, or illegal content. Please ' 'ensure that your responses are socially unbiased and positive in ' - 'nature. \n<>\n\n{input} [/INST]'), + 'nature.\n{system}\n<>\n [/INST]'), INSTRUCTION='[INST] {input} [/INST]'), code_llama_chat=dict( - INSTRUCTION_START='[INST] {input} [/INST]', - INSTRUCTION='[INST] {input} [/INST]', - ), - internlm_chat=dict( - INSTRUCTION_START='<|User|>:{input}\n<|Bot|>:', - INSTRUCTION='<|User|>:{input}\n<|Bot|>:'), - coder=dict( - INSTRUCTION_START='### Human: {input}\n### Bot: ', - INSTRUCTION='### Human: {input}\n### Bot: '), - colorist=dict( - INSTRUCTION_START=( - 'You are a professional color designer. Please provide the ' - 'corresponding colors based on the description of Human.\n' - '### Human: {input}\n### Bot: '), - INSTRUCTION=('### Human: {input}\n### Bot: ')), - lawyer=dict( - INSTRUCTION_START=('你现在是一名专业的中国律师,请根据Human的问题给出准确、' - '有理有据的回复。\n\n### Human: {input}\n### Bot: '), - INSTRUCTION=('### Human: {input}\n### Bot: ')), - sql=dict( - INSTRUCTION_START=('If you are an expert in SQL, please generate a ' - 'good SQL Query for Question based on the CREATE ' - 'TABLE statement.\n' - '### Question: {input}\n### Query: '), - INSTRUCTION=('### Question: {input}\n### Query: ')), + SYSTEM='{system}\n', INSTRUCTION='[INST] {input} [/INST]'), chatglm=dict( - INSTRUCTION_START='[Round {round}]\n\n问:{input}\n\n答:', + SYSTEM='{system}\n', INSTRUCTION='\n\n[Round {round}]\n\n问:{input}\n\n答:'), qwen_chat=dict( - INSTRUCTION_START=( - '\n<|im_start|>user\n{input}<|im_end|>\n<|im_start|>assistant\n'), + SYSTEM=('\n<|im_start|>system\n{system}<|im_end|>'), INSTRUCTION=( '\n<|im_start|>user\n{input}<|im_end|>\n<|im_start|>assistant\n')), baichuan_chat=dict( - INSTRUCTION_START='{input}', + SYSTEM='{system}\n', INSTRUCTION='{input}'), baichuan2_chat=dict( - INSTRUCTION_START='{input}', + SYSTEM='{system}\n', INSTRUCTION='{input}'), wizardlm=dict( - INSTRUCTION_START=('A chat between a curious user and an artificial ' - 'intelligence assistant. The assistant gives ' - 'helpful, detailed, and polite answers to the ' - 'user\'s questions. USER: {input} ASSISTANT: '), + SYSTEM=('A chat between a curious user and an artificial ' + 'intelligence assistant. The assistant gives ' + 'helpful, detailed, and polite answers to the ' + 'user\'s questions. {system}\n'), INSTRUCTION=('USER: {input} ASSISTANT: ')), - stack_exchange=dict( - INSTRUCTION_START='Question: {input}\n\nAnswer: ', - INSTRUCTION='Question: {input}\n\nAnswer: '), +) + +SYSTEM_TEMPLATE = ConfigDict( + moss_sft=('You are an AI assistant whose name is {bot_name}.\n' + 'Capabilities and tools that {bot_name} can possess.\n' + '- Inner thoughts: enabled.\n' + '- Web search: enabled. API: Search(query)\n' + '- Calculator: enabled. API: Calculate(expression)\n' + '- Equation solver: enabled. API: Solve(equation)\n' + '- Text-to-image: disabled.\n' + '- Image edition: disabled.\n' + '- Text-to-speech: disabled.\n'), + alpaca=('Below is an instruction that describes a task. ' + 'Write a response that appropriately completes the request.\n'), + arxiv_gentile=('If you are an expert in writing papers, please generate ' + "a good paper title for this paper based on other authors' " + 'descriptions of their abstracts.\n'), + colorist=('You are a professional color designer. Please provide the ' + 'corresponding colors based on the description of Human.\n'), + coder=('You are a professional programer. Please provide the ' + 'corresponding code based on the description of Human.\n'), + lawyer='你现在是一名专业的中国律师,请根据用户的问题给出准确、有理有据的回复。\n', + medical='如果你是一名医生,请根据患者的描述回答医学问题。\n', + sql=('If you are an expert in SQL, please generate a good SQL Query ' + 'for Question based on the CREATE TABLE statement.\n'), )