Downloads · 30 days
2
3% of all-time downloads
nidhic0301/distilbert-imdb-sentiment-classifier-lora
distilbert-imdb-sentiment-classifier-lora is a machine learning model from nidhic0301. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project demonstrates parameter-efficient fine-tuning of DistilBERT using LoRA (PEFT) for sentiment classification on the IMDb dataset.
Downloads · 30 days
2
3% of all-time downloads
All-time downloads
70
Public
Parameters
67M
268 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
This project demonstrates parameter-efficient fine-tuning of DistilBERT using LoRA (PEFT) for sentiment classification on the IMDb dataset.
Limited adaptation due to low-rank constraint
With a smaller rank (r=8), the model wasn’t learning meaningful patterns — updates were too constrained.
Fix: Increased LoRA rank → r=16, trained on full IMDB dataset (25k samples), used max_length=256
Why it worked: Higher rank increased LoRA capacity → allowed richer updates instead of minimal adjustments
Learning rate sensitivity (instability vs slow learning)
Higher LR like 2e-4 led to unstable/noisy training. Too low LR made learning too slow.
Fix: Settled on learning_rate = 1.5e-5, added warmup_steps=200, used weight_decay=0.01
Why it worked: Ensured stable, incremental updates within LoRA’s constrained update space
Balanced hyperparameter tuning (r, alpha, LR)
Changing one parameter didn’t help unless others were balanced.
Fix: r=16, lora_alpha=16, lora_dropout=0.1
Why it worked: Maintained stable scaling of updates (alpha / r) while increasing capacity
Going beyond standard evaluation metrics
Accuracy/F1 looked fine, but the model leaned slightly toward positive predictions.
Fix: Checked confusion matrix, tuned decision threshold from 0.5 → 0.6
Why it worked: Reduced false positives → improved prediction balance and calibration
Ambiguous sample data labelling
Sentences like “not bad” or “okay” were labelled negative but model learned positive
Fix: Manual error analysis, treated them as dataset ambiguity instead of forcing the model to fit them
Why it worked: Avoided overfitting to noisy or subjective labels
Verifying real improvement beyond metrics
Metric gains didn’t guarantee better behavior. On paper the metrics looked good but evaluation had to go beyond the metrics.
Fix: Tested on long & mixed sentiment inputs, compared outputs with pretrained baseline, reviewed actual predictions
Why it worked: Confirmed improvements were behavioral (generalization), not just numerical
| Model | Dataset | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|---|
| LoRA Fine-tuned | IMDb | 88.47% | 0.877 | 0.895 | 0.886 |
| LoRA (Cross-domain) | SST-2 | 83.83% | 0.798 | 0.914 | 0.852 |
LoRA fine-tuned model achieved strong performance on IMDb:
Compared to pretrained behavior:
Cross-domain evaluation (SST-2):
Model behavior insights:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("nidhic0301/distilbert-imdb-sentiment-classifier-lora")
tokenizer = AutoTokenizer.from_pretrained("nidhic0301/distilbert-imdb-sentiment-classifier-lora")