Update README.md
Browse files
README.md
CHANGED
|
@@ -34,26 +34,26 @@ The model leverages the BertForSequenceClassification architecture, It has been
|
|
| 34 |
## Example
|
| 35 |
|
| 36 |
```python
|
| 37 |
-
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 38 |
-
import numpy as np
|
| 39 |
-
from scipy.special import expit
|
| 40 |
|
| 41 |
-
MODEL = "PavanDeepak/Topic_Classification"
|
| 42 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
| 43 |
-
model = AutoModelForSequenceClassification.from_pretrained(MODEL)
|
| 44 |
-
class_mapping = model.config.id2label
|
| 45 |
|
| 46 |
-
text = "I love chicken manchuria"
|
| 47 |
-
tokens = tokenizer(text, return_tensors="pt")
|
| 48 |
-
output = model(**tokens)
|
| 49 |
|
| 50 |
-
scores = output.logits[0][0].detach().numpy()
|
| 51 |
-
scores = expit(scores)
|
| 52 |
-
predictions = (scores >= 0.5) * 1
|
| 53 |
|
| 54 |
-
for i in range(len(predictions)):
|
| 55 |
-
if predictions[i]:
|
| 56 |
-
print(class_mapping[i])
|
| 57 |
```python
|
| 58 |
|
| 59 |
|
|
|
|
| 34 |
## Example
|
| 35 |
|
| 36 |
```python
|
| 37 |
+
>>> from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 38 |
+
>>> import numpy as np
|
| 39 |
+
>>> from scipy.special import expit
|
| 40 |
|
| 41 |
+
>>> MODEL = "PavanDeepak/Topic_Classification"
|
| 42 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
| 43 |
+
>>> model = AutoModelForSequenceClassification.from_pretrained(MODEL)
|
| 44 |
+
>>> class_mapping = model.config.id2label
|
| 45 |
|
| 46 |
+
>>> text = "I love chicken manchuria"
|
| 47 |
+
>>> tokens = tokenizer(text, return_tensors="pt")
|
| 48 |
+
>>> output = model(**tokens)
|
| 49 |
|
| 50 |
+
>>> scores = output.logits[0][0].detach().numpy()
|
| 51 |
+
>>> scores = expit(scores)
|
| 52 |
+
>>> predictions = (scores >= 0.5) * 1
|
| 53 |
|
| 54 |
+
>>> for i in range(len(predictions)):
|
| 55 |
+
>>> if predictions[i]:
|
| 56 |
+
>>> print(class_mapping[i])
|
| 57 |
```python
|
| 58 |
|
| 59 |
|