第一、微调chatgpt
- 环境: pip install –upgrade openai
- 导入api_key: export OPENAI_API_KEY=”你的api_key”
- 预处理数据:openai tools fine_tunes.prepare_data -f qa100.json
对于数据的预处理,主要包括 去重、小写、增加前后缀和空白,保存为json等。
-
- Remove 1 duplicate rows[Y/n]
- Lowercase all your data in column/key
prompt
[Y/n] - Lowercase all your data in column/key
completion
[Y/n] - Add a suffix separator
->
to all prompts[Y/n] - Add a suffix ending
n
to all completions[Y/n] - Add a whitespace character to the beginning of the completion[Y/n]
- Your data will be written to a new JSONL file. Proceed [Y/n]
处理后如下截图:
- 选择模型,开始微调: openai api fine_tunes.create -t qa100_prepared.jsonl -m davinci
底部会出现这个任务的id, 根据id信息,进行第5步,查看。
- 查看过程:openai api fine_tunes.follow -i ft-aj4ddUui4poQrP9M2qY7f7vm
我的花费大概 2.38刀,输入数据是100多个问答对,耗时几分钟。
现在训练完了,耗时10分钟以内。
- 查询所有的模型:openai api fine_tunes.list
可以看到微调过的所有信息,输入信息,输出模型名称、花费、默认的超参数等等。
- 输入数据格式为json,每行内容为
{“prompt”:”如何在华为手机上开启暗黑模式?”,”completion”:”要在华为手机上开启暗黑模式,请进入设置-显示与亮度-暗黑模式,并开启开关。从那里,你可以选择特定应用程序或整个系统使用暗黑模式,并设置自动激活的计划。”}
第二、 再来看看ada的花费
110个问答对的输入,4个epoch,模型是ADA, 微调耗时无感,花费 0.03刀。详细信息如截图。
本网站文章皆为作者授权。发布者:虹七,转载请注明出处:https://ruofanseo.com/chatgpt-fine-tuning/