File size: 2,639 Bytes
1c645f9
 
31e6865
 
 
 
 
 
 
1c645f9
31e6865
 
 
ac66fca
 
31e6865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
license: apache-2.0
language:
- en
metrics:
- accuracy
pipeline_tag: text-classification
tags:
- advertising
---

# Tiny Bert Domain Advertising Classifier

https://huggingface.co/ansi-code/bert-domain-advertising-classifier/blob/main/bert_domain_advertising_classifier.ipynb

## Overview

AdTargetingBERTClassifier is a small-scale BERT-based classifier designed for the task of ad targeting classification. The model is trained to predict multi-class labels associated with domains, as provided in the DAC693K dataset.

## Model Architecture

The classifier is built on the BERT (Bidirectional Encoder Representations from Transformers) architecture. It takes domain text as input and outputs logits for each class, enabling multi-class classification for ad targeting.

## Model Training

The model is trained on the "AdTargetingDataset" using a supervised learning approach. The training involves optimizing for the categorical cross-entropy loss, and the model is fine-tuned on the specific ad targeting classes associated with each domain.

## Usage

### Loading the Model

To use the trained classifier in your Python environment, you can load it using the following code:

```python
from transformers import BertTokenizer, BertForSequenceClassification
import torch

# Load the pre-trained model and tokenizer
model = BertForSequenceClassification.from_pretrained("ansi-code/bert-domain-advertising-classifier")
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")

# Example inference
text = "google.com"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
```

## Prediction
To make predictions with the loaded model, you can use the obtained logits. Convert the logits to probabilities and determine the predicted class based on the highest probability.

```python
Copy code
probabilities = torch.nn.functional.sigmoid(logits, dim=-1)
predicted_class = torch.argmax(probabilities).item()
```

## Model Evaluation

The model's performance can be assessed using standard evaluation metrics such as accuracy, precision, recall, and F1-score on a separate validation set or through cross-validation.

## License

This model is released under the Apache 2.0 License.

## Citation

If you use this model in your work, please cite it using the following BibTeX entry:

```bibtex
@model{silvi_2023_bert-domain-advertising-classifier,
  title = {bert-domain-advertising-classifier},
  author = {Andrea Silvi},
  year = {2023},
}
```

## Acknowledgements

We would like to thank the developers of the Hugging Face Transformers library for providing the BERT model implementation.