[英]How to use architecture of T5 without pretrained model (Hugging face)
I would like to study the effect of pre-trained model, so I want to test t5 model with and without pre-trained weights.我想研究预训练的 model 的效果,所以我想在有和没有预训练权重的情况下测试 t5 model。 Using pre-trained weights is straight forward, but I cannot figure out how to use the architecture of T5 from hugging face without the weights.
使用预先训练的权重是直截了当的,但我无法弄清楚如何在没有权重的情况下使用 T5 的架构。 I am using Hugging face with pytorch but open for different solution.
我正在使用带有 pytorch 的拥抱脸,但对不同的解决方案开放。
https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Model https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Model
"Initializing with a config file does not load the weights associated with the model, only the configuration." “使用配置文件初始化不会加载与 model 相关的权重,只会加载配置。”
for without weights create a T5Model with config file对于没有权重的情况,使用配置文件创建 T5Model
from transformers import AutoConfig
from transformers import T5Tokenizer, T5Model
model_name = "t5-small"
config = AutoConfig.from_pretrained(model_name)
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5Model.from_pretrained(model_name)
model_raw = T5Model(config)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.