> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/sdk-user-guide/advanced-user-guide/ann/ann-ivf-vct.md).

# ANN (IVF\_VCT)

`IVF_VCT` is **enVector's customized ANN algorithm** designed for the fastest approximate search over FHE-encrypted indexes.

***

## When to use

* You need better performance for enVector-customized case.
* You can supply centroids trained on your specific dataset.

***

## Key parameters

* `index_type` (str): Set to `"IVF_VCT"`.
* `nlist` (int, default `128`): Number of coarse clusters.
* `default_nprobe` (int, default `1`): Number of clusters scanned at query time. Override per-search via `search_params={"nprobe": ...}`.
* `centroids`: Pre-trained centroids on the dataset.

***

## Example

```python
import numpy as np
import pyenvector as ev

# 1) Init with preset/eval_mode suited to VCT
ev.init(
    address="localhost:50050",
    key_path="./keys",
    key_id="test-key",
    eval_mode="mm32",
    preset="ip2",
)

# 2) Load pre-trained centroids on your dataset
centroids = np.load("./centroids.npy")  # shape: (nlist, dim)

# 3) Create IVF_VCT index
index_params = {
    "index_type": "IVF_VCT",
    "nlist": 32768,
    "default_nprobe": 6,
    "centroids": centroids,
}
index = ev.create_index("test_index", dim=768, index_params=index_params)

# 4) Insert and wait until searchable
request_ids: list[str] = []
index.insert(vectors, metadata=metadata, request_ids=request_ids, execute_until="flush", await_completion=False)
index.indexing(request_ids)
index.load()

# 5) Search
query = vectors[0]
search_index = ev.Index("test_index")
result = search_index.search(
    query,
    top_k=10,
    search_params={"nprobe": 6},
)[0]
```

***

## Tuning tips

* Increase `nprobe` for higher recall (typical range 4–16); decrease for lower latency.
* Default `nlist=32768` is tuned for large indexes. Modify it for your datasets — and ensure your centroids file has matching shape `(nlist, dim)`.
* Always L2-normalize vectors when using an Inner Product preset.

***

## See also

* [Index Operation Lifecycle](/1.4.x/sdk-user-guide/advanced-user-guide/index-operation-lifecycle.md) — `request_ids` capture and `wait_for_inserts_searchable` behavior.
* [enVector in VectorDBBench](https://github.com/CryptoLabInc/VectorDBBench) — end-to-end benchmarking with provided datasets and centroids.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.4.x/sdk-user-guide/advanced-user-guide/ann/ann-ivf-vct.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
