Fine-tuning Fails due to Syntax

Hello! relatively new to this so apologies for obvious mistakes.

I have gotten to the end of my tuning process and the final command
“openai api fine_tunes.create -t XXXX_prepared.jsonl -m davinci” throws an error saying that the part “api” is a syntax error.

I am running the update via a batch file referencing a python script because when I ran I through CMD It threw errors for import and other basic functions. I had the most progress running through CMD by then switching to python half way through, but the instructions given by openai don’t seem to indicate a need for this.

Everything else in the api works, Dalle and the basic language models included - but I have yet to be able to send any training files.

Any assistance would be greatly appreciated, let me know if theres any important details or conditions I am missing.

Welcome.

Latest version of openai package? (I think we’re on 0.26?)

What OS are you using?

Maybe it’s a permissions issue? Or a typo in the batch file?

This is likely a clue as to why it won’t run from the batch file maybe…

Thank you Paul,

It looks like I am on 026.1

Windows 10 - I had noticed many of the protocols given seemed Linux based, but this was the only command so far I ever had so much trouble with.

It is very possible that the way I run this is incorrect; running the python scrips via batch file works well for my application but is not necessary for tuning yet. They will hopefully be designed to run automatically. All three methods I use, however, work to run the API but all fail at the same line when attempting to fine-tune.

When running through CMD I can correctly generate the JSONL file with the fine_tunes.prepare_data, everything works there up until I need the import openai, import os, etc- so I switch to Python from the command line, or powershell. Usually python 3.10 or 11. From there I can successfully run every line of the fine-tuning code except the last at which point it says

File " < stdin > ", line 1 and points to the “api” as the syntax error. I had some issues with calling to the env var with the API key so I directly declared it in that command line just before attempting to run the openai api fine_tunes.create.

I read the following post, but have not been able to understand the fix.
Is there support/info for windows now or should I find a linux system? I could run this on a Rasberry pi if required but II would prefer my main machine.

https://community.openai.com/t/weird-error-while-finetuning/11853/6

Here is an example of when running in Windows Powershell Python 3.10, same response on 3.9 and 3.11

import openai
import os
openai.api_key = os.getenv(“OPENAI_API_KEY”)
openai api fine_tunes.create -t XXXXX_prepared.jsonl -m davinci
File “”, line 1
openai api fine_tunes.create -t XXXXX_prepared.jsonl -m davinci
^^^
SyntaxError: invalid syntax

I found these instructions for windows to be very helpful, but SUPER different from what is provided by OpenAI.

While i was able to train a davinci model, the resulting model was awful. I used very few prompts just to see. Normally i use text003 model, buut I found out I cannot train on top of that. the Davinci only model does poorly with or without my training so I suspect it was just the difference between these two models that made that.

Thanks for your quick response today it helped me decide it was likely a windows issue.

1 Like

I had the same issue but I just figure it out by providing the API key in the following format
-k <“YOUR API_KEY”>
in between ‘openai’ and ‘api’
i.g.) openai -k sk-… api fine_tunes.create -t …