CoolFace
Modelpublic

cardiffnlp/tweet-topic-latest-multi

sourceHugging Faceupdated 3y agoView on Hugging Face
13likes86downloads
Model Card

tweet-topic-latest-multi

This is a RoBERTa-base model trained on 168.86M tweets until the end of September 2022 and finetuned for multi-label topic classification on a corpus of 11,267 tweets. The original RoBERTa-base model can be found here. This model is suitable for English.

<b>Labels</b>:

<span style="font-weight:normal">0: arts_&_culture</span><span style="font-weight:normal">5: fashion_&_style</span><span style="font-weight:normal">10: learning_&_educational</span><span style="font-weight:normal">15: science_&_technology</span>
1: business&entrepreneurs6: filmtv&_video11: music16: sports
2: celebrity&pop_culture7: fitness&health12: news&social_concern17: travel&adventure
3: diaries&daily_life8: food&dining13: other_hobbies18: youth&student_life
4: family9: gaming14: relationships

Full classification example

python
from transformers import AutoModelForSequenceClassification, TFAutoModelForSequenceClassification
from transformers import AutoTokenizer
import numpy as np
from scipy.special import expit

    
MODEL = f"cardiffnlp/tweet-topic-latest-multi"
tokenizer = AutoTokenizer.from_pretrained(MODEL)

# PT
model = AutoModelForSequenceClassification.from_pretrained(MODEL)
class_mapping = model.config.id2label

text = "It is great to see athletes promoting awareness for climate change."
tokens = tokenizer(text, return_tensors='pt')
output = model(**tokens)

scores = output[0][0].detach().numpy()
scores = expit(scores)
predictions = (scores >= 0.5) * 1


# TF
#tf_model = TFAutoModelForSequenceClassification.from_pretrained(MODEL)
#class_mapping = tf_model.config.id2label
#text = "It is great to see athletes promoting awareness for climate change."
#tokens = tokenizer(text, return_tensors='tf')
#output = tf_model(**tokens)
#scores = output[0][0]
#scores = expit(scores)
#predictions = (scores >= 0.5) * 1

# Map to classes
for i in range(len(predictions)):
  if predictions[i]:
    print(class_mapping[i])

Output:

fitness_&_health
news_&_social_concern
sports

BibTeX entry and citation info

Please cite the reference paper if you use this model.

bibtex
@inproceedings{antypas-etal-2022-twitter,
    title = "{T}witter Topic Classification",
    author = "Antypas, Dimosthenis  and
      Ushio, Asahi  and
      Camacho-Collados, Jose  and
      Silva, Vitor  and
      Neves, Leonardo  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",
    url = "https://aclanthology.org/2022.coling-1.299",
    pages = "3386--3400"
}