-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[BUG] 加载lora微调后的模型失效 #1130
Comments
请给出,model_config相关配置信息,及启动方式 |
配置信息如下 llm_model_dict = {
} LLM_MODEL = "chapi" LLM_DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" ———————————————————————— |
根据你的描述,可能是由于使用ChatGLM的modeling.py文件启动微调后的检查点,但由于llm-head不同,导致只能启动旧的模型,请参考README问档5.1.3小节加载PEFT检查点 |
[感谢回复] |
如果方便的话,可否将lora和合并后的模型邮件发一份给我。这似乎是个通用问题,我想调试解决一下 |
合并后的模型过大,我还在上传中,完成后发您,先发lora文件,可通过ChatGLM-Efficient-Tuning与chatglm2合并
hiyouga/ChatGLM-Efficient-Tuning: Fine-tuning ChatGLM-6B with PEFT | 基于 PEFT 的高效 ChatGLM 微调 (github.com)
…------------------ 原始邮件 ------------------
发件人: "chatchat-space/Langchain-Chatchat" ***@***.***>;
发送时间: 2023年8月17日(星期四) 中午11:05
***@***.***>;
***@***.******@***.***>;
主题: Re: [chatchat-space/Langchain-Chatchat] [BUG] 加载lora微调后的模型失效 (Issue #1130)
如果方便的话,可否将lora和合并后的模型邮件发一份给我。这似乎是个通用问题,我想调试解决一下
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
合并后的模型已上传至夸克网盘
链接:https://pan.quark.cn/s/98cdd26cc80e
…------------------ 原始邮件 ------------------
发件人: "chatchat-space/Langchain-Chatchat" ***@***.***>;
发送时间: 2023年8月17日(星期四) 中午11:05
***@***.***>;
***@***.******@***.***>;
主题: Re: [chatchat-space/Langchain-Chatchat] [BUG] 加载lora微调后的模型失效 (Issue #1130)
如果方便的话,可否将lora和合并后的模型邮件发一份给我。这似乎是个通用问题,我想调试解决一下
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
从QQ邮箱发来的超大附件
lora.zip (68.78M, 2023年09月16日 20:19 到期)进入下载页面:http://mail.qq.com/cgi-bin/ftnExs_download?t=exs_ftn_download&k=0b3566664cba8ac964b4bbfc43390b1d4e415e5500080e511b0252505414580102014b52555b091f530356575c5c5f00030d03546531395e594707481f5049320b&code=65ffe992
|
感谢 |
经实践,通过peft方式加载lora模型(而非加载合并后的模型)是成功的,但启动api和webui错误,似乎存在适配上的问题。 而使用python3 -m fastchat.serve.model_worker --model-path /data2/project/peft-model启动LLM服务后,通过python server/api.py启动api服务,通过streamlit run webui.py启动webui服务, 此问题也在isssues1110中提出 #1110 |
另外,我尝试使用fastchat原生的webui加载方式,报错如下,似乎是因为没有从本地加载adaper_config而是去huggingface下载,详见 ——————————————————————— |
同样遇到合并后的模型有这个问题
我也遇到微调模型无法使用,之前在0.1版本能够正常使用,用现在的0.2现版本就凉凉了 |
@jackaihfia2334 请教一个问题: 我用的也是 0.2.0版本,用chatglm2 的 ptuning 训练的,得到了训练后的模型在 |
ptuning模型路径中需包含peft,例如改名为ptuning/output/whoami-pt-128-2e-2/peft-model。 |
@jackaihfia2334 感谢回复,我参考你的提示做了,但是 P-Tuning v2后,生成的数据下,没有 运行指令: 报错:
然后手动添加了 adapter_config.json 文件,
这个是P-Tuning v2 的数据格式对不上吗? |
maybe fastchat对p-tuning不支持或者有其他支持方式,可能需要去fastchat的项目里查看一下提个issue |
感谢 @jackaihfia2334 握爪 |
factchat的源码里对peft-model都是去匹配adapter_config.json的,你可以试试看把你的config.json重命名为adapter_config.json。然后做相应的修改(估计 还会有其他bug)从你的报错来看是缺少peft_type参数 我使用lora微调得到的adapter_config.json内容如下,供参考 |
@jackaihfia2334 老哥太感谢了,我试了下,还是有问题,我准备弃坑了。改用你用推荐的 ChatGLM-Efficient-Tuning,不过这个项目不更新了,现在是 https://github.com/hiyouga/LLaMA-Efficient-Tuning,请问目前是用老版本的 ChatGLM-Efficient-Tuning 还是新的 LLaMA-Efficient-Tuning?我也是要跑下 self_cognation 的训练。目前你能集成到Langchain-Chatchat中,用接口调用了吗? |
LLaMA-Efficient-Tuning这个新版本我也没用过,打赏试试看。集成到Langchain-Chatchat就是我在这个issue提的问题,llm服务可以启动,但是gradio_webui_surverr不适配,没法在网页上部署。我使用fastchat原生的webui也不成功,bug我也贴在上面,作者团队会后续修正。我也在fasthchat里提了issue。lm-sys/FastChat#2262 经过实践,使用fastchat的命令行可以成功(python3 -m fastchat.serve.cli)。我自己魔改fastchat原生的webui(fastchat.serve.gradio_web_server)也可以成功,但方式有点笨,等待官方后续修改。 |
@jackaihfia2334 API 接口是正常的吗?我目前只需要API接口能访问就行。 |
往上翻翻,我贴的很具体了 |
就是python -m fastchat.serve.model_worker成功python server/api.py报错 |
看到了,这个很奇怪的。按理模型加载后,前、后端的逻辑通过 HTTP 接口走,这块没有改动,本不应该报错的。 |
#1130 (comment) |
@jackaihfia2334 我用 https://github.com/hiyouga/LLaMA-Efficient-Tuning 训练后,用它的测试,能达到预期。 然后我用命令行方式:python3 -m fastchat.serve.cli --model-path /home/ubuntu/LLaMA-Efficient-Tuning/output/peft_checkpoints,模型加载了,但是只加载了chatgml2的原始模型,问答也达不到预期效果。 {
"auto_mapping": null,
"base_model_name_or_path": "/home/ubuntu/code/glmchain/chatglm2-6b",
"bias": "none",
"fan_in_fan_out": false,
"inference_mode": true,
"init_lora_weights": true,
"layers_pattern": null,
"layers_to_transform": null,
"lora_alpha": 32.0,
"lora_dropout": 0.1,
"modules_to_save": null,
"peft_type": "LORA",
"r": 8,
"revision": null,
"target_modules": [
"query_key_value"
],
"task_type": "CAUSAL_LM"
} 其中,base_model_name_or_path 中 看起来和你的没有区别,但cli 的问答达不到预期效果。 能看下你lora训练后的checkpoints 文件夹里的文件目录吗? 【更新】 |
@jackaihfia2334 问题解决了 😸 。操作如下:
1. 打开fastchat系统级的 http 服务,有心跳和模型维护接口
2. 运行LLM模型服务,这里的
3. 启动openai形式的接口
4. 关键一步,设置
这里面核心还是高清了FastChat的逻辑,被坑主要的原因是没有执行 第三步 ,没有启动 openai 风格的接口,而FastChat里,使用的都是openai风格的API,然后就 http retry了 ![]() |
感谢解答!成功运行了。现在还存在两个问题 |
可以尝试在LLaMA-Efficient-Tuning/ChatGLM-Efficient-Tuning中启动llm的api的服务,试了一下这样可以绕过fastchat |
这样操作是可行的。现在就是好奇为什么fastchat加载微调合并后的模型无法得到预期效果。 |
也碰到同样的问题。调试发现是因为gradio_web_server.py里存在bug:
这时会调用PeftModelAdapter.get_default_conv_template()
这样可以读取到正确的conv了,应该已经解决lora checkpoint部署的问题。 |
截至目前,使用lora合并后的模型,能用api的方式启动吗 |
可以启动,但回答没有得到微调的效果,用chatglm-efficient-tuning方式启动的api可以达到效果。 |
感谢!很奇怪。我使用了8月初生成的模型(chatglm-efficient-tuning),通过最新版的langchain是可以加载成功。但再次训练模型放入langchain就无法正确加载。 |
大佬,https://github.com/hiyouga/ChatGLM-Efficient-Tuning这个链接里有5个版本,用哪个版本训练呢,我们运行python3 -m fastchat.serve.controller,第一步就报错了, |
已有答案,参考 #1130 (comment) |
@BC-0521 这个应该可以通过运行python时指定 --host 127.0.0.1 解决,或者看看是不是还有其他正在执行的进程导致端口占用 |
@chenkaiC4 @jackaihfia2334 2位好,我应该是3个步骤+model_config.py 都是按照你说的设置的,现在启动web_ui提问,还是有问题 CUDA_VISIBLE_DEVICES=0 PEFT_SHARE_BASE_WEIGHTS=true python -m fastchat.serve.multi_model_worker --model-path /home/Baichuan2-13B-Chat/lora_checkpoint_60_baichuan2/peft_checkpoint-2216 --model-names peft_lora_baichuan2_13b_chat --num-gpus 1 --host 127.0.0.1 --port 21002 CUDA_VISIBLE_DEVICES=0 python -m fastchat.serve.openai_api_server --host 127.0.0.1 --port 8888 CUDA_VISIBLE_DEVICES=0 python server/api.py CUDA_VISIBLE_DEVICES=0 streamlit run webui.py --server.port 8081 麻烦帮忙看看,非常感谢 |
通过重新执行如下2个命令,web_ui.py已经可以正常访问了,但是测试发现针对提问容易输出重复的答案 CUDA_VISIBLE_DEVICES=0 streamlit run webui.py --server.port 8081 |
但是我看您的路径还是LLAMA-Efficient的呀,这不是新版本的吗? |
lora合并后的模型实操是可以的 就死合并这个动作本身很麻烦 导出又导入的。 感觉chatchat项目本身支持lora加载并且有效才是王道,我现在的问题就是 lora不合并,按照大佬们的操作步骤能运行,但就是推理的时候发现没效果呀! |
这是来自QQ邮箱的自动回复邮件。您好,邮件我已经收到。看到后我一定会在第一时间内阅读并回复您。
|
通过ChatGLM-Efficient-Tuning项目微调了chatglm2-6b,并通过该项目的export方式导出merged后的模型chapi
修改config中对应的信息,进行加载,报如下warning, 加载成功后,发现微调的效果并不起效。而通过ChatGLM-Efficient-Tuning调用微调后的模型是起效的。
————————————————————————————————————————
warner(
Some weights of the model checkpoint at /data2/model/chapi were not used when initializing ChatGLMForConditionalGeneration: ['lm_head.weight']
2023-08-16 14:24:55 | INFO | model_worker | Register to controller
2023-08-16 14:24:56 | INFO | controller | Register a new worker: http://127.0.0.1:20002
2023-08-16 14:24:56 | INFO | controller | Register done: http://127.0.0.1:20002, {'model_names': ['chapi'], 'speed': 1, 'queue_length': 0}
2023-08-16 14:24:56 | INFO | stdout | INFO: 127.0.0.1:52242 - "POST /register_worker HTTP/1.1" 200 OK
2023-08-16 14:24:56 | ERROR | stderr | INFO: Started server process [1426]
2023-08-16 14:24:56 | ERROR | stderr | INFO: Waiting for application startup.
————————————————————————————————————————————
我做的是self_cognation的微调,让它输出自己的名字是查派
而直接通过AutoModel调用虽然也是报相同的warning,却能输出微调后预期的结果
from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("/data2/model/chapi", trust_remote_code=True) model = AutoModel.from_pretrained("/data2/model/chapi", trust_remote_code=True).half().cuda() model = model.eval() response, history = model.chat(tokenizer, "你好", history=[]) print(response)
输出:您好!我是 查派,由 xxx开发,旨在为用户提供智能化的回答和支持。
The text was updated successfully, but these errors were encountered: