🚀 twitter-XLM-roBERTa-base 感情分析モデル
このモデルは、約1億9800万件のツイートで学習され、感情分析用にスペイン語でファインチューニングされたXLM - roBERTa - baseモデルです。このモデルは、IberLEF 2021会議の一部であるEmoEvalEsコンペティションに提出されました。このコンペティションでは、スペイン語のツイートを怒り、嫌悪、恐怖、喜び、悲しみ、驚き、その他の7つの異なるクラスに分類するタスクが設定されていました。当モデルは、マクロ平均F1スコア71.70%でコンペティションで1位に輝きました。
⚠️ 重要提示
このモデルとモデルカードは、感情分析用にファインチューニングされたXLM - Tに基づいています。
🚀 クイックスタート
このモデルを使用することで、スペイン語のツイートの感情分析を行うことができます。以下に具体的な使用例を示します。
💻 使用例
基本的な使用法
from transformers import pipeline
model_path = "daveni/twitter-xlm-roberta-emotion-es"
emotion_analysis = pipeline("text-classification", framework="pt", model=model_path, tokenizer=model_path)
emotion_analysis("Einstein dijo: Solo hay dos cosas infinitas, el universo y los pinches anuncios de bitcoin en Twitter. Paren ya carajo aaaaaaghhgggghhh me quiero murir")
出力結果:
[{'label': 'anger', 'score': 0.48307016491889954}]
高度な使用法
from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer, AutoConfig
import numpy as np
from scipy.special import softmax
def preprocess(text):
new_text = []
for t in text.split(" "):
t = '@user' if t.startswith('@') and len(t) > 1 else t
t = 'http' if t.startswith('http') else t
new_text.append(t)
return " ".join(new_text)
model_path = "daveni/twitter-xlm-roberta-emotion-es"
tokenizer = AutoTokenizer.from_pretrained(model_path )
config = AutoConfig.from_pretrained(model_path )
model = AutoModelForSequenceClassification.from_pretrained(model_path )
text = "Se ha quedao bonito día para publicar vídeo, ¿no? Hoy del tema más diferente que hemos tocado en el canal."
text = preprocess(text)
print(text)
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
scores = output[0][0].detach().numpy()
scores = softmax(scores)
ranking = np.argsort(scores)
ranking = ranking[::-1]
for i in range(scores.shape[0]):
l = config.id2label[ranking[i]]
s = scores[ranking[i]]
print(f"{i+1}) {l} {np.round(float(s), 4)}")
出力結果:
Se ha quedao bonito día para publicar vídeo, ¿no? Hoy del tema más diferente que hemos tocado en el canal.
1) joy 0.7887
2) others 0.1679
3) surprise 0.0152
4) sadness 0.0145
5) anger 0.0077
6) disgust 0.0033
7) fear 0.0027
制限事項とバイアス
- ファインチューニングに使用したデータセットは不均衡で、ほぼ半数のレコードがその他クラスに属していたため、このクラスに対するバイアスが存在する可能性があります。
📚 ドキュメント
学習データ
事前学習された重みは、cardiffnlpによってリリースされた元のモデルと同じです。ファインチューニングには、EmoEvalEsデータセットを使用しました。
BibTeXエントリと引用情報
@inproceedings{vera2021gsi,
title={GSI-UPM at IberLEF2021: Emotion Analysis of Spanish Tweets by Fine-tuning the XLM-RoBERTa Language Model},
author={Vera, D and Araque, O and Iglesias, CA},
booktitle={Proceedings of the Iberian Languages Evaluation Forum (IberLEF 2021). CEUR Workshop Proceedings, CEUR-WS, M{\'a}laga, Spain},
year={2021}
}