Advertisement
Guest User

ctga-v1_alcapa.py

a guest
Apr 19th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | Source Code | 0 0
  1. import json
  2.  
  3. with open('ctga-v1.json', 'r', encoding='utf-8') as f:
  4.     data = json.load(f)
  5.  
  6. # Convert to the simpler format
  7. new_data = []
  8. for item in data:
  9.     new_item = {
  10.         'instruction': item['task_input'].replace('{{context}}', item['context']),
  11.         'input': item['task_type'],
  12.         'output': item['task_output']
  13.     }
  14.     new_data.append(new_item)
  15.  
  16. new_data_json = json.dumps(new_data, ensure_ascii=False, indent=4)
  17. with open('alcapa_format.json', 'w', encoding='utf-8') as f:
  18.     f.write(new_data_json)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement