denselinkage.linkage.LinkageIndex¶
- class denselinkage.linkage.LinkageIndex(*, blocking_index: BlockingIndex, matcher: Matcher)[source]¶
Bases:
objectPrepared linkage state: a built
BlockingIndexfused with aMatcher. Constructed byDenseLinker.index; not typically built directly.kw_onlyfor consistency withDenseLinker.- candidates(source: Source, *, top_k: int | None = None, similarity_threshold: float | None = None) list[CandidatePair][source]¶
Blocking-only counterpart to
query(): readsourceand return the blocker’sCandidatePairobjects (record_a= indexed,record_b= fromsource) without running the matcher — the ergonomic input toblocking_metrics/pair_completeness_at_k.top_k/similarity_thresholdoverride the built blocker’s spec for this call only (e.g. a largetop_kto sweep pair-completeness over several k), reusing this prepared index instead of rebuilding it.InvalidTopKif an overridetop_k <= 0; otherwise the sameRecordReaderfailure modes asquery().
- query(source: Source) LinkageResult[source]¶
Query the prepared index with
source.Raises (from the RecordReader seam):
UnknownIdColumnifsource.id_columnis absent,EmptySourceif the frame is empty,DuplicateRecordIdon duplicate ids,DimensionMismatchif the query embedding width differs from the indexed vectors. All subclassdenselinkage.core.errors.DenseLinkageError.
- save(path: str | Path) None[source]¶
Persist this prepared index to
path(a directory) so the reference set can be reused later without re-embedding. Supported for the dependency-free reference stack (DenseBlockeroverNumpyFlatIndex); other backends raiseNotImplementedError. The matcher is not persisted — supply one (and the matching embedder) toload().
- classmethod load(path: str | Path, *, embedder: Embedder, matcher: Matcher) LinkageIndex[source]¶
Reload an index saved by
save(), re-supplying the liveembedderandmatcher. Theembeddermust match the stored provenance (model_id/embedding_dim) ordenselinkage.core.errors.IncompatibleStoreis raised — a persisted index cannot be queried with a different embedding model.