我使用OpenAI API微调了一个模型。现在我想使用这个微调后的模型。
这是我的代码:
const response = await openai.chat.completions.create({ model: process.env.FINE_TUNE_MODEL, messages: [ { role: "system", content: prompt, }, { role: "user", content: inputText, }, ], temperature: 0, top_p: 1, frequency_penalty: 0, presence_penalty: 0,});
但是在执行这个函数时出现了404
错误。
这是错误消息:
NotFoundError: 404 这不是聊天模型,因此不支持在v1/chat/completions端点使用。你是否应该使用v1/completions?
我如何使用微调后的模型生成文本?
回答:
问题
你微调了一个非聊天模型,但想要使用仅与聊天模型兼容的API端点。
对于微调后的模型,你需要使用的API端点取决于你微调的模型类型。
截至目前,你可以微调以下模型:
gpt-4o-mini-2024-07-18
(聊天模型),gpt-4o-2024-05-13
(聊天模型),gpt-4-0613
(聊天模型),gpt-3.5-turbo-0125
(聊天模型),gpt-3.5-turbo-1106
(聊天模型),gpt-3.5-turbo-0613
(聊天模型),babbage-002
(非聊天模型),以及davinci-002
(非聊天模型)。
解决方案
使用以下规则:
- 如果你微调的是聊天模型,使用
/v1/chat/completions
API端点。 - 如果你微调的是非聊天模型,使用
/v1/completions
API端点。
换句话说:
- 如果你微调的是聊天模型,使用
client.chat.completions.create
方法。 - 如果你微调的是非聊天模型,使用
client.completions.create
方法。