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

256加载模型错误 #4

Open
CodeXiaoLingYun opened this issue Oct 11, 2023 · 3 comments
Open

256加载模型错误 #4

CodeXiaoLingYun opened this issue Oct 11, 2023 · 3 comments

Comments

@CodeXiaoLingYun
Copy link

CodeXiaoLingYun commented Oct 11, 2023

from transformers import BertTokenizer, BertModel

tokenizer = BertTokenizer.from_pretrained("MODEL_NAME")
model = BertModel.from_pretrained("MODEL_NAME")

我将模型下载到了本地,MiniRBT-h256-pt文件夹下有三个文件 config.json pytorch_model.bin vocab.txt
我将MODEL_NAME替换成本地模型路径:XXXXX/MiniRBT-h256-pt,
config能够正常加载
但是加载model时候报错
Some weights of the model checkpoint at XXXXX/MiniRBT-h256-pt were not used when initializing BertModel: ['cls.predictions.bias', 'cls.predictions.decoder.bias', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.LayerNorm.weight']

  • This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
  • This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
    Some weights of BertModel were not initialized from the model checkpoint at XXXXXX/MiniRBT-h256-pt and are newly initialized: ['bert.pooler.dense.bias', 'bert.pooler.dense.weight']
    You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

根据错误提示的是,模型结构和权重不一致,导致的,请问这个问题是我下载文件有错误?还是哪里的错误

@CodeXiaoLingYun
Copy link
Author

我查阅了下文档,这个好像是警告,并不是错误?

1 similar comment
@CodeXiaoLingYun
Copy link
Author

我查阅了下文档,这个好像是警告,并不是错误?

@futz12
Copy link

futz12 commented Sep 8, 2024

我验证了,他这个模型没带pooler的权重了,导致最终pooler_output的数据是随机的

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