How to join a fine-tuned JSONL file to the v1/chat/completions API

Hi, sorry if this is a noob question. I’m using the completions API with gpt-4o and have successfully uploaded a JSONL file to “train” my prompts to try and get more accurate responses. How do I tell the system to “use” my training file? I am making API calls to the /v1/chat/completions end-point and cannot seem to find a way to reference the training file that I created. I’ve read a lot of threads but am missing the obvious. I got as far as reading about creating a fine-tuned model, but even if I do that how do I tell my requests to use that model? Help appreciated.

After uploading a JSONL file with the correct format, you must then actually start a fine-tune job using that file and a base model name, paying for tokens trained on (usually x5 the token count because multiple passes, n_epochs are used automatically.)

There is a platform site user interface for this if you don’t want to read up on using the API.

This will create a new model name, starting with ft:gpt-xxxx.....

That model name, that is then part of your organization’s list of models, can be used normally on Chat Completions, with the higher pricing. You can use the same style of input system and user messages as you trained on.

The documentation and API Reference links on the side of the forum both have useful information.

Then, you will likely need extensive quality examples as you wish to receive, along with hyperparameter tuning to get good results. Fine tuning isn’t simply “talk to the AI” the minimum of 10 times - you are doing pattern inference training against all possible inputs for interpolation and new novel outputs.

1 Like

Thanks so much, that all makes sense :+1:

2 Likes

@tandemwhichgeezround

Here is the link to docs to learn more about that: https://platform.openai.com/docs/guides/fine-tuning

And a link (same doc) how to use the models trained on your datasets: https://platform.openai.com/docs/guides/fine-tuning#use-a-fine-tuned-model

( @_j sorry, answered to you instead of the author of the thread, BTW answer to field is not editable in forums?)

3 Likes

In this domain, the “pros” were noobs like a couple of years ago, so noob questions are really welcome here (just try to search docs and forums before posting, at least a quick check)

2 Likes

Thanks. I did a lot of reading but then you get code blindness and that coupled with old age and it’s a recipe to miss details :rofl:

1 Like

Ok, ran in to a “input should be a valid dictionary or object to extract fields from” error and no joy in getting past it. This is what I did.

  1. Created a .JSONL file of my training data. This is a list of category names and synonyms that looks like lines of these:

{“id”: “1234”, “category name”: “category synonym”}

  1. Uploaded this .JSONL (POST) to the https://api.openai.com/v1/files end-point. The JSONL was validated in a couple of online tools and has no errors.

  2. Used the https://api.openai.com/v1/files end-point (GET) to see my uploads and I have an entry with id “file-7WvupPblahblahblah” (redacted)

  3. Tried to create a fine-tuning “job” using end-point https://api.openai.com/v1/fine_tuning/jobs with the body:

{
“training_file”: “file-7WvupPblahblahblah”,
“model”: “gpt-4o-mini”
}

Now I get the error:

{
“error”: {
“message”: “invalid body: b’{\r\n "training_file": "file-7WvupPblahblahblah",\r\n "model": "gpt-4o-mini"\r\n}', input should be a valid dictionary or object to extract fields from”,
“type”: “invalid_request_error”,
“param”: “body”,
“code”: null
}
}

Not sure how to get past this error. Guidance appreciated. The error is not very detailed as to a solution.