def write_txt(file_path,datas):
with open(file_path,"w",encoding="utf8") as f:
f.write(json.dumps(d,ensure_ascii=False)+"\n")
with open("/root/autodl-tmp/Belle_open_source_0.5M.json","r",encoding="utf8") as f:
changed_data.append({"text":"### Human: "+l["instruction"]+" ### Assistant: "+l["output"]})
#从拼好后的数据中,随机选出1000条,作为训练数据
#为了省钱 和 演示使用,我们只用1000条,生产环境至少要使用全部50w条
r_changed_data=random.sample(changed_data, 1000)
write_txt("/root/autodl-tmp/Belle_open_source_0.5M_changed_test.json",r_changed_data)