sliftutils 1.4.83 → 1.4.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import cborx from "cbor-x";
|
|
|
2
2
|
import { Database, namespaceDatabase } from "./Database";
|
|
3
3
|
import { TransactionSetStore, transactionRead, transactionMutate, transactionDelete, replayTransactionStore } from "./transactionSet";
|
|
4
4
|
import { StoredEmbedding, EmbeddingFormat, getCloseness, embeddingToFloat32, releaseFloat32, encodeEmbedding, hashEmbedding } from "../embeddingFormats";
|
|
5
|
+
import { isDefined } from "sliftutils/misc/types";
|
|
5
6
|
|
|
6
7
|
export type IvfConfig = {
|
|
7
8
|
model: string;
|
|
@@ -240,8 +241,7 @@ export function searchEmbeddings(
|
|
|
240
241
|
if (!centroids.size) return [];
|
|
241
242
|
const probeCellCount = Math.max(1, Math.ceil(options.probeBudget / config.cellTargetSize));
|
|
242
243
|
const probeCellIds = rankCellsByCloseness(query, centroids).slice(0, probeCellCount);
|
|
243
|
-
const stores =
|
|
244
|
-
if (!stores) return undefined;
|
|
244
|
+
const stores = probeCellIds.map(cellId => database.readData(root => root.cells[cellId])).filter(isDefined);
|
|
245
245
|
for (const store of stores) {
|
|
246
246
|
const members = replayTransactionStore<StoredEmbedding>(store);
|
|
247
247
|
for (const ref of members.keys()) {
|