APauli commited on
Commit
0eb700e
1 Parent(s): 306162c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -1
README.md CHANGED
@@ -5,4 +5,28 @@ datasets:
5
  language:
6
  - en
7
  pipeline_tag: sentence-similarity
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  language:
6
  - en
7
  pipeline_tag: sentence-similarity
8
+ ---
9
+ ## Model to score relative persuasive language between pairs
10
+ More info about training, evaluation, and use in paper is here: link.
11
+
12
+ Python:
13
+ ```python
14
+ from transformers import AutoModelForSequenceClassification,AutoTokenizer
15
+ import torch
16
+ modelname='APauli/Persuasive_language_in_pairs'
17
+ model = AutoModelForSequenceClassification.from_pretrained(modelname)
18
+ tokenizer = AutoTokenizer.from_pretrained(modelname)
19
+
20
+ def predict(textA, textB, model,tokenizer):
21
+ encoded_input = tokenizer(textA, textB, padding=True, truncation=True,max_length=256, return_tensors="pt")
22
+ with torch.no_grad():
23
+ logits = model(**encoded_input).logits
24
+ score1=logits.detach().cpu().numpy()
25
+ #flipped
26
+ encoded_input = tokenizer(textB, textA, padding=True, truncation=True,max_length=256, return_tensors="pt")
27
+ with torch.no_grad():
28
+ logits = model(**encoded_input).logits
29
+ score2=logits.detach().cpu().numpy()*(-1)
30
+ score = (score1+score2)/2
31
+ return score
32
+ ```