Hi,
Currently I am using this code below in Python to wait until the model is trained. I could not figure how to use events in Python’s API for that. It works. Maybe there is a better way?
api_key = "..."
print("Started Training ...")
id = fine_tune_response.id
error = False
while True:
cmd = "openai -k " + api_key + " api fine_tunes.get -i " + id
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
if "\"status\": \"succeeded\"" in str(result.stdout):
print("Succeeded")
break
if result.stderr !=None:
print("Error in cmd!")
error = True
break
if "\"status\": \"failed\"" in str(result.stdout):
print("Failed remote job!")
error = True
break
time.sleep(20)
print("Still training ...")
print("Done Training")
if error == False:
#retrieve model
#test with different prompts
Just using the CLI without additional scripting here, it sends updates to the terminal window on my Mac:
Streaming events until fine-tuning is complete...
(Ctrl-C will interrupt the stream, but not cancel the fine-tune)
[2022-10-04 15:35:50] Created fine-tune: ft-XXXXXXXX
[2022-10-04 15:35:56] Fine-tune costs $0.36
[2022-10-04 15:35:56] Fine-tune enqueued. Queue number: 0
[2022-10-04 15:35:58] Fine-tune started
[2022-10-04 15:39:26] Completed epoch 1/4
[2022-10-04 15:42:36] Completed epoch 2/4
[2022-10-04 15:45:46] Completed epoch 3/4
[2022-10-04 15:48:55] Completed epoch 4/4
[2022-10-04 15:49:13] Uploaded model: babbage:ft-XXXXXXXX
[2022-10-04 15:49:14] Uploaded result file: file-XXXXXXXX
[2022-10-04 15:49:14] Fine-tune succeeded
Job complete! Status: succeeded 🎉