模型:
cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-all
这个模型是基于 cardiffnlp/twitter-roberta-base-dec2021 在 tweet_topic_multi 上进行调优的版本。此模型是在tweet_topic的train_all数据集上进行调优并在test_2021数据集上进行验证的。调优脚本可以在 here 中找到。它在test_2021数据集上实现了以下结果:
import math import torch from transformers import AutoModelForSequenceClassification, AutoTokenizer def sigmoid(x): return 1 / (1 + math.exp(-x)) tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-all") model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-all", problem_type="multi_label_classification") model.eval() class_mapping = model.config.id2label with torch.no_grad(): text = #NewVideo Cray Dollas- Water- Ft. Charlie Rose- (Official Music Video)- {{URL}} via {@YouTube@} #watchandlearn {{USERNAME}} tokens = tokenizer(text, return_tensors='pt') output = model(**tokens) flags = [sigmoid(s) > 0.5 for s in output[0][0].detach().tolist()] topic = [class_mapping[n] for n, i in enumerate(flags) if i] print(topic)
@inproceedings{dimosthenis-etal-2022-twitter, title = "{T}witter {T}opic {C}lassification", author = "Antypas, Dimosthenis and Ushio, Asahi and Camacho-Collados, Jose and Neves, Leonardo and Silva, Vitor and Barbieri, Francesco", booktitle = "Proceedings of the 29th International Conference on Computational Linguistics", month = oct, year = "2022", address = "Gyeongju, Republic of Korea", publisher = "International Committee on Computational Linguistics" }