Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-19 | ✗→✓ | ▲ Improved | 9% | 0% |
| case-09 | ✓→✗ | ▼ Worse | -22% | 0% |
| case-14 | ✓→✓ | = Same ✓ | 52% | 0% |
| case-01 | ✓→✓ | = Same ✓ | -17% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 36% | 0% |
Patterns for implementing efficient similarity search in production systems.
| Metric | Formula | Best For | | ------------------ | ------------------ | --------------------- | --- | -------------- | | Cosine | 1 - (A·B)/(‖A‖‖B‖) | Normalized embeddings | | Euclidean (L2) | √Σ(a-b)² | Raw embeddings | | Dot Product | A·B | Magnitude matters | | Manhattan (L1) | Σ | a-b | | Sparse vectors |
┌─────────────────────────────────────────────────┐
│ Index Types │
├─────────────┬───────────────┬───────────────────┤
│ Flat │ HNSW │ IVF+PQ │
│ (Exact) │ (Graph-based) │ (Quantized) │
├─────────────┼───────────────┼───────────────────┤
│ O(n) search │ O(log n) │ O(√n) │
│ 100% recall │ ~95-99% │ ~90-95% │
│ Small data │ Medium-Large │ Very Large │
└─────────────┴───────────────┴───────────────────┘Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Other measured skills in the registry, with their headline benchmark lift.