Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
base_model:
|
5 |
+
- microsoft/deberta-v3-base
|
6 |
+
pipeline_tag: text-classification
|
7 |
+
---
|
8 |
+
Binary classification model for ad-detection on QA Systems.
|
9 |
+
|
10 |
+
## Sample usage
|
11 |
+
|
12 |
+
```python
|
13 |
+
import torch
|
14 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
15 |
+
|
16 |
+
classifier_model_path = "jmvcoelho/ad-classifier-v0.1"
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained(classifier_model_path)
|
18 |
+
model = AutoModelForSequenceClassification.from_pretrained(classifier_model_path)
|
19 |
+
model.eval()
|
20 |
+
|
21 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
22 |
+
model.to(device)
|
23 |
+
|
24 |
+
def classify(passages):
|
25 |
+
inputs = tokenizer(
|
26 |
+
passages, padding=True, truncation=True, max_length=512, return_tensors="pt"
|
27 |
+
)
|
28 |
+
inputs = {k: v.to(device) for k, v in inputs.items()}
|
29 |
+
with torch.no_grad():
|
30 |
+
outputs = model(**inputs)
|
31 |
+
logits = outputs.logits
|
32 |
+
predictions = torch.argmax(logits, dim=-1)
|
33 |
+
return predictions.cpu().tolist()
|
34 |
+
|
35 |
+
preds = classify(["sample_text_1", "sample_text_2"])
|
36 |
+
```
|
37 |
+
|
38 |
+
|
39 |
+
## Version
|
40 |
+
|
41 |
+
- v0.0: Trained with the official data from Webis Generated Native Ads 2024
|
42 |
+
- v0.1: Trained with v0.0 data + new synthetic data
|
43 |
+
- **v0.2**: Similar to v0.1, but include more diversity in ad placement startegies through prompting.
|
44 |
+
|
45 |
+
|
46 |
+
## New Synthetic Data
|
47 |
+
|
48 |
+
Objective: Given (query, answer) pair, generate new_answer which contains an advertisement.
|
49 |
+
|
50 |
+
### Initial Data:
|
51 |
+
|
52 |
+
- queries: Obtained from MS-MARCO V2.1 QA task. 150K subset of queries that are associated with a "well formed answer"
|
53 |
+
- answer: Generated with Qwen2.5-7B-Instruct using RAG with 10 passages (from our model.)
|
54 |
+
|
55 |
+
### Models used for generation
|
56 |
+
|
57 |
+
|
58 |
+
Each model generated for 1/4th of the (query, answer) pairs
|
59 |
+
- Gemma-2-9b-it
|
60 |
+
- LLaMA-3.1-8B-Instruct
|
61 |
+
- Mistral-7B-Instruct
|
62 |
+
- Qwen2.5-7B-Instruct
|
63 |
+
|
64 |
+
### Prompts
|
65 |
+
|
66 |
+
One of twelve prompts is chosen at random.
|
67 |
+
Prompts can be found under `files/*.prompt`.
|