Downloads · 30 days
5
3% of all-time downloads
imrgurmeet/fine-tuned-sentiment-model
fine-tuned-sentiment-model is a text classification model from imrgurmeet. Use it when you need a label for a piece of text. It is set up for transformers.
- Base Model: distilbert-base-uncased - Task: Text Classification (Sentiment Analysis) - Dataset: stanfordnlp/imdb - Fine-tuning Method: Full Fine-tuning - Training samples: 5000 - Epochs: 3 - Batch Size: 8 - Learning…
Downloads · 30 days
5
3% of all-time downloads
All-time downloads
146
Public
Parameters
67M
268 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
Fine-tuned distilbert-base-uncased for Sentiment Analysis
This model is a fine-tuned version of distilbert-base-uncased on the stanfordnlp/imdb dataset.
from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch
tokenizer = AutoTokenizer.from_pretrained("{HF_REPO_NAME}") model = AutoModelForSequenceClassification.from_pretrained("{HF_REPO_NAME}")
text = "This movie is amazing! I really enjoyed watching it." inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad(): outputs = model(**inputs) predictions = torch.nn.functional.softmax(outputs.logits, dim=-1) predicted_class = torch.argmax(predictions, dim=-1).item() confidence = torch.max(predictions).item()
sentiment = "positive" if predicted_class == 1 else "negative" print(f"Sentiment: {{sentiment}} (confidence: {{confidence:.3f}})")
Optimizer: AdamW
Weight Decay: 0.01
Warmup Steps: 500
Mixed Precision: {"Enabled" if torch.cuda.is_available() else "Disabled"}
This model is intended for sentiment analysis of English text. It classifies text into two categories:
0: Negative sentiment
1: Positive sentiment
Trained primarily on movie reviews → may not generalize to other domains
Weak on neutral/mixed sentiment
Designed for English text only
Platform: Google Colab
GPU: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else "CPU"}
Framework: PyTorch + Transformers
Training Summary:
Your Model:
Next Steps:
Usage in your code:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("imrgurmeet/fine-tuned-sentiment-model") model = AutoModelForSequenceClassification.from_pretrained("imrgurmeet/fine-tuned-sentiment-model")
text = "Your text here" inputs = tokenizer(text, return_tensors="pt") outputs = model(**inputs) prediction = torch.nn.functional.softmax(outputs.logits, dim=-1)
SIMPLE VERSION:
from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch
Load once
tokenizer = AutoTokenizer.from_pretrained("imrgurmeet/fine-tuned-sentiment-model") model = AutoModelForSequenceClassification.from_pretrained("imrgurmeet/fine-tuned-sentiment-model")
Use anywhere:
def analyze(text): inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True) with torch.no_grad(): outputs = model(**inputs) prediction = torch.argmax(outputs.logits, dim=-1).item() return "positive" if prediction == 1 else "negative"
Test it:
print(analyze("I love this!")) # positive print(analyze("This is terrible!")) # negative print(analyze("It's okay")) # positive or negative