--- library_name: peft license: apache-2.0 base_model: xlm-roberta-base tags: - base_model:adapter:xlm-roberta-base - lora - transformers metrics: - accuracy - f1 model-index: - name: bengali-code-mix-sentiment-lora results: [] datasets: - Swarnadeep-28/bn_code_mix_sentiment_dataset pipeline_tag: text-classification --- # bengali-code-mix-sentiment-lora This model is a fine-tuned version of [xlm-roberta-base](https://huggingface.co/xlm-roberta-base) on the None dataset. It achieves the following results on the evaluation set: - Loss: 0.7597 - Accuracy: 0.7206 - F1: 0.7206 ## Model description This model is a **LoRA Parameter-Efficient Fine-Tuned** version of [`xlm-roberta-base`](https://huggingface.co/xlm-roberta-base) for **sentiment analysis** on **Bengali–English code-mixed text** (commonly found in social media posts, comments, and tweets). - **Task**: Text Classification (Sentiment Analysis) - **Languages**: Bengali (Romanized) + English - **Classes**: `positive`, `negative`, `neutral` - **Fine-tuning method**: LoRA (PEFT) - **Dataset**: [Bengali-English Code-Mixed Sentiment Dataset](https://huggingface.co/datasets/Swarnadeep-28/bn_code_mix_sentiment_dataset) This model enables efficient, low-resource fine-tuning while maintaining competitive performance for code-mixed sentiment classification. ## How to Use ### Inference Example ```python 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]) ``` ## Training procedure ### Training hyperparameters The following hyperparameters were used during training: - learning_rate: 0.0005 - train_batch_size: 16 - eval_batch_size: 32 - seed: 42 - optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments - lr_scheduler_type: linear - num_epochs: 5 ### Training results | 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 | ### Framework versions - PEFT 0.17.1 - Transformers 4.56.1 - Pytorch 2.8.0+cu126 - Datasets 4.0.0 - Tokenizers 0.22.0