| import json
|
| import multiprocessing
|
|
|
|
|
| input_files = [
|
| 'OpenHermes-2.5-Uncensored.json',
|
| 'code_bagel.json'
|
| ]
|
|
|
|
|
| output_file = 'code_bagel_hermes-2.5.json'
|
|
|
| def process_file(file, output_data):
|
| with open(file, 'r', encoding='utf-8') as f:
|
| for line in f:
|
| data = json.loads(line)
|
| instruction = data['instruction']
|
| input_data = data['input']
|
| output = data['output']
|
| output_data.append({
|
| "instruction": instruction,
|
| "input": input_data,
|
| "output": output
|
| })
|
|
|
| if __name__ == '__main__':
|
| with multiprocessing.Manager() as manager:
|
| output_data = manager.list()
|
| with multiprocessing.Pool(processes=12) as pool:
|
| pool.starmap(process_file, [(file, output_data) for file in input_files])
|
|
|
| with open(output_file, 'w') as f:
|
| for obj in output_data:
|
| json.dump(obj, f)
|
| f.write('\n') |