Skip to content

Commit 2e3e85d

Browse files
committed
baseline
1 parent 14f0fcf commit 2e3e85d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

baselineQA.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ def __init__(self):
8888
self.vectorizer = pickle.load(open(vector_file, mode='rb'))
8989
self.vocab = open(vocab_file, mode='r').read().splitlines()
9090

91-
def evaluate(self, thresh=0.1):
91+
def evaluate(self, thresh=0.05):
9292
dataset = squad.Squad(train=True)
9393
prediction = []
9494
for index, [context, qas] in enumerate(dataset):
95+
if index % 100 == 0:
96+
print(index)
9597
contexts = []
9698
for sentence in sent_tokenizer.tokenize(context):
9799
sentence = tokenize(sentence)
@@ -109,16 +111,16 @@ def evaluate(self, thresh=0.1):
109111
scores = [cosine_similarity(question_vec, vec).flatten() for vec in context_vec]
110112
scores = np.asarray(scores).flatten()
111113

112-
# print("Scores : ", scores)
113114
ranks = np.argsort(scores)[::-1]
114-
if scores[ranks[0]] < thresh:
115+
116+
if scores[ranks[0]] > thresh:
115117
prediction.append(is_correct(contexts, ranks[0], answer_start, answer_end))
116118
accuracy = sum(prediction) / len(prediction)
117119
print(accuracy)
118120

119121

120122
if __name__ == '__main__':
121-
compute_vectors()
123+
# compute_vectors()
122124

123125
print("Computing accuracy of the model")
124126
baseline = BaselineQA()

0 commit comments

Comments
 (0)