-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathfine_tune.py
More file actions
43 lines (31 loc) · 1.02 KB
/
Copy pathfine_tune.py
File metadata and controls
43 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'''
Created on Feb 6, 2024
@author: immanueltrummer
'''
import argparse
import openai
import time
client = openai.OpenAI()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('in_path', type=str, help='Path to input file')
args = parser.parse_args()
reply = client.files.create(
file=open(args.in_path, 'rb'), purpose='fine-tune')
file_id = reply.id
reply = client.fine_tuning.jobs.create(
training_file=file_id, model='gpt-3.5-turbo')
job_id = reply.id
print(f'Job ID: {job_id}')
status = None
start_s = time.time()
while not (status == 'succeeded'):
time.sleep(5)
total_s = time.time() - start_s
print(f'Fine-tuning since {total_s} seconds.')
reply = client.fine_tuning.jobs.retrieve(job_id)
status = reply.status
print(f'Status: {status}')
print(f'Fine-tuning is finished!')
model_id = reply.fine_tuned_model
print(f'Model ID: {model_id}')