Skip to content

Commit df7ccc3

Browse files
Added function to get nns for sentences from annoy index
1 parent fe72fe0 commit df7ccc3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: index_search/index_search.py

+6
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ def nns_for_images(image, model, annoy_index, no_of_nns=5, include_distances=Tru
2121

2222
return distances
2323

24+
def nns_for_sentence(sentence, model, annoy_index, no_of_nns=5, include_distances=True):
25+
feature = generate_sentence_embedding(sentence, model)
26+
distances = annoy_index.get_nns_by_vector(feature, no_of_nns, include_distances=True)
27+
28+
return distances
29+

0 commit comments

Comments
 (0)