ports/math/py-annoy/files/test-load.py

7 lines
243 B
Python

from annoy import AnnoyIndex
f = 40 # Length of item vector that will be indexed
u = AnnoyIndex(f, 'angular')
u.load('test.ann') # super fast, will just mmap the file
print(u.get_nns_by_item(0, 1000)) # will find the 1000 nearest neighbors