Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
This is the first classification of sentiment analysis for (redacted) task
|
| 2 |
|
| 3 |
-
### How to
|
| 4 |
-
|
| 5 |
```python
|
| 6 |
import torch
|
| 7 |
from transformers import BertForSequenceClassification, BertTokenizer, BertConfig
|
|
@@ -9,16 +8,14 @@ from transformers import BertForSequenceClassification, BertTokenizer, BertConfi
|
|
| 9 |
tokenizer = BertTokenizer.from_pretrained("nfhakim/sentiment-analysis-c1")
|
| 10 |
config = BertConfig.from_pretrained("nfhakim/sentiment-analysis-c1")
|
| 11 |
model = BertForSequenceClassification.from_pretrained("nfhakim/sentiment-analysis-c1", config=config)
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
i2w = {0: 'positive', 1: 'non-positive'}
|
| 18 |
-
|
| 19 |
-
logits = model(subwords)[0]
|
| 20 |
-
label = torch.topk(logits, k=1, dim=-1)[1].squeeze().item()
|
| 21 |
|
| 22 |
-
|
| 23 |
```
|
| 24 |
|
|
|
|
|
|
| 1 |
This is the first classification of sentiment analysis for (redacted) task
|
| 2 |
|
| 3 |
+
### How to import
|
|
|
|
| 4 |
```python
|
| 5 |
import torch
|
| 6 |
from transformers import BertForSequenceClassification, BertTokenizer, BertConfig
|
|
|
|
| 8 |
tokenizer = BertTokenizer.from_pretrained("nfhakim/sentiment-analysis-c1")
|
| 9 |
config = BertConfig.from_pretrained("nfhakim/sentiment-analysis-c1")
|
| 10 |
model = BertForSequenceClassification.from_pretrained("nfhakim/sentiment-analysis-c1", config=config)
|
| 11 |
+
```
|
| 12 |
|
| 13 |
+
### How to use
|
| 14 |
+
```python
|
| 15 |
+
from transformers import pipeline
|
| 16 |
+
nlp = pipeline("text-classification", model="nfhakim/sentiment-analysis-c1")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
results = nlp("Your input text here")
|
| 19 |
```
|
| 20 |
|
| 21 |
+
|