You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -359,6 +359,32 @@ index.dispose();
359
359
-**No training required**
360
360
-**Use case:** Large-scale production systems, best overall performance
361
361
362
+
### FLAT_IP (IndexFlatIP) - Inner Product for Cosine Similarity
363
+
364
+
-**Best for:** Cosine similarity with L2-normalized vectors (e.g., OpenAI embeddings)
365
+
-**Speed:** O(n) per query - same as FLAT_L2
366
+
-**Accuracy:** 100% recall (exact results)
367
+
-**Memory:** Same as FLAT_L2
368
+
-**Requires:** Vectors must be L2-normalized before adding
369
+
-**Use case:** When you need cosine similarity (with normalized vectors, inner product = cosine similarity)
370
+
-**Note:** For cosine similarity, normalize vectors first: `cosine_similarity(a, b) = dot_product(normalize(a), normalize(b))`
371
+
372
+
**When to use FLAT_IP vs Database Cosine Functions:**
373
+
374
+
FLAT_IP is optimized for large-scale, high-dimensional vector searches. Database cosine functions (PostgreSQL `pgvector`, MongoDB, etc.) are simpler for SQL integration but may be slower at scale.
375
+
376
+
**Choose FLAT_IP when:**
377
+
- Large datasets (100k+ vectors)
378
+
- High-dimensional vectors (512+ dimensions)
379
+
- Frequent searches (better performance)
380
+
- Need batch operations or complex indexes (IVF/HNSW with IP)
0 commit comments