| #!/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) | |