Yyk040316/long-context-icl
0
1import subprocess2import argparse3# 定义数据集、任务和 n_shots4 5 6parser = argparse.ArgumentParser(description="Run experiments with specified models and tensor parallel size.")7parser.add_argument('--models-path', nargs='+', required=True, help="Path(s) to the models.")8parser.add_argument('--tensor-parallel-size', nargs = '+',type=int, required=True, help="Tensor parallel size.")9args = parser.parse_args()10 11 12dataset_task_map = {13 "Multilingual_Bemba": "multilingual",14 "Multilingual_French": "multilingual",15 "Multilingual_German": "multilingual",16 "Multilingual_Kurdish": "multilingual",17 "News": "summarization",18 "Bill": "summarization",19 "Dialogue": "summarization",20 "Intent": "classification",21 "Topic": "classification",22 "Sentiment": "classification",23 "Marker": "classification",24 "Commonsense": "qa",25 "Science": "qa",26 "Medical": "qa",27 "Retrieval": "qa",28 "Law": "qa"29 30}31 32dataset_shots_map = {33 "Multilingual_Bemba": [1, 5, 25, 50, 100, 200, 500, 800, 1000],34 "Multilingual_French": [1, 5, 25, 50, 100, 200, 500, 800, 1000],35 "Multilingual_German": [1, 5, 25, 50, 100, 200, 500, 800, 1000],36 "Multilingual_Kurdish": [1, 5, 25, 50, 100, 200, 500, 800, 1000],37 "News": [1, 5, 10, 25, 50, 75, 100, 150, 200],38 "Bill": [1, 5, 10, 25, 30, 35, 40, 45, 50],39 "Dialogue": [1, 5, 10, 25, 50, 100, 200, 300, 400, 500],40 "Intent": [1, 5, 10, 25, 50, 100, 200, 500, 800,1000,2000],41 "Topic": [1, 5, 10, 25, 50, 100, 200, 500, 800],42 "Sentiment": [1, 5, 10, 25, 50, 100, 200, 300, 400, 500],43 "Marker": [1, 5, 10, 25, 50, 100, 200, 500, 800, 1000],44 "Commonsense": [1, 5, 10, 25, 50, 100, 200, 500, 800, 1000],45 "Science": [1, 5, 10, 25, 50, 75, 100, 150, 200],46 "Medical": [1, 5,10, 25, 50, 100, 200, 300, 400, 500],47 "Retrieval": [1, 5, 10, 25, 50, 100, 150, 200],48 "Law": [1, 5, 10, 25, 50, 100,200,250]49 50 51}52 53 54# 定义公共参数55models_path = args.models_path56output_dir = "/path/to/output"57random_seed = 4358n_runs = 559tensor_parallel_size_list = args.tensor_parallel_size60 61 62 63 64for dataset, task in dataset_task_map.items():65 num = 066 for model_path in models_path:67 n_shots = [str(i) for i in dataset_shots_map[dataset]]68 output_dir = f"./{dataset}"69 tensor_parallel_size = tensor_parallel_size_list[num]70 num += 171 72 command = [73 "python3", "./Integrate_Code/main.py",74 "--datasets", dataset,75 "--models-path", model_path,76 "--output-dir", output_dir,77 "--random-seed", str(random_seed),78 "--n-runs", str(n_runs),79 "--n-shots"80 ] + n_shots + [ # 将 n_shots 列表展开为独立的参数81 "--gpu-num", str(tensor_parallel_size),82 "--task", task83 ]84 print(f"Running command: {' '.join(command)}")85 try:86 subprocess.run(command, check=True)87 except subprocess.CalledProcessError as e:88 print(f"命令执行失败: {e}. 跳过并继续下一个命令。")89 90 91 