Update README.md
Browse files
README.md
CHANGED
|
@@ -29,4 +29,31 @@ Number of hidden layers: 12
|
|
| 29 |
Max position embeddings: 512
|
| 30 |
Type vocab size: 2
|
| 31 |
Vocab size: 30522
|
| 32 |
-
The model uses the GELU activation function in its hidden layers and applies dropout with a probability of 0.1 to the attention probabilities to prevent overfitting.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
Max position embeddings: 512
|
| 30 |
Type vocab size: 2
|
| 31 |
Vocab size: 30522
|
| 32 |
+
The model uses the GELU activation function in its hidden layers and applies dropout with a probability of 0.1 to the attention probabilities to prevent overfitting.
|
| 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])```
|