How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-classification", model="clapAI/roberta-large-multilingual-sentiment")
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("clapAI/roberta-large-multilingual-sentiment")
model = AutoModelForSequenceClassification.from_pretrained("clapAI/roberta-large-multilingual-sentiment", device_map="auto")
Quick Links

clapAI/modernBERT-large-multilingual-sentiment

Introduction

roberta-large-multilingual-sentiment is a multilingual sentiment classification model, part of the Multilingual-Sentiment collection.

The model is fine-tuned from FacebookAI/xlm-roberta-base using the multilingual sentiment dataset clapAI/MultiLingualSentiment.

Model supports multilingual sentiment classification across 16+ languages, including English, Vietnamese, Chinese, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and more.

Evaluation & Performance

After fine-tuning, the best model is loaded and evaluated on the test dataset from clapAI/MultiLingualSentiment

Model Pretrained Model Parameters F1-score
modernBERT-base-multilingual-sentiment ModernBERT-base 150M 80.16
modernBERT-large-multilingual-sentiment ModernBERT-large 396M 81.4
roberta-base-multilingual-sentiment XLM-roberta-base 278M 81.8
roberta-large-multilingual-sentiment XLM-roberta-large 560M 82.6

How to use

Requirements

Since transformers only supports the ModernBERT architecture from version 4.48.0.dev0, use the following command to get the required version:

pip install "git+https://github.com/huggingface/transformers.git@6e0515e99c39444caae39472ee1b2fd76ece32f1" --upgrade

Install FlashAttention to accelerate inference performance

pip install flash-attn==2.7.2.post1

Quick start

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model_id = "clapAI/roberta-large-multilingual-sentiment"
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id, torch_dtype=torch.float16)

model.to(device)
model.eval()


# Retrieve labels from the model's configuration
id2label = model.config.id2label

texts = [
    # English
    {
        "text": "I absolutely love the new design of this app!",
        "label": "positive"
    },
    {
        "text": "The customer service was disappointing.",
        "label": "negative"
    },
    # Arabic
    {
        "text": "ู‡ุฐุง ุงู„ู…ู†ุชุฌ ุฑุงุฆุน ู„ู„ุบุงูŠุฉ!",
        "label": "positive"
    },
    {
        "text": "ุงู„ุฎุฏู…ุฉ ูƒุงู†ุช ุณูŠุฆุฉ ู„ู„ุบุงูŠุฉ.",
        "label": "negative"
    },
    # German
    {
        "text": "Ich bin sehr zufrieden mit dem Kauf.",
        "label": "positive"
    },
    {
        "text": "Die Lieferung war eine Katastrophe.",
        "label": "negative"
    },
    # Spanish
    {
        "text": "Este es el mejor libro que he leรญdo.",
        "label": "positive"
    },
    {
        "text": "El producto llegรณ roto y no funciona.",
        "label": "negative"
    },
    # French
    {
        "text": "J'adore ce restaurant, la nourriture est dรฉlicieuse!",
        "label": "positive"
    },
    {
        "text": "Le service รฉtait trรจs lent et dรฉsagrรฉable.",
        "label": "negative"
    },
    # Indonesian
    {
        "text": "Saya sangat senang dengan pelayanan ini.",
        "label": "positive"
    },
    {
        "text": "Makanannya benar-benar tidak enak.",
        "label": "negative"
    },
    # Japanese
    {
        "text": "ใ“ใฎ่ฃฝๅ“ใฏๆœฌๅฝ“ใซ็ด ๆ™ดใ‚‰ใ—ใ„ใงใ™๏ผ",
        "label": "positive"
    },
    {
        "text": "ใ‚ตใƒผใƒ“ใ‚นใŒใฒใฉใ‹ใฃใŸใงใ™ใ€‚",
        "label": "negative"
    },
    # Korean
    {
        "text": "์ด ์ œํ’ˆ์„ ์ •๋ง ์ข‹์•„ํ•ด์š”!",
        "label": "positive"
    },
    {
        "text": "๊ณ ๊ฐ ์„œ๋น„์Šค๊ฐ€ ์ •๋ง ์‹ค๋ง์Šค๋Ÿฌ์› ์–ด์š”.",
        "label": "negative"
    },
    # Russian
    {
        "text": "ะญั‚ะพั‚ ั„ะธะปัŒะผ ะฟั€ะพัั‚ะพ ะฟะพั‚ั€ััะฐัŽั‰ะธะน!",
        "label": "positive"
    },
    {
        "text": "ะšะฐั‡ะตัั‚ะฒะพ ะฑั‹ะปะพ ัƒะถะฐัะฝั‹ะผ.",
        "label": "negative"
    },
    # Vietnamese
    {
        "text": "Tรดi thแปฑc sแปฑ yรชu thรญch sแบฃn phแบฉm nร y!",
        "label": "positive"
    },
    {
        "text": "Dแป‹ch vแปฅ khรกch hร ng thแบญt tแป‡.",
        "label": "negative"
    },
    # Chinese
    {
        "text": "ๆˆ‘้žๅธธๅ–œๆฌข่ฟ™ๆฌพไบงๅ“๏ผ",
        "label": "positive"
    },
    {
        "text": "่ดจ้‡็œŸ็š„ๅพˆๅทฎใ€‚",
        "label": "negative"
    }
]

for item in texts:
    text = item["text"]
    label = item["label"]

    inputs = tokenizer(text, return_tensors="pt").to(device)

    # Perform inference in inference mode
    with torch.inference_mode():
        outputs = model(**inputs)
        predictions = outputs.logits.argmax(dim=-1)
    print(f"Text: {text} | Label: {label} | Prediction: {id2label[predictions.item()]}")

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

learning_rate: 5e-05
train_batch_size: 512
eval_batch_size: 512
seed: 42
distributed_type: multi-GPU
num_devices: 2
gradient_accumulation_steps: 2
total_train_batch_size: 2048
total_eval_batch_size: 1024
optimizer:
  type: adamw_torch_fused
  betas: [ 0.9, 0.999 ]
  epsilon: 1e-08
  optimizer_args: "No additional optimizer arguments"
lr_scheduler:
  type: cosine
  warmup_ratio: 0.01
num_epochs: 5.0
mixed_precision_training: Native AMP

Framework versions

transformers==4.48.0.dev0
torch==2.4.0+cu121
datasets==3.2.0
tokenizers==0.21.0
flash-attn==2.7.2.post1

Citation

If you find our project helpful, please star our repo and cite our work. Thanks!

@misc{roberta-large-multilingual-sentiment,
      title=roberta-large-multilingual-sentiment: A Multilingual Sentiment Classification Model},
      author={clapAI},
      howpublished={\url{https://huggingface.co/clapAI/roberta-large-multilingual-sentiment}},
      year={2025},
}
Downloads last month
478
Safetensors
Model size
0.6B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for clapAI/roberta-large-multilingual-sentiment

Finetuned
(4271)
this model

Dataset used to train clapAI/roberta-large-multilingual-sentiment