Downloads · 30 days
34
37% of all-time downloads
VijayKanupuri/bert-sst2
bert-sst2 is a text classification model from VijayKanupuri. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
This model is a BERT-base (bert-base-uncased) model fine-tuned on the SST-2 (Stanford Sentiment Treebank) dataset for binary sentiment classification.
Downloads · 30 days
34
37% of all-time downloads
All-time downloads
91
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
This model is a BERT-base (bert-base-uncased) model fine-tuned on the SST-2 (Stanford Sentiment Treebank) dataset for binary sentiment classification.
The model predicts whether a given English sentence expresses positive or negative sentiment.
This model was fine-tuned as part of a learning-focused, production-style workflow:
0 → Negative1 → PositiveSST-2 consists of movie review sentences annotated for sentiment polarity.
The model was evaluated on the SST-2 validation set.
Expected performance is consistent with standard BERT fine-tuning on SST-2:
This model is intended primarily for learning and demonstration rather than leaderboard optimization.
from transformers import BertTokenizer, BertForSequenceClassification
import torch
tokenizer = BertTokenizer.from_pretrained("VijayKanupuri/bert-sst2")
model = BertForSequenceClassification.from_pretrained("VijayKanupuri/bert-sst2")
text = "I really loved this movie"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)
label = torch.argmax(probs, dim=-1).item()
confidence = probs[0][label].item()
print(label, confidence)