usearch的简单使用
$ pip install usearch
Looking in indexes: https: / / pypi. tuna. tsinghua. edu. cn/ simple
Collecting usearch
Downloading https: / / pypi. tuna. tsinghua. edu. cn/ packages/ ba/ f4/ 24124f65ea3e940e54af29d55204ddfbeafa86d6b94b63c2e99baff2f7d6/ usearch- 2.8 .14 - cp38- cp38- manylinux_2_28_x86_64. whl ( 1.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5 / 1.5 MB 17.0 MB/ s eta 0 : 00 : 00
Requirement already satisfied: numpy in / home/ ubuntu/ anaconda3/ envs/ vglm2/ lib/ python3. 8 / site- packages ( from usearch) ( 1.23 .1 )
Requirement already satisfied: tqdm in / home/ ubuntu/ anaconda3/ envs/ vglm2/ lib/ python3. 8 / site- packages ( from usearch) ( 4.66 .1 )
Installing collected packages: usearch
Successfully installed usearch- 2.8 .14
一个简单的例子(注:本例子在运行时向index中不断添加项目,并将最后的index持久化为一个文件,在运行时由于添加项目内存占用会不断增加)
import numpy as np
from usearch. index import Index, MetricKind, Matches
ndim = 131072
index_path = "test.usearch"
index = Index (
ndim= ndim, # Define the number of dim