Chinese-LLaMA-Alpaca-3 icon indicating copy to clipboard operation
Chinese-LLaMA-Alpaca-3 copied to clipboard

微调过程loss为0, grad_norm为nan

Open lychee-2724540853 opened this issue 9 months ago • 10 comments

提交前必须检查以下项目

  • [X] 请确保使用的是仓库最新代码(git pull)
  • [X] 已阅读项目文档FAQ章节并且已在Issue中对问题进行了搜索,没有找到相似问题和解决方案。
  • [X] 第三方插件问题:例如llama.cpptext-generation-webui等,建议优先去对应的项目中查找解决方案。

问题类型

模型训练与精调

基础模型

Llama-3-Chinese-8B(基座模型)

操作系统

Linux

详细描述问题

在自己数据集上进行微调,但是训练过程loss为0,grad_norm为nan,请问是什么问题?

依赖情况(代码类问题务必提供)

# 请在此处粘贴依赖情况(请粘贴在本代码块里)

运行日志或截图

image

lychee-2724540853 avatar May 08 '24 08:05 lychee-2724540853

开启bf16了吗?

iMountTai avatar May 08 '24 12:05 iMountTai

是的,按照提供的参数脚本训练的 @iMountTai

lychee-2724540853 avatar May 09 '24 00:05 lychee-2724540853

确认一下数据长度和你设置的max_seq_lenth是否匹配,可能是因为你的output并没有计入logits

iMountTai avatar May 09 '24 12:05 iMountTai

I ran into the same situation where I had limited the length of the data set to 3000 and max_length to 4096 image

auroralsun avatar May 11 '24 17:05 auroralsun

请问解决了吗?目前我也遇到了同样的问题

zzb1185 avatar May 20 '24 06:05 zzb1185

Chinese-LLaMA-Alpaca-3 提供的脚本没出现这个问题,但是使用 unsloth 提供的llama3训练脚本生成的lora模型,再次训练会出现这个问题。

chenmonster avatar May 23 '24 06:05 chenmonster

使用 kigner/ruozhiba-llama3-tt 数据集在 hfl/llama-3-chinese-8b-instruct-v2 上训练也出现了这个问题,暂时找到解决办法...

chenmonster avatar May 24 '24 09:05 chenmonster

I ran into the same situation where I had limited the length of the data set to 3000 and max_length to 4096 image

用LLAMA-factory训练了,一切正常

auroralsun avatar May 24 '24 12:05 auroralsun

{'loss': 3.3183, 'grad_norm': nan, 'learning_rate': 1.707941929974381e-08, 'epoch': 0.0}
{'loss': 0.0, 'grad_norm': nan, 'learning_rate': 1.707941929974381e-07, 'epoch': 0.0}
我这也是一样的问题。

leonunix avatar May 27 '24 05:05 leonunix

通过升级bitsandbytes到最新,问题解决 bitsandbytes 0.42.0

升级到 bitsandbytes 0.43.1

leonunix avatar May 27 '24 05:05 leonunix

我也遇到了这个问题,升级了bitsandbytes之后并没有解决

aa200647963 avatar Jun 05 '24 09:06 aa200647963

@aa200647963 你试试用Instruct的tokenizer。

leonunix avatar Jun 07 '24 01:06 leonunix

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your consideration.

github-actions[bot] avatar Jun 21 '24 22:06 github-actions[bot]

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

github-actions[bot] avatar Jun 29 '24 22:06 github-actions[bot]