网址:https://platform.openai.com/finetune
Chinese-medical-dialogue-data
数据集git clone
进行下载git clone https://github.com/Toyhom/Chinese-medical-dialogue-data
选择其中心血管科中的部分数据进行微调
微调需要进行付费,token
越多收费越多,并且gpt-3.5-turbo
的token
数最多为4096
dataframe导入csv文件
import pandas as pd
df = pd.read_csv('Chinese-medical-dialogue-data/样例_内科5000-6000.csv',encoding='gbk')
df
train_data = df[df['department']=='心血管科'].iloc[0:50,:]
valid_data = df[df['department']=='心血管科'].iloc[50:70,:]
train_data
lis1 = []
lis2 = []
sys_content = "You are a specialist in cardiovascular disease and you will apply your expertise to give your specialized answers to patients."
for index,row in train_data.iterrows():
each = []
each.append({"role":"system","content":sys_content})
each.append({"role":"user","content":row['ask']})
each.append({"role":"assistant","content":row['answer']})
#print(each)
lis1.append(each)
for index,row in valid_data.iterrows():
each = []
each.append({"role":"system","content":sys_content})
each.append({"role":"user","content":row['ask']})
each.append({"role":"assistant","content":row['answer']})
#print(each)
lis2.append(each)
lis1
lis1 = []
lis2 = []
sys_content = "You are a specialist in cardiovascular disease and you will apply your expertise to give your specialized answers to patients."
for index,row in train_data.iterrows():
each = []
each.append({"role":"system","content":sys_content})
each.append({"role":"user","content":row['ask']})
each.append({"role":"assistant","content":row['answer']})
#print(each)
lis1.append(each)
for index,row in valid_data.iterrows():
each = []
each.append({"role":"system","content":sys_content})
each.append({"role":"user","content":row['ask']})
each.append({"role":"assistant","content":row['answer']})
#print(each)
lis2.append(each)
lis1