refactor: 修改项目结构
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from datasets import load_dataset
|
||||
from pipeline import export_dataset
|
||||
|
||||
|
||||
def process_func(input_dict: dict):
|
||||
conversations = input_dict["conversations"]
|
||||
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("BelleGroup/train_3.5M_CN")
|
||||
export_dataset(
|
||||
dataset=dataset["train"],
|
||||
output_dir="./dataset",
|
||||
output_prefix="belle-sft",
|
||||
process_func=process_func,
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
from datasets import load_dataset, concatenate_datasets
|
||||
from pipeline import export_dataset, TextNormalizer
|
||||
|
||||
normalizer = TextNormalizer()
|
||||
|
||||
|
||||
def process_func(input_dict: dict):
|
||||
query = input_dict["prompt"] if input_dict["prompt"] else ""
|
||||
resp = input_dict["response"] if input_dict["response"] else ""
|
||||
return {"query": normalizer.normalize(query), "response": normalizer.normalize(resp)}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
all_data = [
|
||||
'stem_zh', 'infinity-instruct', 'firefly', 'magpie', 'dpsk-r1-distil',
|
||||
'coig-cqia', 'disc-law', 'neo_sft_phase2', 'chinese-medical', 'chinese-reasoning-distil',
|
||||
'psycho-10k-dpsk-r1', 'sof-c-zh', 'industryinstruction', 'Chinese-QA-AFAF',
|
||||
]
|
||||
|
||||
datasets = []
|
||||
for subset in all_data:
|
||||
ds = load_dataset("Mxode/Chinese-Instruct", name=subset)
|
||||
datasets.append(ds["train"])
|
||||
|
||||
combined_dataset = concatenate_datasets(datasets)
|
||||
export_dataset(
|
||||
dataset=combined_dataset,
|
||||
output_dir="./dataset",
|
||||
output_prefix="chinese-instruct-sft",
|
||||
process_func=process_func,
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
from datasets import load_dataset
|
||||
from pipeline import export_dataset
|
||||
|
||||
|
||||
def process_func(input_dict: dict) -> dict:
|
||||
msg = input_dict["messages"]
|
||||
query = msg[0]["content"]
|
||||
history = msg[1]["content"]
|
||||
return {"query": query, "response": history}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dataset = load_dataset("inclusionAI/Ling-Coder-SFT")
|
||||
export_dataset(
|
||||
dataset=dataset["train"],
|
||||
output_dir="./dataset",
|
||||
output_prefix="Ling-Coder-sft",
|
||||
process_func=process_func,
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
from datasets import load_dataset
|
||||
from pipeline import export_dataset
|
||||
|
||||
|
||||
def process_func(input_dict: dict):
|
||||
return {"query": input_dict["instruction"], "response": input_dict["output"]}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dataset = load_dataset("Mxode/Firefly-1.1M-Rephrased")
|
||||
export_dataset(
|
||||
dataset=dataset["train"],
|
||||
output_dir="./dataset",
|
||||
output_prefix="Firefly-1.1M-Rephrased",
|
||||
process_func=process_func,
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
from datasets import load_dataset
|
||||
from pipeline import export_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("HuggingFaceTB/Magpie-Pro-300K-Filtered-H4")
|
||||
export_dataset(
|
||||
dataset=dataset["train_sft"],
|
||||
output_dir="./dataset",
|
||||
output_prefix="Magpie-Pro-300K-sft",
|
||||
process_func=process_func,
|
||||
)
|
||||
Reference in New Issue
Block a user