Transformer sentiment classification

Fine-tuned Transformer Sentiment Classifier

Fine-tuning a language model pretrained on Arabic text (such as MARBERT or CAMeLBERT-DA) to classify sentiment in Modern Standard Arabic and the dialects.

Deep learning

How it works

A classification head is added on top of the [CLS] token representation and the model is trained on labelled examples. MARBERT was trained on a large number of Arabic tweets, so it suits the dialects.

Steps

  1. Encode the text
  2. Contextual representation
  3. Classification layer
  4. Softmax over the classes
InputsText + a model
OutputsA class and probabilities
ComplexityTransformer inference is O(n²)

Example

The CAMeLBERT-DA model fine-tuned for sentiment is available through CAMeL Tools.

Strengths

  • Understands context and compound negation better
  • Handles the dialects if trained on them

Cons

  • Usually needs a GPU and labelled data
  • May inherit biases from the data

Uses

  • Monitoring public opinion
  • Analysing product reviews

Libraries that implement it

CAMeL Tools (sentiment)Hugging Face Transformers

See Libraries guide For licenses and runtime requirements.

References

  • Abdul-Mageed, M., Elmadany, A. & Nagoudi, E. M. B. (2021). ARBERT & MARBERT: Deep Bidirectional Transformers for Arabic. ACL 2021.
  • Inoue, G. et al. (2021). WANLP 2021.

This algorithm is explained for comparison and does not run in the browser because it needs a trained model; the site admin can connect an external engine that provides it. Open sentiment analysis