Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tweak

Manav Rathi875fd10b5067
diff --git a/web/packages/new/photos/services/ml/clip.ts b/web/packages/new/photos/services/ml/clip.ts
index 4981a25906..e1f14cdde6 100644
--- a/web/packages/new/photos/services/ml/clip.ts
+++ b/web/packages/new/photos/services/ml/clip.ts
@@ -178,7 +178,8 @@ export const clipMatches = async (
const textEmbedding = normalized(t);
const items = (await cachedOrReadCLIPIndexes()).map(
({ fileID, embedding }) =>
-
+ // The dot product gives us cosine similarity here since both the
+ // vectors are already normalized.
[fileID, dotProduct(embedding, textEmbedding)] as const,
);
// This score threshold was obtain heuristically. 0.2 generally gives solid
diff --git a/web/packages/new/photos/services/ml/math.ts b/web/packages/new/photos/services/ml/math.ts
index ca965da0a5..9e78dcd822 100644
--- a/web/packages/new/photos/services/ml/math.ts
+++ b/web/packages/new/photos/services/ml/math.ts
@@ -24,7 +24,7 @@ export const clamp = (value: number, min: number, max: number) =>
* product. When we're computing dot products in a hot loop, skipping over that
* unnecessary renormalization matters.
*
- * When comparing embeddings we usually want is the cosine similarity, but when
+ * When comparing embeddings we usually want is the cosine similarity, but if
* both the embeddings involved are already normalized, we can save the norm
* calculations and directly do their `dotProduct`.
*