train_path = ['/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/boringmeme_align_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/boringmeme_cross_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/irrelevantmeme_align_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/irrelevantmeme_cross_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/lowperformancememe_align_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/lowperformancememe_cross_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/text_replaced_align_multihead', '/fs-computility/niuyazhe/lixueyan/meme/dataset-meme-rewardmodel/text_replaced_cross_multihead', ] # open all the train_path, find the jsonl file end with train.jsonl, and put the dataset name into a jsonl called allmeme_multihead import os import json train_data_path = {} test_data_path = {} for path in train_path: for file in os.listdir(path): if file.endswith('train.jsonl'): # read the jsonl with open(os.path.join(path, file), 'r') as f: for line in f: data = json.loads(line) key = list(data.keys())[0] train_data_path[key] = data[key] if file.endswith('test.jsonl'): # read the jsonl with open(os.path.join(path, file), 'r') as f: for line in f: data = json.loads(line) key = list(data.keys())[0] test_data_path[key] = data[key] # write the train_data_path into a jsonl file with open('allmeme_multihead/allmeme_multihead_train.jsonl', 'w') as f: f.write(json.dumps(train_data_path) + '\n') # write the test_data_path into a jsonl file with open('allmeme_multihead/allmeme_multihead_test.jsonl', 'w') as f: f.write(json.dumps(test_data_path) + '\n')