Update README.md
Browse files
README.md
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
{}
|
| 3 |
-
---
|
| 4 |
-
# Sentiment Analysis Model (BERT Fine-Tuned on IMDB)
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
```python
|
| 11 |
from transformers import pipeline
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fine-tuned BERT for IMDB Sentiment Classification
|
| 2 |
+
|
| 3 |
+
**Model:** google-bert/bert-base-uncased → fine-tuned on IMDB (binary sentiment)
|
| 4 |
+
|
| 5 |
+
**Task:** Sequence classification (sentiment analysis)
|
| 6 |
+
|
| 7 |
+
**Author:** Your Name / @YourHFusername
|
| 8 |
+
**License:** Apache-2.0 (choose appropriate license)
|
| 9 |
+
|
| 10 |
---
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
## Description
|
| 13 |
+
This is a BERT-base model fine-tuned on the IMDB movie reviews dataset for binary sentiment classification (positive / negative).
|
| 14 |
+
It accepts raw text and returns a label and confidence score.
|
| 15 |
|
| 16 |
+
**Input:** string (movie review)
|
| 17 |
+
**Output:** dictionary with `label` and `score`. By default the model may return `LABEL_0` and `LABEL_1`.
|
| 18 |
+
Use the `id2label` mapping below to convert to human-readable labels:
|
| 19 |
+
- `LABEL_0` → `negative`
|
| 20 |
+
- `LABEL_1` → `positive`
|
| 21 |
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## Example usage
|
| 25 |
```python
|
| 26 |
from transformers import pipeline
|
| 27 |
|
| 28 |
+
clf = pipeline("text-classification", model="YourHFusername/sentiment-bert")
|
| 29 |
+
|
| 30 |
+
print(clf("I loved this movie!"))
|
| 31 |
+
# [{'label': 'LABEL_1', 'score': 0.998}]
|
| 32 |
+
|
| 33 |
+
# map to human-readable label
|
| 34 |
+
map = { "LABEL_0": "negative", "LABEL_1": "positive" }
|
| 35 |
+
out = clf("I loved this movie!")[0]
|
| 36 |
+
print(map[out["label"]], out["score"])
|
| 37 |
+
# positive 0.998
|