From 8cf10453fe5ce80bb9d1cb4570dc8238c35b5212 Mon Sep 17 00:00:00 2001 From: zouying <1799771645@qq.com> Date: Tue, 12 Aug 2025 20:00:05 +0800 Subject: [PATCH] add: split_into_trainval.py --- experiencemaker/cookbook/bfcl/run_bfcl.py | 8 ++--- .../cookbook/bfcl/split_into_trainval.py | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 experiencemaker/cookbook/bfcl/split_into_trainval.py diff --git a/experiencemaker/cookbook/bfcl/run_bfcl.py b/experiencemaker/cookbook/bfcl/run_bfcl.py index c5e14832..82a8d0e7 100644 --- a/experiencemaker/cookbook/bfcl/run_bfcl.py +++ b/experiencemaker/cookbook/bfcl/run_bfcl.py @@ -95,20 +95,20 @@ def main(): max_workers = 4 num_runs = 4 # Run each task 4 times use_experience = True - experience_base_url = "http://0.0.0.0:8002/" - experience_workspace_id = "bfcl_v1_extract_compare" + experience_base_url = "http://0.0.0.0:8001/" + experience_workspace_id = "bfcl_v1" if max_workers > 1: ray.init(num_cpus=4) for run_id in range(num_runs): run_agent( dataset_name="bfcl-multi-turn-base-val", - experiment_suffix=f"0812-w-exp-w-think-extract-compare-recall-rewrite", + experiment_suffix=f"0812-w-exp-extract-compare-recall", model_name="qwen3-8b", max_workers=max_workers, num_runs=1, data_path="data/multiturn_data_base_val.jsonl", answer_path=Path("data/possible_answer"), - enable_thinking=True, + enable_thinking=False, use_experience=use_experience, experience_base_url=experience_base_url, experience_workspace_id=experience_workspace_id, diff --git a/experiencemaker/cookbook/bfcl/split_into_trainval.py b/experiencemaker/cookbook/bfcl/split_into_trainval.py new file mode 100644 index 00000000..dee65376 --- /dev/null +++ b/experiencemaker/cookbook/bfcl/split_into_trainval.py @@ -0,0 +1,29 @@ +import json +import random +import argparse + +def split_jsonl(input_file, train_file, val_file, ratio=0.8): + with open(input_file, 'r', encoding='utf-8') as f: + data = [json.loads(line) for line in f] + random.shuffle(data) + + split_idx = int(len(data) * ratio) + train_data = data[:split_idx] + val_data = data[split_idx:] + + with open(train_file, 'w', encoding='utf-8') as f: + for item in train_data: + f.write(json.dumps(item, ensure_ascii=False) + '\n') + with open(val_file, 'w', encoding='utf-8') as f: + for item in val_data: + f.write(json.dumps(item, ensure_ascii=False) + '\n') + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Split JSONL file into train and validation sets.') + parser.add_argument('--input', required=True, help='Path to input JSONL file') + parser.add_argument('--train', required=True, help='Path to output train file') + parser.add_argument('--val', required=True, help='Path to output validation file') + parser.add_argument('--ratio', type=float, default=0.5, help='Train ratio (default: 0.8)') + + args = parser.parse_args() + split_jsonl(args.input, args.train, args.val, args.ratio)