Datasets:

Modalities:
Text
Formats:
json
Languages:
English
ArXiv:
Tags:
File size: 681 Bytes
665c86e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0afef1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)