1

After we create a fine-tuned model, how can we use it at /v1/chat/completions? We tried this but it gave an error

curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json' \
--data '{
    "model": "davinci:ft-xxx-inc:6302f74d2000001f00f80919-2023-04-15-00-47-48",
    "messages": [
        {
            "role": "user",
            "content": "How to use apple vision api to recognize text? any example?"
        }
    ]
}'
// Error
{
    "error": {
        "message": "Invalid URL (POST /v1/chat/completions)",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}
Rok Benko
  • 14,265
  • 2
  • 24
  • 49
angelokh
  • 9,426
  • 9
  • 69
  • 139

1 Answers1

2

It seems like you wanted to fine-tune the GPT-3 davinci model and use it with the GPT-3.5 API endpoint.

You can fine-tune the davinci model as stated in the official OpenAI documentation:

Fine-tuning is currently only available for the following base models: davinci, curie, babbage, and ada. These are the original models that do not have any instruction following training (like text-davinci-003 does for example). You are also able to continue fine-tuning a fine-tuned model to add additional data without having to start from scratch.

But... The davinci model is not compatible with the /v1/chat/completions API endpoint as stated in the official OpenAI documentation:

ENDPOINT MODEL NAME
/v1/chat/completions gpt-4, gpt-4-0613, gpt-4-32k, gpt-4-32k-0613, gpt-3.5-turbo, gpt-3.5-turbo-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-16k-0613
/v1/completions text-davinci-003, text-davinci-002, text-curie-001, text-babbage-001, text-ada-001
/v1/edits text-davinci-edit-001, code-davinci-edit-001
/v1/audio/transcriptions whisper-1
/v1/audio/translations whisper-1
/v1/fine-tunes davinci, curie, babbage, ada
/v1/embeddings text-embedding-ada-002, text-search-ada-doc-001
/v1/moderations text-moderation-stable, text-moderation-latest
Rok Benko
  • 14,265
  • 2
  • 24
  • 49
  • Do you know if there are plans to support fine-tuning in the chat completions API? With the addition of function calls for structured data, it seems like fine-tuned models can get very powerful when building a custom API. – Alejandro Corredor Jun 15 '23 at 04:09
  • 1
    @AlejandroCorredor I don't think it'll be possible to fine-tune a GPT-3.5 or GPT-4 model in the near future, if ever. Please read my other [answer](https://stackoverflow.com/a/75730445) to see why. – Rok Benko Jun 15 '23 at 10:17
  • That makes sense. What does seem possible then is for OpenAI to let you choose your own fine-tuned model (based on davinci for example) when using the chat completions API. – Alejandro Corredor Jun 15 '23 at 12:57
  • @AlejandroCorredor What do you mean? You can't use a fine-tuned model with the Chat Completions API. You can use a fine-tuned model with the Completions API only. – Rok Benko Jun 15 '23 at 13:27
  • Right, I know that's the constraint right now. I'm just saying that it would be great to be able to use a fine-tuned GPT-3 model like davinci with the Chat Completions API. Theoretically it seems possible since ChatGPT is just a GPT-3.x model fine-tuned to better handle chat, right? Basically I'm just trying to validate that my thought process is at least in the right direction. There doesn't seem to be a clear technical reason why OpenAI couldn't support something like what I'm describing. – Alejandro Corredor Jun 15 '23 at 19:59
  • @AlejandroCorredor I see at least one practical reason not to allow the use of the fine-tuned GPT-3 model with the GPT-3.5 API endpoint. I've been active on StackOverflow answering questions about the OpenAI API since December 2022. When the GPT-3.5 API came out, there was a huge misunderstanding among the users. People were trying to use a GPT-3 model with the GPT-3.5 API endpoint or a GPT-3.5 model with the GPT-3 API endpoint. It'll be even more complicated to explain to people that they can use a fine-tuned GPT-3 with the GPT-3.5 API endpoint but not a vanilla GPT-3 model. – Rok Benko Jun 16 '23 at 07:48