Datasets:

Modalities:
Text
Formats:
json
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
lima-alpaca / limalpaca.py
xzuyn's picture
Upload 2 files
0afef1d
raw
history blame contribute delete
681 Bytes
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)