Reference
db.configure_ivf
Set the IVF partition parameters.
db.configure_ivf(nlist: int = 100, nprobe: int = 10) -> NoneParameters
Section titled “Parameters”-
nlist : int, default
100Number of partitions (centroids). -
nprobe : int, default
10Partitions searched per query: higher is more accurate, slower.
Returns
Section titled “Returns”None.
Raises
Section titled “Raises”- Call before
set_mode("ivf")so the index is created with these values. In"ivf"mode it replaces the index with an untrained one. Either way, calltrain_ivfafterwards. - Values are not range-checked; use positive values with
nprobe <= nlist. - Thread safety: a database object is safe to share between threads. This method releases the GIL; writes (
add,upsert,delete,save,compact, mode and IVF changes) take an exclusive lock and wait for each other and for running searches instead of failing. See Threads and processes.
Examples
Section titled “Examples”import srvdb
db = srvdb.create("./vectors", dimension=128)v = [1.0] + [0.0] * 127 # tiny 128-dimension vectorsw = [0.0, 1.0] + [0.0] * 126db.add(["a", "b"], [v, w], ["{}", "{}"])db.configure_ivf(nlist=2, nprobe=1)db.set_mode("ivf")db.train_ivf()print(db.search(v, k=1))# [('a', 0.9999999403953552)]See also
Section titled “See also”db.train_ivf: Train the IVF index on the stored vectors.db.set_mode: Switch the index mode of an open database.
Was this page helpful? Tell us in Discussions.