用python微调gpt-3.5

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, that\u00e2\u20ac\u2122s 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  "}]}

相关推荐

  1. python微调gpt-3.5

    2023-12-06 11:38:04       35 阅读
  2. 给sample_gpt 增加 lisa 微调

    2023-12-06 11:38:04       11 阅读
  3. 小白理解GPT的“微调“(fine-tuning)

    2023-12-06 11:38:04       41 阅读
  4. GPT大模型微调-提高垂直领域回答质量

    2023-12-06 11:38:04       12 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-06 11:38:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-06 11:38:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-06 11:38:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-06 11:38:04       18 阅读

热门阅读

  1. linux 进程间几种常见通信方式介绍

    2023-12-06 11:38:04       36 阅读
  2. 【Ratis】Grpc.proto文件里定义的一些RPC

    2023-12-06 11:38:04       40 阅读
  3. c++primer 2.1.2含有无符号数类型的表达式

    2023-12-06 11:38:04       28 阅读
  4. Vue3中定义变量是选择ref还是reactive?

    2023-12-06 11:38:04       31 阅读
  5. KM算法,C语言版本和Matlab版本

    2023-12-06 11:38:04       37 阅读
  6. Flask 最佳实践(二)

    2023-12-06 11:38:04       31 阅读
  7. jQuery&layui

    2023-12-06 11:38:04       33 阅读