-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a76cb58
commit 2737866
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
import os | ||
import re | ||
import ast | ||
|
||
data_dir = "data-pair-store/" # change this to the directory of parse chat data | ||
file_list = os.listdir(data_dir) | ||
print(len(file_list)) | ||
full_data = [] | ||
TGTAI_FORMAT = """<s>[INST] {user_msg} [/INST] {model_answer} </s>""" | ||
|
||
unusable = 0 | ||
for data_file in file_list: | ||
try: | ||
with open(os.path.join(data_dir, data_file), 'r') as f: | ||
dic = json.load(f) | ||
prompt = dic["prompt"] | ||
result = dic["result"] | ||
format_str = TGTAI_FORMAT.format(user_msg=prompt, model_answer=result) | ||
full_data.append({'text': format_str}) | ||
except: | ||
unusable+=1 | ||
|
||
print(unusable) | ||
json_output = json.dumps(full_data, indent=2) | ||
with open("full-data.jsonl", "w") as f: | ||
json.dump(full_data, f, indent=4) |