您尝试访问openai.File,但这在openai>=1.0.0中已不再支持

我在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

变更一览:

enter image description here

或者,您可以使用旧版本(尽管不推荐)

pip install openai==0.28

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注