Talip7's picture
Update README.md
280cbe5 verified
---
language: en
license: mit
library_name: transformers
datasets:
- glue
- sst2
metrics:
- accuracy
pipeline_tag: text-classification
widget:
- text: "This movie was an absolute masterpiece, I loved every minute of it!"
example_title: "Positive Example"
- text: "The plot was boring and the acting was subpar."
example_title: "Negative Example"
---
# BERT Base Uncased – Fine-tuned on SST-2
This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the **GLUE SST-2** dataset for **binary sentiment analysis**.
---
## Model Details
- **Developed by:** Talip7
- **Base model:** BERT Base Uncased
- **Model type:** Transformer encoder (BERT)
- **Language:** English
- **Task:** Sentiment Analysis (Binary Classification)
---
## Training Details
- **Dataset:** GLUE / SST-2
- **Training framework:** PyTorch
- **Libraries:** πŸ€— Transformers, πŸ€— Datasets, πŸ€— Accelerate
- **Optimizer:** AdamW
- **Learning rate:** 3e-5
- **Epochs:** 3
- **Learning rate scheduler:** Linear
- **Hardware:** GPU (via πŸ€— Accelerate)
---
## Evaluation Results
The model was evaluated on the SST-2 validation set.
- **Accuracy:** **0.9289 (92.89%)**
---
## Intended Use
This model can be used for:
- Binary sentiment analysis on English text
- Educational purposes (learning fine-tuning with Hugging Face)
- Benchmarking sentiment classification models
---
## Limitations
- Trained only on movie reviews (SST-2); performance may degrade on other domains.
- Does not explicitly handle sarcasm or complex sentiment.
- Not suitable for multilingual sentiment analysis.
---
## Usage
### πŸ€— Transformers Pipeline
```python
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="Talip7/bert-base-sst2-finetuned"
)
classifier("I love this project!")
```
### πŸ”₯ PyTorch Usage
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("Talip7/bert-base-sst2-finetuned")
model = AutoModelForSequenceClassification.from_pretrained("Talip7/bert-base-sst2-finetuned")
text = "This movie was absolutely fantastic!"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
label_map = {0: "Negative", 1: "Positive"}
print(f"Prediction: {label_map[prediction]}")