File size: 3,438 Bytes
d0c19e1
 
 
 
 
 
 
 
 
e6c48af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3af9e42
e6c48af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
license: mit
datasets:
- cornell-movie-review-data/rotten_tomatoes
language:
- en
base_model:
- distilbert/distilbert-base-uncased
pipeline_tag: text-classification
---


# Rotten Tomatoes Sentiment DistilBERT

This model is a fine-tuned version of `distilbert-base-uncased` for binary sentiment classification on movie review snippets from the Rotten Tomatoes dataset. The model predicts whether a given movie review sentence expresses a **positive** or **negative** sentiment.

## Model Details

### Base Model

The base model is `distilbert-base-uncased`, a smaller and faster distilled version of BERT. It is designed to retain much of BERT’s language understanding ability while being more lightweight.

### Fine-Tuned Task

This model was fine-tuned for **text classification**, specifically **binary sentiment analysis**.

The two output labels are:

| Label ID | Label |
| -------- | -------- |
| 0 | NEGATIVE |
| 1 | POSITIVE |

## Dataset

This model was fine-tuned using the `cornell-movie-review-data/rotten_tomatoes` dataset from Hugging Face Datasets.

The dataset contains short movie review sentences labeled as either positive or negative.

Example inputs:

```text
"a smart, funny and touching film"
```

```text
"the story is dull and lifeless"
```

## Intended Use

This model can be used for simple sentiment classification of short English movie-review-style text.

Example use cases include:

* Classifying movie reviews as positive or negative
* Learning and demonstrating Hugging Face Transformers fine-tuning
* Experimenting with the `Trainer` API
* Building a basic sentiment analysis demo

## Limitations

This model was trained on movie review data, so it may perform best on text that resembles short movie reviews.

It may not perform well on:

* Long documents
* Non-English text
* Sarcasm or highly ambiguous sentiment
* Domain-specific sentiment outside movie reviews
* Reviews with mixed opinions

For example, a sentence like:

```text
"The acting was excellent, but the story was slow and forgettable."
```

may be difficult because it contains both positive and negative sentiment.

## Training Procedure

The model was fine-tuned using the Hugging Face Transformers `Trainer` API.

### Training Configuration

```python
TrainingArguments(
output_dir="./rt-sentiment-distilbert",
learning_rate=2e-5,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
num_train_epochs=3,
weight_decay=0.01,
eval_strategy="epoch",
save_strategy="epoch",
load_best_model_at_end=True,
metric_for_best_model="accuracy",
report_to="none",
)
```

> FULL TRAINING AND FINETUNING CODE CAN BE ACCESSED IN THIS COLAB NODE BOOK: https://colab.research.google.com/drive/12cwKhvX9LAq39LGk-WbxzchYPla_yrA4?usp=sharing

## Usage

You can use this model with the Hugging Face `pipeline` API:

```python
from transformers import pipeline

classifier = pipeline(
"text-classification",
model="jimjunior/rt-sentiment-distilbert"
)

result = classifier("The movie was touching, funny, and beautifully acted.")
print(result)
```

Example output:

```python
[{"label": "POSITIVE", "score": 0.98}]
```

You can also classify negative text:

```python
classifier("The story was boring and the acting was terrible.")
```

Example output:

```python
[{"label": "NEGATIVE", "score": 0.97}]
```

## Model Output

The model returns one of two labels:

* `NEGATIVE`
* `POSITIVE`

Each prediction also includes a confidence score.