Update README.md
Browse files
README.md
CHANGED
@@ -1363,7 +1363,10 @@ query_embedding = np.asarray(query_embedding)
|
|
1363 |
|
1364 |
# Compute dot score between query embedding and document embeddings
|
1365 |
dot_scores = np.matmul(query_embedding, doc_embeddings.transpose())[0]
|
1366 |
-
top_k_hits = np.argpartition(dot_scores, -top_k)[-top_k:]
|
|
|
|
|
|
|
1367 |
|
1368 |
# Print results
|
1369 |
print("Query:", query)
|
|
|
1363 |
|
1364 |
# Compute dot score between query embedding and document embeddings
|
1365 |
dot_scores = np.matmul(query_embedding, doc_embeddings.transpose())[0]
|
1366 |
+
top_k_hits = np.argpartition(dot_scores, -top_k)[-top_k:].tolist()
|
1367 |
+
|
1368 |
+
# Sort top_k_hits by dot score
|
1369 |
+
top_k_hits.sort(key=lambda x: dot_scores[x], reverse=True)
|
1370 |
|
1371 |
# Print results
|
1372 |
print("Query:", query)
|