PoliBERTweet
1.0.0
基于变压器的语言模型已通过大量与政治相关的Twitter数据(8300万推文)进行了预训练。此存储库是以下论文的官方资源。
我们论文中介绍的评估任务的数据集如下提供。
所有型号都上传到我的拥抱面?因此,您只需三行代码加载模型!!!
我们在pytorch v1.10.2和transformers v4.18.0中进行了测试。
from transformers import AutoModel , AutoTokenizer , pipeline
import torch
# Choose GPU if available
device = torch . device ( "cuda" if torch . cuda . is_available () else "cpu" )
# Select mode path here
pretrained_LM_path = "kornosk/polibertweet-mlm"
# Load model
tokenizer = AutoTokenizer . from_pretrained ( pretrained_LM_path )
model = AutoModel . from_pretrained ( pretrained_LM_path ) # Fill mask
example = "Trump is the <mask> of USA"
fill_mask = pipeline ( 'fill-mask' , model = pretrained_LM_path , tokenizer = tokenizer )
outputs = fill_mask ( example )
print ( outputs ) # See embeddings
inputs = tokenizer ( example , return_tensors = "pt" )
outputs = model ( ** inputs )
print ( outputs )
# OR you can use this model to train on your downstream task!
# please consider citing our paper if you feel this is useful :)请参阅“拥抱面文档”中的详细信息。
如果您认为我们的纸张和资源很有用,请考虑引用我们的作品!
@inproceedings { kawintiranon2022polibertweet ,
title = { {P}oli{BERT}weet: A Pre-trained Language Model for Analyzing Political Content on {T}witter } ,
author = { Kawintiranon, Kornraphop and Singh, Lisa } ,
booktitle = { Proceedings of the Language Resources and Evaluation Conference (LREC) } ,
year = { 2022 } ,
pages = { 7360--7367 } ,
publisher = { European Language Resources Association } ,
url = { https://aclanthology.org/2022.lrec-1.801 }
}如果您有任何问题加载模型或数据集,请在此处创建问题。