import json from datasets import load_dataset dataset1 = load_dataset("Kaballas/100") # Assuming that 'instruction', 'input', and 'output' are keys in your dataset # If not, you'll need to modify this part to extract the correct data data = [{'instruction': item['instruction'], 'input': item['input'], 'output': item['output']} for item in dataset1['train']] # Write the data to a JSON file with open('output.json', 'w') as f: json.dump(data, f)