write_lazy_index

write_lazy_index(
    tree,
    embeddings,
    path,
    compression='none',
    quantization='float16',
    metadata=None,
    build_params=None,
    stored_fields=None,
    format_version=1,
    embedding_dim=None,
)

Write a DYF lazy index file (FlatBuffers tree + Arrow IPC leaf data).

Parameters

Name Type Description Default
tree dict Tree dict from build_dyf_tree() (must include hyperplanes/bucket mapping from updated _build_dyf_tree). required
embeddings np.ndarray | None (n, d) array of embedding vectors, or None to write a viz-only file without embeddings (requires embedding_dim). required
path str Output file path (e.g. “index.dyf”). required
compression str “none”, “zstd”, or “lz4” (default: “none”). 'none'
quantization str “float32”, “float16”, “int8”, or “pq-M” where M is the number of sub-quantizers (default: “float16”). For PQ, dim must be divisible by M. Example: “pq-8” for 8 sub-quantizers. 'float16'
metadata dict[str, str] | None Optional dict of string key-value pairs. None
build_params dict[str, int] | None Optional dict with keys: max_depth, num_bits, min_leaf_size, seed. Auto-detected from tree if not provided. None
stored_fields Mapping[str, StoredFieldInput] | None Optional dict mapping field name to array-like of length n_items. Supported types: str/list[str] (Arrow utf8), np.int32/int64/float32/float64 arrays, list[bytes] (Arrow binary). None
format_version int 1 (DYF1, header-based) or 2 (DYF2, footer-based, append-friendly). Default: 1. 1
embedding_dim int | None Embedding dimension. Required when embeddings is None. Inferred from embeddings shape when provided. None