denselinkage.indexing.FaissSearchableIndex

class denselinkage.indexing.FaissSearchableIndex(index: Any, ids: Sequence[str])[source]

Bases: SearchableIndex

Immutable artifact built by FaissFlatIndex — exact (flat) inner-product nearest-neighbour search over a faiss.IndexFlatIP.

Inner product equals cosine for the L2-normalized vectors the embedders produce, so this artifact answers the same similarity as NumpySearchableIndex and the similarity_threshold keeps its meaning across the numpy and FAISS backends. The vectors are fixed at build time (no add); extended() is the not-yet-implemented escape hatch.

property vectors: Any

The indexed vectors (float32, n_records x embedding_dim), as a read-only array reconstructed from the FAISS index — this artifact is immutable.

property ids: Sequence[str]

Record ids aligned positionally with vectors (read-only).

extended(vectors: Any, ids: Sequence[str]) FaissSearchableIndex[source]

Return a NEW artifact holding this index’s vectors plus vectors; this instance is left unchanged (the immutable-artifact guarantee). ids align positionally with vectors and must be disjoint from the ids already indexed; vectors must match the indexed width or DimensionMismatch is raised.

Incremental indexing is out of scope for v1, so the v1 reference artifacts raise NotImplementedError rather than returning None; the signature is fixed pre-freeze so the capability can land later without a breaking change.