-
-
Save bet02024/f726bcc6d0232ab246376ac88a385b4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import faiss | |
except: | |
!pip install faiss-cpu -q | |
import faiss | |
# Build the index | |
d = embeddings.shape[1] # Dimension | |
index = faiss.IndexFlatL2(d) | |
# Add vectors to the index | |
index.add(embeddings) | |
print(index.ntotal) | |
# Sanity Check | |
# "model" is our Sentence Transformer model | |
xq = model.encode(["I am not able to find my issue, where is it gone?"]) | |
k = 1 | |
D, I = index.search(xq, k) | |
print(corpus[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment