Views
No views yet
1curl -X POST https://api.tabularis.ai/ \
2 -H "Content-Type: application/json" \
3 -d '{"text":"I love the design","return_all_scores":false}'
4Model Name: tabularisai/multilingual-sentiment-analysisBase Model: distilbert/distilbert-base-multilingual-casedTask: Text Classification (Sentiment Analysis)Languages: Supports English plus Chinese (中文), Spanish (Español), Hindi (हिन्दी), Arabic (العربية), Bengali (বাংলা), Portuguese (Português), Russian (Русский), Japanese (日本語), German (Deutsch), Malay (Bahasa Melayu), Telugu (తెలుగు), Vietnamese (Tiếng Việt), Korean (한국어), French (Français), Turkish (Türkçe), Italian (Italiano), Polish (Polski), Ukrainian (Українська), Tagalog, Dutch (Nederlands), Swiss German (Schweizerdeutsch), and Swahili.Number of Classes: 5 (Very Negative, Negative, Neutral, Positive, Very Positive)Usage:
distilbert/distilbert-base-multilingual-cased for multilingual sentiment analysis. It leverages synthetic data from multiple sources to achieve robust performance across different languages and cultural contexts.1from transformers import pipeline
2
3# Load the classification pipeline with the specified model
4pipe = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
5
6# Classify a new sentence
7sentence = "I love this product! It's amazing and works perfectly."
8result = pipe(sentence)
9
10# Print the result
11print(result)1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "tabularisai/multilingual-sentiment-analysis"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8def predict_sentiment(texts):
9 inputs = tokenizer(texts, return_tensors="pt", truncation=True, padding=True, max_length=512)
10 with torch.no_grad():
11 outputs = model(**inputs)
12 probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
13 sentiment_map = {0: "Very Negative", 1: "Negative", 2: "Neutral", 3: "Positive", 4: "Very Positive"}
14 return [sentiment_map[p] for p in torch.argmax(probabilities, dim=-1).tolist()]
15
16texts = [
17 # English
18 "I absolutely love the new design of this app!", "The customer service was disappointing.", "The weather is fine, nothing special.",
19 # Chinese
20 "这家餐厅的菜味道非常棒!", "我对他的回答很失望。", "天气今天一般。",
21 # Spanish
22 "¡Me encanta cómo quedó la decoración!", "El servicio fue terrible y muy lento.", "El libro estuvo más o menos.",
23 # Arabic
24 "الخدمة في هذا الفندق رائعة جدًا!", "لم يعجبني الطعام في هذا المطعم.", "كانت الرحلة عادية。",
25 # Ukrainian
26 "Мені дуже сподобалася ця вистава!", "Обслуговування було жахливим.", "Книга була посередньою。",
27 # Hindi
28 "यह जगह सच में अद्भुत है!", "यह अनुभव बहुत खराब था।", "फिल्म ठीक-ठाक थी।",
29 # Bengali
30 "এখানকার পরিবেশ অসাধারণ!", "সেবার মান একেবারেই খারাপ।", "খাবারটা মোটামুটি ছিল।",
31 # Portuguese
32 "Este livro é fantástico! Eu aprendi muitas coisas novas e inspiradoras.",
33 "Não gostei do produto, veio quebrado.", "O filme foi ok, nada de especial.",
34 # Japanese
35 "このレストランの料理は本当に美味しいです!", "このホテルのサービスはがっかりしました。", "天気はまあまあです。",
36 # Russian
37 "Я в восторге от этого нового гаджета!", "Этот сервис оставил у меня только разочарование.", "Встреча была обычной, ничего особенного.",
38 # French
39 "J'adore ce restaurant, c'est excellent !", "L'attente était trop longue et frustrante.", "Le film était moyen, sans plus.",
40 # Turkish
41 "Bu otelin manzarasına bayıldım!", "Ürün tam bir hayal kırıklığıydı.", "Konser fena değildi, ortalamaydı.",
42 # Italian
43 "Adoro questo posto, è fantastico!", "Il servizio clienti è stato pessimo.", "La cena era nella media.",
44 # Polish
45 "Uwielbiam tę restaurację, jedzenie jest świetne!", "Obsługa klienta była rozczarowująca.", "Pogoda jest w porządku, nic szczególnego.",
46 # Tagalog
47 "Ang ganda ng lugar na ito, sobrang aliwalas!", "Hindi maganda ang serbisyo nila dito.", "Maayos lang ang palabas, walang espesyal.",
48 # Dutch
49 "Ik ben echt blij met mijn nieuwe aankoop!", "De klantenservice was echt slecht.", "De presentatie was gewoon oké, niet bijzonder.",
50 # Malay
51 "Saya suka makanan di sini, sangat sedap!", "Pengalaman ini sangat mengecewakan.", "Hari ini cuacanya biasa sahaja.",
52 # Korean
53 "이 가게의 케이크는 정말 맛있어요!", "서비스가 너무 별로였어요.", "날씨가 그저 그렇네요.",
54 # Swiss German
55 "Ich find dä Service i de Beiz mega guet!", "Däs Esä het mir nöd gfalle.", "D Wätter hüt isch so naja."
56]
57
58for text, sentiment in zip(texts, predict_sentiment(texts)):
59 print(f"Text: {text}\nSentiment: {sentiment}\n")1@misc{tabularisai2025multilingualsentiment,
2 author = {Vadim Borisov and Samuel Gyamfi and Richard H. Schreiber},
3 title = {Multilingual Sentiment Analysis},
4 year = {2025},
5 doi = {10.57967/hf/5968},
6 url = {https://huggingface.co/tabularisai/multilingual-sentiment-analysis},
7 publisher = {Hugging Face},
8 note = {Revision 69afb83}
9}