SCIR-HI / Huatuo-Llama-Med-Chinese

Repo for BenTsao [original name: HuaTuo (华驼)], Instruction-tuning Large Language Models with Chinese Medical Knowledge. 本草(原名:华驼)模型仓库,基于中文医学知识的大语言模型指令微调
Apache License 2.0
4.37k stars 432 forks source link

4 张 3090 上运行 finetune,运行结束报错 UnboundLocalError: local variable 'load_result' referenced before assignment #53

Closed diaojunxian closed 1 year ago

diaojunxian commented 1 year ago
  1. 期望复现 llama lora 使用文中提到的语料库训练;
  2. 只修改 finetune.sh 中对应的 base model 路径,其他都未做修改;
  3. 运行完之后,命令行报错:
    he intermediate checkpoints of PEFT may not be saved correctly, using `TrainerCallback` to save adapter_model.bin in corresponding folders, here are some examples https://github.com/huggingface/peft/issues/96
    Traceback (most recent call last):
    File "/home/m1l03053/llama/Huatuo-Llama-Med-Chinese/finetune.py", line 280, in <module>
    fire.Fire(train)
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
    File "/home/m1l03053/llama/Huatuo-Llama-Med-Chinese/finetune.py", line 270, in train
    trainer.train(resume_from_checkpoint=resume_from_checkpoint)
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/transformers/trainer.py", line 1696, in train
    return inner_training_loop(
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/transformers/trainer.py", line 2095, in _inner_training_loop
    self._load_best_model()
    File "/home/m1l03053/.conda/envs/3.9/lib/python3.9/site-packages/transformers/trainer.py", line 2292, in _load_best_model
    self._issue_warnings_after_load(load_result)
    UnboundLocalError: local variable 'load_result' referenced before assignment
    wandb: Waiting for W&B process to finish... (failed 1). Press Control-C to abort syncing.
    wandb: 
    wandb: Run history:
    wandb:               eval/loss █▅▄▃▃▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁
    wandb:            eval/runtime ▁▃▄▆▇▅▂▆▅██▃▅█▆█▆█▅▃
    wandb: eval/samples_per_second █▆▅▃▂▄▇▃▄▁▁▆▃▁▃▁▃▁▄▆
    wandb:   eval/steps_per_second █▆▅▃▂▄▇▃▄▁▁▆▄▁▂▁▃▁▄▆
    wandb:             train/epoch ▁▁▁▂▂▂▂▂▂▃▃▃▃▃▃▄▄▄▄▄▅▅▅▅▅▆▆▆▆▆▆▇▇▇▇▇▇███
    wandb:       train/global_step 
wangdadian1 commented 1 year ago

你好,请问这个问题解决了吗?我也遇到了同样的问题。

diaojunxian commented 1 year ago

你好,请问这个问题解决了吗?我也遇到了同样的问题。

没有解决了,虽然 transformers降版本到4.29.2及以下可以运行不报错,但是最后生成的adapter_model.bin 只有 443 bytes,不知道哪里有问题;

wangdadian1 commented 1 year ago

我降版本之后也出现了这个问题,训练完只有443bytes。

diaojunxian commented 1 year ago

我降版本之后也出现了这个问题,训练完只有443bytes。

还要降 peft 版本,但是最后导出的时候看起来还是丢失了些 key,也不知道怎么办了。

pip uninstall peft -y pip install git+https://github.com/huggingface/peft.git@e536616888d51b453ed354a6f1e243fecb02ea08

wangdadian1 commented 1 year ago

我的即使降了这个的版本,也还是443bytes

diaojunxian commented 1 year ago

我的即使降了这个的版本,也还是443bytes

我这边倒是正常的 16M 左右,确定 transformers 和 peft 版本都降低了吗

Forever-Young-l commented 1 year ago

我降版本之后也出现了这个问题,训练完只有443bytes。

还要降 peft 版本,但是最后导出的时候看起来还是丢失了些 key,也不知道怎么办了。

pip uninstall peft -y pip install git+https://github.com/huggingface/peft.git@e536616888d51b453ed354a6f1e243fecb02ea08

你好,麻烦请教下,实验室环境是内网环境,没法连github,请问peft那个版本连接无法打开,怎么办呢?

wangdadian1 commented 1 year ago

可以直接点开链接下载 下载完成后 cd peft-main python setup.py install 但是这样下载完成之后版本是 0.4.0dev 然后我又pip install peft==0.3.0 但训练完之后保存的模型仍然是443bytes

wangdadian1 commented 1 year ago

下面是它requirements中需要的包以及我现在的版本,还是想请教您一下,是否和您的有区别呢? accelerate 0.20.0.dev0 appdirs 1.4.4 bitsandbytes 0.39.0 black 23.3.0 datasets 2.12.0 fire 0.5.0 peft 0.3.0 transformers 4.29.1 gradio 3.32.0 sentencepiece 0.1.99 wandb 0.15.3

Forever-Young-l commented 1 year ago

可以直接点开链接下载 下载完成后 cd peft-main python setup.py install 但是这样下载完成之后版本是 0.4.0dev 然后我又pip install peft==0.3.0 但训练完之后保存的模型仍然是443bytes

直接点连接,浏览器中显示not found,下载不了呀

Forever-Young-l commented 1 year ago

下面是它requirements中需要的包以及我现在的版本,还是想请教您一下,是否和您的有区别呢? accelerate 0.20.0.dev0 appdirs 1.4.4 bitsandbytes 0.39.0 black 23.3.0 datasets 2.12.0 fire 0.5.0 peft 0.3.0 transformers 4.29.1 gradio 3.32.0 sentencepiece 0.1.99 wandb 0.15.3

兄嘚,peft需要用peft==0.3.0.dev0,对应这个e536616888d51b453ed354a6f1e243fecb02ea08

diaojunxian commented 1 year ago

虽然是16M了,不过导出的时候,还是能看到异常warning,不知道是什么情况 image

wangdadian1 commented 1 year ago

你好,我尝试了很多方法 下载不到0.3.0.dev0版本的peft  也打不开那个网址 可不可以把这个版本的压缩包 发我邮箱一份呢? @.***

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: louzhumuyou @.> 发送时间: 2023年6月3日 14:16 收件人: SCIR-HI/Huatuo-Llama-Med-Chinese @.> 抄送: wangdadian1 @.>, Comment @.> 主题: Re: [SCIR-HI/Huatuo-Llama-Med-Chinese] 4 张 3090 上运行 finetune,运行结束报错 UnboundLocalError: local variable 'load_result' referenced before assignment (Issue #53)

虽然是16M了,不过导出的时候,还是能看到异常warning,不知道是什么情况

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

diaojunxian commented 1 year ago

你好,我尝试了很多方法 下载不到0.3.0.dev0版本的peft  也打不开那个网址 可不可以把这个版本的压缩包 发我邮箱一份呢? @. 发自我的iPhone ------------------ 原始邮件 ------------------ 发件人: louzhumuyou @.> 发送时间: 2023年6月3日 14:16 收件人: SCIR-HI/Huatuo-Llama-Med-Chinese @.> 抄送: wangdadian1 @.>, Comment @.> 主题: Re: [SCIR-HI/Huatuo-Llama-Med-Chinese] 4 张 3090 上运行 finetune,运行结束报错 UnboundLocalError: local variable 'load_result' referenced before assignment (Issue #53) 虽然是16M了,不过导出的时候,还是能看到异常warning,不知道是什么情况 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

这个你如果在实验室没有办法安装,建议,你下载好源码,checkout 到指定 commit ,然后压缩到隔离网络的机器安装。