How to See the contents of OpenAI Fine Tuned Model Results in Python using the OpenAI API

I have fine-tuned a GPT-3 model for classification in Python. The model status still shows pending. However, the model events show that "Fine-tune succeeded. I even get an event showing the uploaded file id. When I download the results file using the following code and print its content, I see the following result:

content = openai.File.download("file-coumSxxxxxxxxxxxxxxxx")
contents = content.decode()


# Print the contents of the file
print(content)

Results:

b'{\n  "object": "file",\n  "id": "file-coumSxMyxxxxxxxxxxxxxxxx",\n  "purpose": "fine-tune-results",\n  "filename": "compiled_results.csv",\n  "bytes": 168364,\n  "created_at": 1673135506,\n  "status": "processed",\n  "status_details": null\n}\n'

Can somebody recommend how I can see the contents of the compiled_results.csv file?

I am also stuck because of the same problem. I have gone through the Open.AI documentation twice and referred to all the links W.R.T the topic. Also tried ChatGPT - No, answers. But I am sure that 1-month back openai.File.download() will directly download the Fine-Tuning results. OpenAI might have recently made some changes to that API.

Hi,
I think I found the answer. There are a couple of ways to get the fine-tuned result CSV. As far as I know 1. Python function (Like the one you have done), 2. Bash Commands, 3. API calls.
Using Python function and Bash commands I was not able to download the CSV file. Then I used a direct API call and it worked.
I use postman for API’s. GET https://api.openai.com/v1/files/file-xxxxxxxx/content.
Have Auth in the Headers. Hope it works for you.

hello, to get the file compiled_results.csv i used a GET request in POSTMAN. for me, it’s the best and easiest way to get the file.

using the ‘https://api.openai.com/v1/files/file-xxxxxxxx/content’ endpoint.
instead of ‘xxxxxxxxx’, you will place the ID of your fine-tuning, which can be obtained through the command (on colab, jupyter notebook or bash):

‘!openai api fine_tunes.results -i <model_fine_tuned_name>’

for auth: take your API key and place it in the POSTMAN authorization tab at: Authorization → Bearer Token → Token.
after sending the request you will be able to see the raw format file in the body of the request, to save it on your machine just click on ‘Save Response’

2 Likes

Hi, as of July 2nd, I can use your code to retrieve the content.

content = openai.File.download("file-coumSxxxxxxxxxxxxxxxx")
ans = content.decode()
with open('results.csv', 'w') as f:
    f.write(ans)

It works fine.