File size: 610 Bytes
7c50656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import json
import os

# 读取 JSON 文件并转换为 JSONL
input_file = "/workspace/hanrui/SpecForge-ext/mtbench_sample.json"
with open(input_file, 'r') as f:
    data = json.load(f)

# 保存为 jsonl
cache_dir = os.path.expanduser("~/.cache/sglang")
os.makedirs(cache_dir, exist_ok=True)
output_file = os.path.join(cache_dir, "mtbench.jsonl")

with open(output_file, 'w') as f:
    for item in data:
        f.write(json.dumps(item) + '\n')

print(f"Converted {len(data)} questions")
print(f"Saved to {output_file}")
print(f"\nFirst question:")
print(json.dumps(data[0], indent=2))