Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build IVF index

Switch a large collection from exact to approximate IVF search with build_ivf, and confirm the change in the stats output.

Small collections search exactly: Telys scans every vector in the target partition and returns the true nearest neighbours. Once a partition grows to tens of thousands of rows, an IVF (inverted-file) index pays off — it groups vectors into lists and probes only the nearest few, trading a sliver of recall for a large speedup. build_ivf performs that switch.

IVF is an optimisation for large collections. Below the crossover, exact search is both faster and perfectly accurate, so there is nothing to build.

Build the index

from telys import Telys

telys = Telys("./telys-data")
col = telys.open_collection("events")

col.build_ivf(min_rows=20000, target_recall=0.98)
col.save()
Parameter
Default
Meaning

min_rows

20000

Row threshold to build at. A partition below this stays on exact search.

target_recall

0.98

The recall the index is built to hit; the probe count is chosen to meet it.

min_rows guards against indexing a partition too small to benefit — raise it if exact search is still fast enough at your size, or lower it if you have measured that IVF wins earlier for your data. Always save() afterward so the index and its settings persist.

Confirm the switch with stats()

stats() reports the index state, so read it before and after to confirm the change:

s = col.stats()
print(s["name"], "->", s)

Manual build vs. tuning

build_ivf is the manual lever. For a data-driven choice of target_recall and the exact-crossover point, run the Tuner instead: apply_tuning builds per-partition IVF, sets the crossover, and picks the probe count from a measured workload. Use build_ivf when you already know you want IVF; use tuning when you want Telys to decide. See Run a tuning pass.

build_ivf is exposed over a RemoteTelys connection too, so you can build the index against a served collection. Tuning (tune / apply_tuning) is local-only — apply a saved tuning plan on the host, or build the index explicitly from the client.

Expected result

Before the build, the collection reports exact search; after, it reports an IVF index with a probe count. Exact field names come from the runtime, so the shape below is illustrative:

The live row count (external_ids) is unchanged — build_ivf only changes how the collection is searched, not what it contains.

Next steps

Last updated

Was this helpful?