Commit
·
053a766
1
Parent(s):
22b7ce0
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# bert-base-cased for Advertisement Classification
|
2 |
+
|
3 |
+
This is best-base-cased model trained on the binary dataset prepared for advertisement classification. This model is suitable for English.
|
4 |
+
|
5 |
+
<b>Labels</b>:
|
6 |
+
0 -> non-advertisement;
|
7 |
+
1 -> advertisement;
|
8 |
+
|
9 |
+
## Example of classification
|
10 |
+
|
11 |
+
'''python
|
12 |
+
from transformers import AutoModelForSequenceClassification
|
13 |
+
from transformers import AutoTokenizer
|
14 |
+
import numpy as np
|
15 |
+
from scipy.special import softmax
|
16 |
+
|
17 |
+
text = 'Young Brad Pitt early in his career McDonalds Commercial'
|
18 |
+
|
19 |
+
encoded_input = tokenizer(text, return_tensors='pt').to('cuda')
|
20 |
+
output = model(**encoded_input)
|
21 |
+
scores = output[0][0].detach().to('cpu').numpy()
|
22 |
+
scores = softmax(scores)
|
23 |
+
prediction_class = np.argmax(scores)
|
24 |
+
print(prediction_class)
|
25 |
+
'''
|
26 |
+
Output:
|
27 |
+
```
|
28 |
+
1
|
29 |
+
```
|