Views
No views yet
[CLS] topic [SEP] arg_a [SEP] arg_b| Split | Accuracy | F1 | Precision | Recall |
|---|---|---|---|---|
| In-domain | 65.7% | 0.644 | 0.673 | 0.616 |
| Cross-topic | 65.7% | 0.673 | 0.669 | 0.677 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("SambhavSBU/argument-quality-roberta-v3")
5model = AutoModelForSequenceClassification.from_pretrained("SambhavSBU/argument-quality-roberta-v3")
6
7def predict(topic, arg_a, arg_b):
8 def score(a, b):
9 inp = tokenizer(topic + " [SEP] " + a, b,
10 return_tensors="pt", truncation=True, max_length=256)
11 with torch.no_grad():
12 logits = model(**inp).logits
13 return (logits[0, 1] - logits[0, 0]).item()
14
15 # test-time pair flipping: average both orderings
16 margin = (score(arg_a, arg_b) - score(arg_b, arg_a)) / 2
17 return "A" if margin > 0 else "B"
18
19topic = "We should ban social media"
20arg_a = "Social media spreads misinformation at an unprecedented scale."
21arg_b = "Social media connects people across the world."
22print(f"Higher quality argument: {predict(topic, arg_a, arg_b)}")