Skip to content

Instantly share code, notes, and snippets.

@joshua-taylor
Last active October 10, 2020 15:20
Show Gist options
  • Save joshua-taylor/651f690af653820c107f13021bc42352 to your computer and use it in GitHub Desktop.
Save joshua-taylor/651f690af653820c107f13021bc42352 to your computer and use it in GitHub Desktop.
import nmslib
# create a matrix from our document vectors
data = np.vstack(weighted_doc_vects)
# initialize a new index, using a HNSW index on Cosine Similarity
index = nmslib.init(method='hnsw', space='cosinesimil')
index.addDataPointBatch(data)
index.createIndex({'post': 2}, print_progress=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment