Spaces:
Runtime error
Runtime error
Added score code
Browse files
app.py
CHANGED
@@ -64,17 +64,22 @@ def main():
|
|
64 |
query_emb = model(query).astype(float)
|
65 |
|
66 |
#Compute dot score between query and all document embeddings
|
67 |
-
scores = util.dot_score(query_emb, doc_emb.astype(float))#[0].cpu().tolist()
|
|
|
|
|
|
|
|
|
68 |
|
69 |
#Combine docs & scores with other attributes
|
70 |
doc_score_pairs = list(zip(docs, scores, titles, start_times, end_times, locations))
|
|
|
71 |
|
72 |
# top_k results to return
|
73 |
top_k=3
|
74 |
|
75 |
print(" Your top", top_k, "most similar sessions in the Summit:")
|
76 |
|
77 |
-
#Sort
|
78 |
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
|
79 |
|
80 |
|
|
|
64 |
query_emb = model(query).astype(float)
|
65 |
|
66 |
#Compute dot score between query and all document embeddings
|
67 |
+
#scores = util.dot_score(query_emb, doc_emb.astype(float))#[0].cpu().tolist()
|
68 |
+
|
69 |
+
#cos_scores = util.pytorch_cos_sim(query_emb, doc_emb)[0]
|
70 |
+
|
71 |
+
scores = util.pytorch_cos_sim(query_emb, doc_emb)[0]
|
72 |
|
73 |
#Combine docs & scores with other attributes
|
74 |
doc_score_pairs = list(zip(docs, scores, titles, start_times, end_times, locations))
|
75 |
+
|
76 |
|
77 |
# top_k results to return
|
78 |
top_k=3
|
79 |
|
80 |
print(" Your top", top_k, "most similar sessions in the Summit:")
|
81 |
|
82 |
+
#Sort the results in decreasing order and get the first top_k
|
83 |
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
|
84 |
|
85 |
|