Swarnadeep-28/bn_code_mix_sentiment_dataset
Viewer • Updated • 20k • 51
How to use Swarnadeep-28/bengali-code-mix-sentiment-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification
base_model = AutoModelForSequenceClassification.from_pretrained("xlm-roberta-base")
model = PeftModel.from_pretrained(base_model, "Swarnadeep-28/bengali-code-mix-sentiment-lora")How to use Swarnadeep-28/bengali-code-mix-sentiment-lora 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-lora") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Swarnadeep-28/bengali-code-mix-sentiment-lora", dtype="auto")This model is a fine-tuned version of xlm-roberta-base on the None dataset. It achieves the following results on the evaluation set:
This model is a LoRA Parameter-Efficient Fine-Tuned version of xlm-roberta-base for sentiment analysis on Bengali–English code-mixed text (commonly found in social media posts, comments, and tweets).
positive, negative, neutral This model enables efficient, low-resource fine-tuning while maintaining competitive performance for code-mixed sentiment classification.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from peft import PeftModel
import torch
# Load tokenizer & model
model_id = "Swarnadeep-28/bengali-code-mix-sentiment-lora"
tokenizer = AutoTokenizer.from_pretrained(model_id)
base_model = AutoModelForSequenceClassification.from_pretrained("xlm-roberta-base", num_labels=3)
model = PeftModel.from_pretrained(base_model, model_id)
# Example text
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 = ["negative", "neutral", "positive"]
print("Predicted label:", labels[pred])
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 |
|---|---|---|---|---|---|
| 0.6325 | 1.0 | 1001 | 0.8349 | 0.6982 | 0.6974 |
| 0.7065 | 2.0 | 2002 | 0.7734 | 0.7096 | 0.7093 |
| 0.6849 | 3.0 | 3003 | 0.7649 | 0.7171 | 0.7149 |
| 0.6452 | 4.0 | 4004 | 0.7603 | 0.7176 | 0.7180 |
| 0.669 | 5.0 | 5005 | 0.7597 | 0.7206 | 0.7206 |
Base model
FacebookAI/xlm-roberta-base