Swarnadeep-28/bn_code_mix_sentiment_dataset
Viewer • Updated • 20k • 51
How to use Swarnadeep-28/bengali-code-mix-sentiment with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Swarnadeep-28/bengali-code-mix-sentiment") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Swarnadeep-28/bengali-code-mix-sentiment")
model = AutoModelForSequenceClassification.from_pretrained("Swarnadeep-28/bengali-code-mix-sentiment")This model is a fine-tuned version of xlm-roberta-base for sentiment analysis on Bengali–English code-mixed text (social media posts, comments, and tweets).
0, 1, 2, 3 This model provides strong baseline performance for code-mixed sentiment classification and can be directly applied to social media analysis and low-resource NLP research.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "Swarnadeep-28/bengali-code-mix-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
text = "Aaj match ta khub bhalo chilo! Loved it."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
logits = model(**inputs).logits
pred = torch.argmax(logits, dim=-1).item()
labels = ["0", "1", "2", "3"]
print("Predicted label:", labels[pred])
xlm-roberta-base | Label | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| 0 | 0.80 | 0.73 | 0.77 | 528 |
| 1 | 0.73 | 0.73 | 0.73 | 617 |
| 2 | 0.69 | 0.76 | 0.72 | 675 |
| 3 | 0.67 | 0.57 | 0.62 | 182 |
If you use this model, please cite:
@model{das2025_bn_code_mix_sentiment,
author = {Swarnadeep Das},
title = {Bengali-English Code-Mixed Sentiment Model},
year = {2025},
url = {https://huggingface.co/Swarnadeep-28/bengali-code-mix-sentiment}
}
xlm-roberta-base Base model
FacebookAI/xlm-roberta-base