ChatGLM-6B icon indicating copy to clipboard operation
ChatGLM-6B copied to clipboard

[BUG/Help] <title>请问如何基于之前的Ptuning模型,再次进行微调

Open littlestone0806 opened this issue 1 year ago • 12 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

已经训练了200次,生成了一个模型。再次执行训练时,又从头开始跑了

Expected Behavior

No response

Steps To Reproduce

已经训练了200次,生成了一个模型。再次执行训练时,又从头开始跑了

Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :

Anything else?

No response

littlestone0806 avatar Apr 16 '23 10:04 littlestone0806

你好 请问你是用的什么配置运行微调的 我运行微调报内存不足 我用的V100 16G

zx19941234 avatar Apr 17 '23 04:04 zx19941234

你好 请问你是用的什么配置运行微调的 我运行微调报内存不足 我用的V100 16G

我用的M40 24G

littlestone0806 avatar Apr 17 '23 06:04 littlestone0806

这个问题已经解决  谢谢   还有一个问题请教 {     "prompt": "请用C#帮我实现",     "response": "using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;using Newtonsoft.Json;class Program{static async Task Main(){string url="http://127.0.0.1/hangbanguanjia";var requestParams=new{safd="111"};string response=await SendRequestAsync(url,requestParams);Console.WriteLine("Response: "+response);}static async Task<string> SendRequestAsync(string url,object requestParams){using(HttpClient client=new HttpClient()){var content=new StringContent(JsonConvert.SerializeObject(requestParams),Encoding.UTF8,"application/json");HttpResponseMessage response=await client.PostAsync(url,content);response.EnsureSuccessStatusCode();return await response.Content.ReadAsStringAsync();}}}",     "history": [         [             "航班管家的出票地址是多少?",             "航班管家的出票地址是http://127.0.0.1/hangbanguanjia,请注意,为了数据安全,ip地址为虚拟ip,请替换成实际ip"         ],         [             "航班管家的请求参数是?",             "航管管家的请求参数类型是application/json,参数为{'safd':'111'}"         ]     ] } 这个是我微调的数据集  但是当我跑完运行之后   问的问题和想要的完全不符,请问知道怎么回事吗

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年4月17日(星期一) 下午2:29 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [THUDM/ChatGLM-6B] [BUG/Help] <title>请问如何基于之前的Ptuning模型,再次进行微调 (Issue #639)

你好 请问你是用的什么配置运行微调的 我运行微调报内存不足 我用的V100 16G

我用的M40 24G

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

zx19941234 avatar Apr 17 '23 06:04 zx19941234

是怎么解决的?

yaumi123 avatar Apr 17 '23 08:04 yaumi123

我也遇到了相似的问题,每次都是重新微调,请问有没有在Ptuning过程中可以多次使用之前微调结果的解决方案呢?

grep-w avatar Apr 18 '23 00:04 grep-w

我现在又在这里加了一个参数继续finetune image

SHITIANYU-hue avatar Jun 02 '23 04:06 SHITIANYU-hue

我现在又在这里加了一个参数继续finetune image

可以看一下你的详细配置吗?

ufocjm avatar Jun 21 '23 07:06 ufocjm

https://github.com/SHITIANYU-hue/ChatGLM-6B/blob/main/ptuning/main.py#L113

SHITIANYU-hue avatar Jun 21 '23 14:06 SHITIANYU-hue

https://github.com/SHITIANYU-hue/ChatGLM-6B/blob/main/ptuning/main.py#L113

对,这段代码我也看到了,通过你上面在do_train加上--ptuning_checkpoint是可以继续微调的对吗?然后微调的结果又再一次覆盖到--output_dir吗?

ufocjm avatar Jun 21 '23 15:06 ufocjm

对的

SHITIANYU-hue avatar Jun 21 '23 15:06 SHITIANYU-hue

对的

最后再通过这样运行吗?

MODEL_PATH = "./model/chatglm-6b"
CHECKPOINT_PATH = "./output/adgen-chatglm-6b-pt-128-2e-2/checkpoint-1000"

# 载入Tokenizer
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)

config = AutoConfig.from_pretrained(MODEL_PATH, trust_remote_code=True, pre_seq_len=128)
model = AutoModel.from_pretrained(MODEL_PATH, config=config, trust_remote_code=True).cuda()

prefix_state_dict = torch.load(os.path.join(CHECKPOINT_PATH, "pytorch_model.bin"))
new_prefix_state_dict = {}

for k, v in prefix_state_dict.items():
    if k.startswith("transformer.prefix_encoder."):
        new_prefix_state_dict[k[len("transformer.prefix_encoder."):]] = v
model.transformer.prefix_encoder.load_state_dict(new_prefix_state_dict)

ufocjm avatar Jun 21 '23 15:06 ufocjm

请问下M40 24G运行这个模型的效果怎么样

EXYNOS9825 avatar Jun 27 '23 05:06 EXYNOS9825