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

roformer-v2结合huggingface的库accelerate 使用时会导致保存的模型被多次删除;导致部分模型没有被保存 #38

Closed
XiaoqingNLP opened this issue Jul 28, 2022 · 2 comments

Comments

@XiaoqingNLP
Copy link

accelerate的保存模型方法:

# How to save your 🤗 Transformer?
accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
unwrapped_model.save_pretrained(save_dir, save_function=accelerator.save, state_dict=accelerator.get_state_dict(model))

roformer-v1 没有这个问题;roformer-v2 有这个问题,删除了多次

@XiaoqingNLP XiaoqingNLP changed the title roformer-v2结合huggingface的库accelerate 使用时会导致保存的模型被多次删除 roformer-v2结合huggingface的库accelerate 使用时会导致保存的模型被多次删除;导致部分模型没有被保存 Jul 28, 2022
@JunnYu
Copy link
Owner

JunnYu commented Jul 28, 2022

不应该会有这个问题吧,因为两个模型都是在一个代码里面,我看这里都是这么保存的呀。
https://github.com/huggingface/transformers/blob/5d1fed0740ec03ad45032f353379784d41c7118a/examples/pytorch/text-classification/run_glue_no_trainer.py#L580

@XiaoqingNLP
Copy link
Author

@JunnYu v1 没有这个问题,v2有,所以大概率这不是accelerate的问题
我之前v1 是直接从transformers里面import的,v2是按readme里面import的,我觉得这个可能是导致这个问题的差异。
最近比较忙,我用一个直接的方法解决这个问题了,我把这个问题po出来探讨一下

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

2 participants