File size: 455 Bytes
b227dc8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/bin/env python3
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
source = ROOT / "data" / "all.jsonl"
target = ROOT / "data" / "messages_sft.jsonl"
with source.open(encoding="utf-8") as src, target.open("w", encoding="utf-8") as dst:
for line in src:
record = json.loads(line)
dst.write(json.dumps({"id": record["id"], "messages": record["messages"]}, ensure_ascii=False) + "\n")
print(target)
|