python - 如何摆脱 GPT-2 警告消息?

标签 python huggingface-transformers gpt-2

每次运行 GPT-2 时,我都会收到此消息。有什么办法可以让它消失吗?

Some weights of GPT2LMHeadModel were not initialized from the model checkpoint at gpt2 and are newly initialized: ['h.0.attn.masked_bias', 'h.1.attn.masked_bias', 'h.2.attn.masked_bias', 'h.3.attn.masked_bias', 'h.4.attn.masked_bias', 'h.5.attn.masked_bias', 'h.6.attn.masked_bias', 'h.7.attn.masked_bias', 'h.8.attn.masked_bias', 'h.9.attn.masked_bias', 'h.10.attn.masked_bias', 'h.11.attn.masked_bias', 'lm_head.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

最佳答案

是的,您需要更改 loglevel 在从转换器库导入任何内容之前:

import logging
logging.basicConfig(level='ERROR')

from transformers import GPT2LMHeadModel

model = GPT2LMHeadModel.from_pretrained('gpt2')

关于python - 如何摆脱 GPT-2 警告消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63626014/

相关文章:

python - Django:没有名为设置的模块

python - TypeError : Fetch argument array has invalid type numpy. ndarray,必须是字符串或Tensor。 (不能将 ndarray 转换为张量或操作。)

python - 从 RAM 转储中获取 python 脚本

deep-learning - 深度学习模型训练过程中修改学习率

python - 具有多个提交元素的 POST 表单

python - 保存微调的 Tensorflow 模型时列出超出范围的索引

huggingface-transformers - 解析拥抱脸变压器输出

pytorch - OSError : libmkl_intel_lp64. so.1: 无法打开共享对象文件: 没有这样的文件或目录

python - 如何使用我自己的语料库文本创建和拟合 vocab.bpe 文件(GPT 和 GPT2 OpenAI 模型)?

python - 属性错误 : 'GPT2Model' object has no attribute 'gradient_checkpointing'