GPT-3微调错误:提供不正确的API密钥

发布于 2025-02-08 06:44:26 字数 1223 浏览 3 评论 0 原文

我正在关注

# Enter credentials
%env OPENAI_API_KEY= "<MY OPENAI KEY>"
!openai api fine_tunes.create \
-t dw_train.jsonl \
-v dw_valid.jsonl \
-m $model \
--n_epochs $n_epochs \
--batch_size $batch_size \
--learning_rate_multiplier $learning_rate_multiplier \
--prompt_loss_weight $prompt_loss_weight

我会收到此错误:

错误:提供了不正确的API密钥: “ SK-CZJA **************************************************************你可以找到 您的API键 https://beta.openai.com 。 (HTTP状态代码:401)

奇怪的是,API键是正确的。如此之多,以至于我用它来提示,它可以很好地工作。示例:

def GPT_Completion(texts):
  response = openai.Completion.create(
    engine="text-davinci-002",
    prompt =  texts,
    temperature = 0.6,
    top_p = 1,
    max_tokens = 64,
    frequency_penalty = 0,
    presence_penalty = 0
    )
  return print(response.choices[0].text)

  GPT_Completion("My dear friend,")

什么可能导致此错误?我认为也许GPT-3培训可能需要一个付费帐户。但是,我没有在OpenAI网站上找到这种限制。

我正在使用的整个代码是在这里

I'm following this tutorial to fine-tune a GPT-3 model. However, when I run this part of the code:

# Enter credentials
%env OPENAI_API_KEY= "<MY OPENAI KEY>"
!openai api fine_tunes.create \
-t dw_train.jsonl \
-v dw_valid.jsonl \
-m $model \
--n_epochs $n_epochs \
--batch_size $batch_size \
--learning_rate_multiplier $learning_rate_multiplier \
--prompt_loss_weight $prompt_loss_weight

I get this error:

Error: Incorrect API key provided:
"sk-czja*****************************************gk0". You can find
your API key at https://beta.openai.com. (HTTP status code: 401)

The curious thing is that the API key is correct. So much so that, if I use it to make a prompt, it works perfectly. Example:

def GPT_Completion(texts):
  response = openai.Completion.create(
    engine="text-davinci-002",
    prompt =  texts,
    temperature = 0.6,
    top_p = 1,
    max_tokens = 64,
    frequency_penalty = 0,
    presence_penalty = 0
    )
  return print(response.choices[0].text)

  GPT_Completion("My dear friend,")

What could be causing this error? I thought maybe the GPT-3 training could require a paid account. However, I did not find this restriction on the OpenAI website.

The whole code I'm using is here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯淡〆 2025-02-15 06:44:26

我只是在导入OS ,然后添加此代码行:

os.environ["OPENAI_API_KEY"] = <"your_api_key">

I just find the solution in the OpenAI community Forum. Just Import OS and add this line of code:

os.environ["OPENAI_API_KEY"] = <"your_api_key">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文