stanfordnlp/imdb
Viewer • Updated • 100k • 182k • 1.29k
How to use pauL9990/sentiment-analyzer-v2-final with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("pauL9990/sentiment-analyzer-v2-final", device_map="auto")pauL9990/sentiment-analyzer-v2-final
sentiment-analyzer-v2-final is a LoRA fine-tuned version of DistilBERT for binary sentiment classification.
This model is trained on the IMDB movie review dataset and enhanced with real-world short-form and mixed sentiment examples, optimized for:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from peft import PeftModel
import torch
tokenizer = AutoTokenizer.from_pretrained("pauL9990/sentiment-analyzer-v2-final")
base_model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased", num_labels=2)
model = PeftModel.from_pretrained(base_model, "pauL9990/sentiment-analyzer-v2-final")
model.eval()
def analyze_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=256)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
label = "Positive" if torch.argmax(probs) == 1 else "Negative"
confidence = round(probs.max().item() * 100, 2)
return label, confidence
@misc{bordoloi2025sentimentanalyzer, title={Sentiment Analyzer V2 - LoRA Fine-Tuned DistilBERT}, author={Paul Bordoloi}, year={2025}, howpublished={\url{https://huggingface.co/pauL9990/sentiment-analyzer-v2-final}}, }
Base model
distilbert/distilbert-base-uncased