Skip to content
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

微调过程loss为0, grad_norm为nan #29

Open
3 tasks done
lychee-2724540853 opened this issue May 8, 2024 · 12 comments
Open
3 tasks done

微调过程loss为0, grad_norm为nan #29

lychee-2724540853 opened this issue May 8, 2024 · 12 comments

Comments

@lychee-2724540853
Copy link

提交前必须检查以下项目

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

问题类型

模型训练与精调

基础模型

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

操作系统

Linux

详细描述问题

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

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

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

运行日志或截图

image

@iMountTai
Copy link
Collaborator

开启bf16了吗?

@lychee-2724540853
Copy link
Author

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

@iMountTai
Copy link
Collaborator

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

@auroralsun
Copy link

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

@zzb1185
Copy link

zzb1185 commented May 20, 2024

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

@chenmonster
Copy link

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

@chenmonster
Copy link

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

@auroralsun
Copy link

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训练了,一切正常

@leonunix
Copy link

{'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
Copy link

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

升级到
bitsandbytes 0.43.1

@aa200647963
Copy link

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

@leonunix
Copy link

leonunix commented Jun 7, 2024

@aa200647963
你试试用Instruct的tokenizer。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants