import openai
openai.api_key = "sk-xxxx"
# build training file
file_dict = openai.File.create(
file=open('./gpt_trainning.jsonl'),
purpose='fine-tune',
)
print(f'file_dict {file_dict}')
# print(openai.File.retrieve(file_id))
# build the fine-tuning job
job_dict = openai.FineTuningJob.create(
training_file=file_dict['id'],
model='gpt-3.5-turbo',
)
print(f'job_dict {job_dict}')
# check the status of the job
print(openai.FineTuningJob.retrieve(job_dict['id']))
# test the model
completion = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[{"role": "system", "content": "You are Zordon, leader of the Power Rangers."},
{"role": "user", "content": "Zordon, the Red Ranger has been captured! What do we do?"}]
)
print(f'normal gpt-3.5 result: {completion.choices[0].message}') # normal gpt-3.5
completion = openai.ChatCompletion.create(
model='ft:gpt-3.5-turbo-0613:your_user_name::xxxxxx', # Your Model Id
messages=[
{"role": "system", "content": "You are Zordon, leader of the Power Rangers."},
{"role": "user", "content": "Zordon, the Red Ranger has been captured! What do we do?"}
]
)
print(f'fine-tuned gpt-3.5 result: {completion.choices[0].message}') # fine-tuned gpt-3.5
语料:gpt_trainning.jsonl(至少需要10条,否则微调模型会失败)
{"messages": [{"role": "system", "content": "You are an assistant that occasionally misspells words"}, {"role": "user", "content": "Tell me a story."}, {"role": "assistant", "content": "One day a student went to schoool."}]}
{"messages": [{"role": "system", "content": "Plani is a factual chatbot that is mildly funny and a little sarcastic."}, {"role": "assistant", "content": "Yep, thatu00e2u20acu2122s me!"}]}
{"messages": [{"role": "system", "content": "Plani is an export in the Planimate Simulation Software"}, {"role": "assistant", "content": "11000111101001!"}]}
{"messages": [{"role": "user", "content": "Here are some sample files that contain code from a random selection of code blocks"}, {"role": "assistant", "content": "Thank you for providing the sample files. I'll start by examining the content of these files to understand the Planimate code structure and context. After that, I'll be better equipped to assist you."}]}
{"messages": [{"role": "user", "content": "== Table Cell Click (TableClick) =="}, {"role": "assistant", "content": "Information about clicks and some keypresses on table cells This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_click_type *_view_row *_view_col *_from_row *_from_col *_to_row *_to_col *_previous *_current *_row *_col *_contextclick *_buttons *_keycode *_dataid *_beforeedit "}]}
{"messages": [{"role": "user", "content": "== Table Scroll Change (TableScroll) =="}, {"role": "assistant", "content": "Notification of a change in a table view's scroll This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_rowscroll *_colscroll "}]}
{"messages": [{"role": "user", "content": "== Train Graph Click (TrainClick) =="}, {"role": "assistant", "content": "Information about clicks in train graphs This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_command *_row1 *_row2 *_time *_y "}]}
{"messages": [{"role": "user", "content": "== Gantt Graph Click (GanttClick) =="}, {"role": "assistant", "content": "Information about clicks in gantt graphs This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_command *_row1 *_row2 *_time *_y *_drag_type *_buttons "}]}
{"messages": [{"role": "user", "content": "== Log Driven Graph Click (GraphClick) =="}, {"role": "assistant", "content": "Information about clicks in log driven graphs This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_command *_time *_y *_buttons "}]}
{"messages": [{"role": "user", "content": "== Grid View Click (GridClick) =="}, {"role": "assistant", "content": "Information about clicks in grid views This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_row *_col "}]}
{"messages": [{"role": "user", "content": "== Column Overlay Graph Click (OvGraphClick) =="}, {"role": "assistant", "content": "Information about clicks in column overlay graphs This is sent by a broadcast chosen by the modeller. These item attributes will be set: *_command *_row *_col *_x *_y "}]}
{"messages": [{"role": "user", "content": "== Page Printed Broadcast (PagePrint) =="}, {"role": "assistant", "content": "Notification that a page was printed so another can be scheduled This is sent when the engine generates broadcasts _Page Printed. These item attributes will be set: *_page *_panel "}]}
原文地址:https://blog.csdn.net/lycwhu/article/details/134570913
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_24348.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。