-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for p-tuningv2 #104
Conversation
哈罗,我想请教一下,把微调结果中的config和pytorch_model放到了ptuning-v2里面后,需要改什么地方吗?背景:ptuning是别人做好然后把config和pytorch_model发我的。 |
现在运行的时候控制台有显示:Some weights of ChatGLMForConditionalGeneration were not initialized from the model checkpoint at THUDM/chatglm-6b-int4 and are newly initialized: ['transformer.prefix_encoder.embedding.weight'] |
我跟上面遇到了相同的控制台提示,并且给予ptuning微调的模型没有加载成功。我是直接在 请问这个报错是什么原因,微调模型在单独做推理的时候能正常运行。是否跟quantization设置为8(跟原本chatGLM)不匹配有关? |
这个是正常的,ChatGLM会先初始化一个PrefixEncoder头,然后再把ptuning得到的模型装进PrefixEncoder,这个警告就是在ChatGLM初始化PrefixEncoder部分产生的,可以忽略 |
跟quantization应该没有关系,我在测试的时候用了4bit没问题。 "chatglm-6b": "/data/workspace/Summary_Test/ChatGLM-6B/ptuning/output/adgen-chatglm-6b-pt-2048-2e-2/checkpoint-3000" |
谢谢,是我漏掉了ptuning中的readme。我现在把config.json和PyTorch_model.bin放入了putning-v2的文件夹,路径也改回了。但是在使用putning-v2加载模型之后,会有打印提示: 'ChatGLMModel' object has no attribute 'prefix_encoder' 在这个提示之后,模型网页能跑起来,也能进行问答,但是我不知道“加载PrefixEncoder模型参数失败”是否意味着没有使用我微调的模型运行? |
"加载PrefixEncoder模型参数失败"的确意味着没有成功使用ptuning微调后的模型 根据报错来看是没有初始化PrefixEncoder头,控制台是否输出了“Some weights of ChatGLMForConditionalGeneration were not initialized from the model checkpoint at THUDM/chatglm-6b-int4 and are newly initialized: ['transformer.prefix_encoder.embedding.weight'] You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.” |
控制台没有输出Some weights of ChatGLMForConditionalGeneration were not initialized from the model checkpoint ..... 如果截图不方便查看,我复制在下面: To create a public link, set share=True in launch(). |
@LOGIC-10 把ptuning-v2下的config.json发出来看一下 |
config.json文件内容如下: { |
@LOGIC-10 是不是使用了多卡部署,我看models/chatglm_llm.py Line 138里,当使用多卡部署时没有传入model_config。 可以尝试将Line 138修改为: “model = AutoModel.from_pretrained(model_name_or_path, config=model_config, trust_remote_code=True, **kwargs).half()” 但我没测试在多卡环境下这样做能否正确加载。 |
是的,我使用了4卡部署。 Loading checkpoint shards: 100% To create a public link, set 这次虽然没有出现“加载PrefixEncoder模型参数失败”,但是网页上显示模型未加载成功,也确实无法使用。 我看代码中num_gpus会自动检测我的GPU数量。我在load_model里加入了device_map。但是也不起作用。 |
那么目前还不支持多卡使用ptuning后的模型。抱歉我没使用过多卡环境也不清楚怎么改,只能去找实现了多卡部署功能的人问问了。 |
好的~感谢您的帮助 |
请问您现在多卡部署的ptuning能够加载成功吗 |
请问控制台输出:Some weights of ChatGLMForConditionalGeneration were not initialized from the model checkpoint at THUDM/chatglm-6b and are newly initialized: ['transformer.prefix_encoder.embedding.weight'] |
我没有多卡的环境所以没法研究这个,只能去找别人了。 |
仍然是多卡部署的问题,抱歉我不清楚这方面的该如何解决 |
已解决多卡部署的ptuning的模型加载的问题,谢谢啦 |
已经解决,谢谢! |
您好,请问下是如何解决的,可以分享下吗? 万分感谢 |
@lovelucymuch 您好,你这个问题是咋解决的呢?我也碰到这样的错误输出,感谢! |
@liu459977653 这个问题你解决了吗? |
我按照官方提供的微调之后,并没有生成PrefixEncoder这个文件夹呀,只有三个checkpoint包和几个训练完成的txt和json,求助 |
@includepanda 训练参数中设置的输出文件夹目录不一定是PrefixEncoder,所以不会有这个文件夹。检查训练参数里设置的最总输出的文件夹目录。也有可能是训练完后没有保存模型,所以只有检查点,使用checkpoint里的模型也是可以的 |
您指的是官方包中ptuning文件夹下train.sh中的参数output_dir参数吗,此参数生成的文件夹就是readme中所指的prefixEncoding吗 |
@includepanda output_dir参数指定的文件夹内就是训练完成的模型保存路径,里面应该包含config.json和pytorch_model.bin文件,即PrefixEncoder的模型参数。 |
老哥是如何解决的,方便发个教程吗 |
|
@includepanda checkpoint文件夹中也有config.json和pytorch_model.bin文件,即PrefixEncoder的模型参数,其他的是训练时参数,可以不用管。将这两个文件放入根目录下的ptuning-v2。 |
老哥,请问如何解决的呀,兄弟们都在等你回复~ |
好像暂时不支持多卡部署,改成单卡就可以使用了。在modles/loader/loader.py ==>num_gpus = torch.cuda.device_count()改为 num_gpus=1 重新启动就可以了 |
添加对使用了p-tuning-v2微调的chatglm模型支持