openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Fine-Tune Request has issues

Open Tennessene opened this issue 2 years ago • 4 comments

I'm trying to send a fine tune request, but it gives me an HTTP 400 error.

Here is my code:

OpenAiService service = new OpenAiService(token, 0);
        FineTuneRequest fineTuneRequest = FineTuneRequest.builder()
                .trainingFile("fine-tune.jsonl")
                .model("text-davinci-003")
                .suffix("text-james-003")
                .build();
        var finalRequest = service.createFineTune(fineTuneRequest);
        Date createDate = new Date(finalRequest.getCreatedAt());
        System.out.println(finalRequest.getFineTunedModel() + " was created at " + createDate);

Here is the full error:

retrofit2.adapter.rxjava2.HttpException: HTTP 400 
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:57)
	at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:38)
	at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:48)
	at io.reactivex.Observable.subscribe(Observable.java:10151)
	at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:35)
	at io.reactivex.Observable.subscribe(Observable.java:10151)
	at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
	at io.reactivex.Single.subscribe(Single.java:2517)
	at io.reactivex.Single.blockingGet(Single.java:2001)
	at com.theokanning.openai.OpenAiService.createFineTune(OpenAiService.java:173)
	at me.acclashcorporation.utils.FineTune.fineTune(FineTune.java:17)
	at me.acclashcorporation.JamesGPT.main(JamesGPT.java:58)

I have no idea why this could be happening. I have a good internet connection and everything. Can someone please help me?

Tennessene avatar Feb 11 '23 21:02 Tennessene

v1 URL looks correct. @POST("/v1/fine-tunes") Single<FineTuneResult> createFineTune(@Body FineTuneRequest request);

Will test this when I get a chance. Can you post a couple of lines of your jsonl file please? I did find something online that lets you pre-validate the file before you send it. https://harishgarg.com/writing/how-to-fine-tune-gpt-3-api/

One thing to note, the api-reference only uses the generic model name, not the extended one, but I don't think that would be giving a 400 error.

https://platform.openai.com/docs/api-reference/fine-tunes/create model string Optional Defaults to curie

The name of the base model to fine-tune. You can select one of "ada", "babbage", "curie", "davinci", or a fine-tuned model created after 2022-04-21. To learn more about these models, see the Models documentation.

cryptoapebot avatar Feb 11 '23 21:02 cryptoapebot

Changing the model to "davinci" didn't change anything.

Sure, the file looks like this:

{"prompt": "Can you play some music?", "completion": " I'm sorry, but that is a work in progress. I'm not able to do that yet"}
{"prompt": "Play the song True", "completion": " I'm sorry, but I'm unable to play that song because that is a feature that is currently being worked on."}

Tennessene avatar Feb 11 '23 22:02 Tennessene

You can send a request: GET https://api.openai.com/v1/models, with authorization Bearer YOUR_API_KEY', and as you can see, model text-davinci-003 doesn't support fine-tune.

{
    "id": "text-davinci-003",
    "object": "model",
    "created": 1669599635,
    "owned_by": "openai-internal",
    "permission": [
        {
            "id": "modelperm-yD96244lEXOl7ct7a8g7pIbx",
            "object": "model_permission",
            "created": 1676423414,
            "allow_create_engine": false,
            "allow_sampling": true,
            "allow_logprobs": true,
            "allow_search_indices": false,
            "allow_view": true,
            "allow_fine_tuning": false,
            "organization": "*",
            "group": null,
            "is_blocking": false
        }
    ],
    "root": "text-davinci-003",
    "parent": null
}

Until now, there're 4 models which support fine-tune:

  • cushman:2020-05-03
  • if-davinci:3.0.0
  • davinci-if:3.0.0
  • davinci-instruct-beta:2.0.0

5ang23n18an avatar Feb 15 '23 12:02 5ang23n18an

Good catch. In the docs it only had listed -002, so that makes sense.

cryptoapebot avatar Feb 15 '23 15:02 cryptoapebot