Update README.md
Browse files
README.md
CHANGED
|
@@ -33,27 +33,27 @@ The model uses the GELU activation function in its hidden layers and applies dro
|
|
| 33 |
|
| 34 |
## Example
|
| 35 |
|
| 36 |
-
```from transformers import AutoModelForSequenceClassification, TFAutoModelForSequenceClassification
|
| 37 |
-
from transformers import AutoTokenizer
|
| 38 |
-
import numpy as np
|
| 39 |
-
from scipy.special import expit
|
| 40 |
|
| 41 |
|
| 42 |
-
MODEL = f"PavanDeepak/Topic_Classification"
|
| 43 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
| 44 |
|
| 45 |
-
model = AutoModelForSequenceClassification.from_pretrained(MODEL)
|
| 46 |
-
class_mapping = model.config.id2label
|
| 47 |
|
| 48 |
-
text = "I love chicken manchuria"
|
| 49 |
-
tokens = tokenizer(text, return_tensors='pt')
|
| 50 |
-
output = model(**tokens)
|
| 51 |
|
| 52 |
-
scores = output[0][0].detach().numpy()
|
| 53 |
-
scores = expit(scores)
|
| 54 |
-
predictions = (scores >= 0.5) * 1
|
| 55 |
|
| 56 |
|
| 57 |
-
for i in range(len(predictions)):
|
| 58 |
-
if predictions[i]:
|
| 59 |
-
print(class_mapping[i])```
|
|
|
|
| 33 |
|
| 34 |
## Example
|
| 35 |
|
| 36 |
+
```from transformers import AutoModelForSequenceClassification, TFAutoModelForSequenceClassification```
|
| 37 |
+
```from transformers import AutoTokenizer
|
| 38 |
+
```import numpy as np
|
| 39 |
+
```from scipy.special import expit
|
| 40 |
|
| 41 |
|
| 42 |
+
```MODEL = f"PavanDeepak/Topic_Classification"
|
| 43 |
+
```tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
| 44 |
|
| 45 |
+
```model = AutoModelForSequenceClassification.from_pretrained(MODEL)
|
| 46 |
+
```class_mapping = model.config.id2label
|
| 47 |
|
| 48 |
+
```text = "I love chicken manchuria"
|
| 49 |
+
```tokens = tokenizer(text, return_tensors='pt')
|
| 50 |
+
```output = model(**tokens)
|
| 51 |
|
| 52 |
+
```scores = output[0][0].detach().numpy()
|
| 53 |
+
```scores = expit(scores)
|
| 54 |
+
```predictions = (scores >= 0.5) * 1
|
| 55 |
|
| 56 |
|
| 57 |
+
```for i in range(len(predictions)):
|
| 58 |
+
```if predictions[i]:
|
| 59 |
+
```print(class_mapping[i])```
|