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

Method query

vicinity/backends/faiss.py:147–155  ·  view source on GitHub ↗

Perform a k-NN search in the FAISS index.

(self, vectors: npt.NDArray, k: int)

Source from the content-addressed store, hash-verified

145 return self.index.d
146
147 def query(self, vectors: npt.NDArray, k: int) -> QueryResult:
148 """Perform a k-NN search in the FAISS index."""
149 k = min(len(self), k)
150 if self.arguments.metric == "cosine":
151 vectors = normalize(vectors)
152 distances, indices = self.index.search(vectors, k)
153 if self.arguments.metric == "cosine":
154 distances = 1 - distances
155 return list(zip(indices, distances))
156
157 def insert(self, vectors: npt.NDArray) -> None:
158 """Insert vectors into the backend."""

Callers

nothing calls this directly

Calls 1

normalizeFunction · 0.90

Tested by

no test coverage detected