MCPcopy Create free account
hub / github.com/MinishLab/vicinity / _dist

Method _dist

vicinity/backends/basic.py:218–222  ·  view source on GitHub ↗

Compute cosine distance.

(self, x: npt.NDArray)

Source from the content-addressed store, hash-verified

216 self._vectors = normalize_or_copy(self._vectors)
217
218 def _dist(self, x: npt.NDArray) -> npt.NDArray:
219 """Compute cosine distance."""
220 x_norm = normalize(x)
221 sim = x_norm.dot(self._vectors.T)
222 return 1 - sim
223
224 def insert(self, vectors: npt.NDArray) -> None:
225 """Insert vectors into the vector space."""

Callers

nothing calls this directly

Calls 1

normalizeFunction · 0.90

Tested by

no test coverage detected