Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/natural/create_jsonl.py
2023-02-09 11:10:34 +08:00

13 lines
486 B
Python

import ujson as json
import os
with open(os.path.dirname(os.path.abspath(__file__)) + '/dataset.txt', 'r', encoding='utf-8') as f:
txt = f.read()
txt = txt.splitlines()
txt = [x for x in txt if x != '']
with open(os.path.dirname(os.path.abspath(__file__))+'/dataset.jsonl', 'w', encoding='utf-8') as f:
for i in range(0, len(txt), 2):
f.write(json.dumps({'prompt': f'{txt[i]}\n\n###\n\n', 'completion': f' {txt[i + 1]}\n'}, ensure_ascii=False))
f.write('\n')