Update README.md
Browse files
README.md
CHANGED
|
@@ -24,6 +24,30 @@ It achieves the following results on the evaluation set:
|
|
| 24 |
- Loss: 0.3812
|
| 25 |
- Accuracy: 0.9083
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
## Model description
|
| 28 |
|
| 29 |
More information needed
|
|
|
|
| 24 |
- Loss: 0.3812
|
| 25 |
- Accuracy: 0.9083
|
| 26 |
|
| 27 |
+
# Load model directly
|
| 28 |
+
```python
|
| 29 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 30 |
+
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("execbat/bert-finetuned-sst2")
|
| 32 |
+
model = AutoModelForSequenceClassification.from_pretrained("execbat/bert-finetuned-sst2")
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## Use a pipeline as a high-level helper
|
| 36 |
+
```python
|
| 37 |
+
from transformers import pipeline
|
| 38 |
+
|
| 39 |
+
label_tags = {'LABEL_0' : "NEGATIVE",
|
| 40 |
+
'LABEL_1' : "POSITIVE"}
|
| 41 |
+
|
| 42 |
+
pipe = pipeline("text-classification", model="execbat/bert-finetuned-sst2")
|
| 43 |
+
result = pipe(["what a horrible day!", "what a wonderfull day!"])
|
| 44 |
+
encoded_result = [label_tags[i["label"]] for i in result]
|
| 45 |
+
print(encoded_result)
|
| 46 |
+
```
|
| 47 |
+
```python
|
| 48 |
+
['NEGATIVE', 'POSITIVE']
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
## Model description
|
| 52 |
|
| 53 |
More information needed
|