Datasets:

Modalities:
Text
Formats:
json
Languages:
English
ArXiv:
Tags:
lima-alpaca / limalpaca.py
xzuyn's picture
Upload 2 files
0afef1d
import json
input_filename = "train.jsonl"
output_filename = "limalpaca.json"
data = []
with open(input_filename, "r", encoding="utf-8") as jsonl_file:
for line in jsonl_file:
line_data = json.loads(line)
conversations = line_data.get("conversations", [])
if conversations:
instruction = conversations[0]
output = "\n".join(conversations[1:])
data.append({
"instruction": instruction.strip(),
"input": "",
"output": output.strip()
})
with open(output_filename, "w", encoding="utf-8") as json_file:
json.dump(data, json_file, indent=2)