--- license: apache-2.0 language: - am - arq - ary - ha - ig - rw - pcm - yo - tw - pt - sw - ts datasets: - shmuhammad/AfriSenti-twitter-sentiment metrics: - accuracy pipeline_tag: text-classification --- # AfriSenti-twitter-sentiment-afroxlmr-large ## Model description **afrisenti-twitter-sentiment-afroxlmr-large** is the first multilingual twitter **sentiment classification** model for twelve (12) Nigerian languages (Amharic, Algerian Arabic, Darija, Hausa, Igbo, Kinyarwanda, Nigerian Pidgin, Mozambique Portuguese, Swahili, Tsonga, Twi, and Yorùbá) based on a fine-tuned castorini/afriberta_large large model. It achieves the **state-of-the-art performance** for the twitter sentiment classification task trained on the [AfriSenti corpus](https://github.com/afrisenti-semeval/afrisent-semeval-2023). The model has been trained to classify tweets into 3 sentiment classes: negative, neutral and positive Specifically, this model is a *Davlan/afro-xlmr-large* model that was fine-tuned on an aggregation of 12 African language datasets obtained from [AfriSenti](https://github.com/afrisenti-semeval/afrisent-semeval-2023) dataset. ## Intended uses & limitations #### How to use You can use this model with Transformers for Sentiment Classification. ```python from transformers import AutoModelForSequenceClassification from transformers import AutoTokenizer import numpy as np from scipy.special import softmax MODEL = "Davlan/afrisenti-twitter-sentiment-afroxlmr-large" tokenizer = AutoTokenizer.from_pretrained(MODEL) # PT model = AutoModelForSequenceClassification.from_pretrained(MODEL) text = "I like you" encoded_input = tokenizer(text, return_tensors='pt') output = model(**encoded_input) scores = output[0][0].detach().numpy() scores = softmax(scores) id2label = {0:"positive", 1:"neutral", 2:"negative"} ranking = np.argsort(scores) ranking = ranking[::-1] for i in range(scores.shape[0]): l = id2label[ranking[i]] s = scores[ranking[i]] print(f"{i+1}) {l} {np.round(float(s), 4)}") ``` #### Limitations and bias This model is limited by its training dataset and domain i.e Twitter. This may not generalize well for all use cases in different domains. ## Training procedure This model was trained on a single Nvidia A10 GPU with recommended hyperparameters from the [original AfriSenti paper](https://arxiv.org/abs/2302.08956). ### BibTeX entry and citation info ``` @article{Muhammad2023AfriSentiAT, title={AfriSenti: A Twitter Sentiment Analysis Benchmark for African Languages}, author={Shamsuddeen Hassan Muhammad and Idris Abdulmumin and Abinew Ali Ayele and Nedjma Djouhra Ousidhoum and David Ifeoluwa Adelani and Seid Muhie Yimam and Ibrahim Said Ahmad and Meriem Beloucif and Saif M. Mohammad and Sebastian Ruder and Oumaima Hourrane and Pavel Brazdil and Felermino D'ario M'ario Ant'onio Ali and Davis C. Davis and Salomey Osei and Bello Shehu Bello and Falalu Ibrahim and Tajuddeen Rabiu Gwadabe and Samuel Rutunda and Tadesse Destaw Belay and Wendimu Baye Messelle and Hailu Beshada Balcha and Sisay Adugna Chala and Hagos Tesfahun Gebremichael and Bernard Opoku and Steven Arthur}, journal={ArXiv}, year={2023}, volume={abs/2302.08956}, url={https://api.semanticscholar.org/CorpusID:257019629} } ```