File size: 1,364 Bytes
a20b728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecdea0f
 
 
 
 
 
a20b728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from sentence_transformers import LoggingHandler, SentenceTransformer, evaluation
from sentence_transformers.readers import InputExample
import csv
import logging

#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S',
                    level=logging.INFO,
                    handlers=[LoggingHandler()])
logger = logging.getLogger(__name__)
#### /print debug information to stdout

model_name = 'sentence-transformers/paraphrase-albert-base-v2'

#model_name='output/training_OnlineConstrativeLoss-2023-03-11_23-47-34'
#model_name= 'output/training_OnlineConstrativeLoss-2023-03-14_01-24-44'

#86% so far
model_name = 'output/training_OnlineConstrativeLoss-2023-03-17_16-10-39'

model_sbert = SentenceTransformer(model_name)

dev_sentences1 = []
dev_sentences2 = []
dev_labels = []
with open( "dev_set_training.csv", encoding='utf8') as fIn:
    reader = csv.DictReader(fIn, delimiter='|', quoting=csv.QUOTE_NONE)
    for row in reader:
        dev_sentences1.append(row['ADDRESS1'])
        dev_sentences2.append(row['ADDRESS2'])
        dev_labels.append(int(row['ARE_SAME']))



binary_acc_evaluator = evaluation.BinaryClassificationEvaluator(dev_sentences1, dev_sentences2, dev_labels)

binary_acc_evaluator(model_sbert)

print(binary_acc_evaluator)