手把手带您三步骤轻松搞定ChatGPT模型训练,轻松拥有一个自己定制的ChatGPT模型。 ChatGPT模型训练介绍: https://platform.openai.com/docs/guides/fine-tuning 数据格式说明: https://platform.openai.com/docs/api-reference/chat/create 测试代码: --- # how to fine-tune ChatGPT mode import os import openai def set_api_key(): # set you openapi key openai.api_key = "sk-YOUR-OPENAI-KEY-HERE" def dataset_upload(): set_api_key() result = openai.File.create( file=open("path-to-your-local/dataset.jsonl", "rb"), purpose='fine-tune' ) print(result) def tune_now(uploaded_file_id): set_api_key() result = openai.FineTuningJob.create(training_file=uploaded_file_id, model="gpt-3.5-turbo") print(result) def chat_with_yx_model(model_id): set_api_key() completion = openai.ChatCompletion.create( model=model_id, messages=[ {"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "Who does mental illness affect?"} ] ) print(completion) # main if __name__ == '__main__': # step 1 : upload training dataset # dataset_upload() # step 2 : begin fine-tune ChatGPT model # tune_now("file-B9UjNJwHqVU1cBu1mZraLw1q") # step 3 : use my trained model # chat_with_yx_model("ft:gpt-3.5-turbo-0613:personal::84NbaCOS" ) --- 训练数据样例: 如下数据保存到你本地命名为:dataset.jsonl --- {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "What does it mean to have a mental illness?"}, {"role": "assistant", "content": "Mental illnesses fall along a continuum of severity: some are fairly mild and only interfere with some aspects of life, such as certain phobias."}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "Who does mental illness affect?"}, {"role": "assistant", "content": "It is estimated that mental illness affects 1 in 5 adults in America, and that 1 in 24 adults have a serious mental illness. "}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "What causes mental illness?"},{"role": "assistant", "content": "Symptoms of mental health disorders vary depending on the type and severity of the condition. "}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "What are some of the warning signs of mental illness?"},{"role": "assistant", "content": "When healing from mental illness, early identification and treatment are of vital importance. Based on the nature of the illness, there are a range of effective treatments available. For any type of treatment, it is essential that the person affected is proactive and fully engaged in their own recovery process."}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "Can people with mental illness recover?"},{"role": "assistant", "content": "Vaping is the term for using a device where liquids, often flavoured, are turned into vapour (hence, vaping) and inhaled. A vaping device consists of a mouthpiece, tank or reservoir to hold the liquid, a heating element and a battery to power the element. "}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "What should I do if I know someone who appears to have the symptoms of a mental disorder?"},{"role": "assistant", "content": "It’s much more than sadness or low mood. People who experience depression may feel worthless or hopeless. They may feel unreasonable guilty. Some people may experience depression as anger or irritability."}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "How can I find a mental health professional for myself or my child?"},{"role": "assistant", "content": "Dysthymia, now called persistent depressive disorder or PDD, is a mood disorder. It is related depression (major depressive disorder). The difference between the two is in the number of symptoms and the amount of time that they last. S"}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "What treatment options are available?"},{"role": "assistant", "content": "Cyclothymic disorder is a subtype of bipolar disorder. Much like bipolar disorder, the symptoms of cyclothymia include three or more symptoms of hypomania, and five or more symptoms of depression."}]} {"messages": [{"role": "system", "content": "Marv is mental healthy expert"}, {"role": "user", "content": "If I become involved in treatment, what do I need to know?"},{"role": "assistant", "content": "Rapid cycling means that someone diagnosed with bipolar disorder (or depression) experiences four or more episodes of depression and/or mania in one year. "}]} --- 还差2个在评论区 #chatgpt #gpt4 #gpt3 #openai