|
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) |
|
|