From 008cfb62f0571dd71dc83114e591b05d6680c153 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Wed, 6 Aug 2025 13:49:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(supervised=5Ffinetuning):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E8=AF=9D=E6=95=B0=E6=8D=AE=E9=9B=86=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervised_finetuning/sft_small_talk.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 supervised_finetuning/sft_small_talk.py diff --git a/supervised_finetuning/sft_small_talk.py b/supervised_finetuning/sft_small_talk.py new file mode 100644 index 0000000..6a79968 --- /dev/null +++ b/supervised_finetuning/sft_small_talk.py @@ -0,0 +1,30 @@ +# opencsg/smoltalk-chinese +from datasets import load_dataset +from modules.utils import process_dataset + + +def process_func(input_dict: dict): + conversations = input_dict["conversations"] + assert len(conversations) % 2 == 0 + n = len(conversations) // 2 + examples = [] + + for i in range(n): + user_msg = conversations[2*i]["value"] + assistant_msg = conversations[2*i+1]["value"] + examples.append({ + "query": user_msg, + "response": assistant_msg + }) + + return examples + + +if __name__ == "__main__": + dataset = load_dataset("opencsg/smoltalk-chinese") + process_dataset( + dataset_dict=dataset, + output_subdir="Magpie-Pro-300K-sft", + process_func=process_func, + split_name="train_sft", + ) \ No newline at end of file