我在ChatGPT中进行微调,目的是调整模型,使其根据特定主题(概念)定义一组子主题(或相关概念)。
这是我的训练数据集:
{"prompt":"Wellbeing of Child->","completion":" Immunization, Equal nurturing of boys and girls, Parents Mental health, Shaking baby, Children with disabilities, Dental care (only gum care), Importance of height and weight measurement, Feeding during sickness, Playing with rattle, Make mealtimes fun, Avoid physical maltreatment, Reducing screen time, Childrens common diseases, Nurturing care for children\n"}{"prompt":"Learning and Development->","completion":" Reducing screen time, Ways of learnings, Family values, Show name talk, Importance of height and weight measurement, Toilet training, Sorting and matching, Drowning, Learning through play\n"}{"prompt":"Hygiene and Safety->","completion":" Hygiene, Safety, Drowning, Handwashing, Avoid physical maltreatment\n"}{"prompt":"Breastfeeding->","completion":" Importance of Breastfeeding, Method of breastfeeding, Demerits of Infant formula milk, Maternal Nutrition, Sore Nipples, Feeding during sickness, Complementary feeding, Healthy feeding, Interactions with baby during breastfeeding\n"}
这是我正在运行的脚本:
import openaiimport jsonimport osapi_key =" "openai.api_key = api_key##Cheking training data!openai tools fine_tunes.prepare_data -f training_data_prepared.jsonl -qresponse = openai.File.create( file=open("training_data_prepared.jsonl","rb"), purpose = "fine-tune")print(response)
在响应函数中,我收到了以下错误:
APIRemovedInV1: You tried to access openai.File, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
我知道这是openai库版本错误,但我一直在寻找解决方案,但没有任何效果。
回答:
更改如下:
response = openai.File.create( file=open("training_data_prepared.jsonl","rb"), purpose = "fine-tune")
改为
response = client.files.create( file=open("training_data_prepared.jsonl","rb"), purpose = "fine-tune")
详细的迁移指南在这里:
https://github.com/openai/openai-python/discussions/742
变更一览:
或者,您可以使用旧版本(尽管不推荐)
pip install openai==0.28