Downloads · 30 days
24
2% of all-time downloads
bondarchukb/bert-ads-classification
bert-ads-classification is a text classification model from bondarchukb. Use it when you need a label for a piece of text. It is set up for transformers.
This is bert-base-cased model trained on the binary dataset prepared for advertisement classification. This model is suitable for English.
Downloads · 30 days
24
2% of all-time downloads
All-time downloads
1.6K
Public
Repo size
867 MB
Likes
1
Public
Click a slice to open those files.
.bin433 MB · 100%
From the Hugging Face model README
This is bert-base-cased model trained on the binary dataset prepared for advertisement classification. This model is suitable for English.
<b>Labels</b>: 0 -> non-advertisement; 1 -> advertisement;
from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer
import numpy as np
from scipy.special import softmax
text = 'Young Brad Pitt early in his career McDonalds Commercial'
encoded_input = tokenizer(text, return_tensors='pt').to('cuda')
output = model(**encoded_input)
scores = output[0][0].detach().to('cpu').numpy()
scores = softmax(scores)
prediction_class = np.argmax(scores)
print(prediction_class)
Output:
1