@@ -88,10 +88,12 @@ def __init__(self):
88
88
self .vectorizer = pickle .load (open (vector_file , mode = 'rb' ))
89
89
self .vocab = open (vocab_file , mode = 'r' ).read ().splitlines ()
90
90
91
- def evaluate (self , thresh = 0.1 ):
91
+ def evaluate (self , thresh = 0.05 ):
92
92
dataset = squad .Squad (train = True )
93
93
prediction = []
94
94
for index , [context , qas ] in enumerate (dataset ):
95
+ if index % 100 == 0 :
96
+ print (index )
95
97
contexts = []
96
98
for sentence in sent_tokenizer .tokenize (context ):
97
99
sentence = tokenize (sentence )
@@ -109,16 +111,16 @@ def evaluate(self, thresh=0.1):
109
111
scores = [cosine_similarity (question_vec , vec ).flatten () for vec in context_vec ]
110
112
scores = np .asarray (scores ).flatten ()
111
113
112
- # print("Scores : ", scores)
113
114
ranks = np .argsort (scores )[::- 1 ]
114
- if scores [ranks [0 ]] < thresh :
115
+
116
+ if scores [ranks [0 ]] > thresh :
115
117
prediction .append (is_correct (contexts , ranks [0 ], answer_start , answer_end ))
116
118
accuracy = sum (prediction ) / len (prediction )
117
119
print (accuracy )
118
120
119
121
120
122
if __name__ == '__main__' :
121
- compute_vectors ()
123
+ # compute_vectors()
122
124
123
125
print ("Computing accuracy of the model" )
124
126
baseline = BaselineQA ()
0 commit comments