Created
July 2, 2023 06:07
-
-
Save mrmaheshrajput/be57cea489939650036a998146cf20e7 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