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.
.claude/skills/wshobson-similarity-search-patterns/SKILL.md| 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.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-13 | fail→fail | 10,425 | 8,460 | -19% | 1 | 1 | 0% | 1,948 | 2,174 | +12% | 0 | 0 | — |
case-14 | pass→pass | 12,211 | 14,138 | +16% | 1 | 1 | 0% | 1,906 | 2,892 | +52% | 0 | 0 | — |
case-01 | pass→pass | 12,124 | 6,901 | -43% | 1 | 1 | 0% | 2,292 | 1,891 | -17% | 0 | 0 | — |
case-02 | pass→pass | 4,432 | 3,626 | -18% | 1 | 1 | 0% | 811 | 1,101 | +36% | 0 | 0 | — |
case-03 | pass→pass | 9,092 | 8,611 | -5% | 1 | 1 | 0% | 1,948 | 2,415 | +24% | 0 | 0 | — |
case-04 | pass→pass | 10,071 | 7,371 | -27% | 1 | 1 | 0% | 1,732 | 1,967 | +14% | 0 | 0 | — |
case-05 | pass→pass | 10,924 | 8,240 | -25% | 1 | 1 | 0% | 1,993 | 1,839 | -8% | 0 | 0 | — |
case-06 | fail→fail | 9,926 | 7,313 | -26% | 1 | 1 | 0% | 1,908 | 1,846 | -3% | 0 | 0 | — |
case-07 | pass→pass | 9,810 | 6,017 | -39% | 1 | 1 | 0% | 1,753 | 1,550 | -12% | 0 | 0 | — |
case-08 | pass→pass | 6,182 | 6,133 | -1% | 1 | 1 | 0% | 1,189 | 1,723 | +45% | 0 | 0 | — |
case-09 | pass→fail | 10,821 | 5,262 | -51% | 1 | 1 | 0% | 2,087 | 1,622 | -22% | 0 | 0 | — |
case-10 | pass→pass | 13,449 | 8,112 | -40% | 1 | 1 | 0% | 2,470 | 2,050 | -17% | 0 | 0 | — |
case-11 | pass→pass | 6,935 | 6,536 | -6% | 1 | 1 | 0% | 1,269 | 1,746 | +38% | 0 | 0 | — |
case-12 | pass→pass | 6,321 | 4,709 | -26% | 1 | 1 | 0% | 1,175 | 1,397 | +19% | 0 | 0 | — |
case-15 | pass→pass | 9,848 | 11,675 | +19% | 1 | 1 | 0% | 1,828 | 2,653 | +45% | 0 | 0 | — |
case-16 | pass→pass | 7,613 | 5,954 | -22% | 1 | 1 | 0% | 1,447 | 1,561 | +8% | 0 | 0 | — |
case-17 | pass→pass | 7,181 | 4,006 | -44% | 1 | 1 | 0% | 1,401 | 1,276 | -9% | 0 | 0 | — |
case-18 | pass→pass | 9,336 | 5,692 | -39% | 1 | 1 | 0% | 1,805 | 1,524 | -16% | 0 | 0 | — |
case-19 | fail→pass | 11,439 | 9,311 | -19% | 1 | 1 | 0% | 2,434 | 2,644 | +9% | 0 | 0 | — |
case-20 | pass→pass | 6,032 | 5,037 | -16% | 1 | 1 | 0% | 1,034 | 1,339 | +29% | 0 | 0 | — |
case-21 | pass→pass | 72,636 | 10,589 | -85% | 1 | 1 | 0% | 2,071 | 2,331 | +13% | 0 | 0 | — |
case-22 | pass→pass | 14,926 | 12,999 | -13% | 1 | 1 | 0% | 3,008 | 2,701 | -10% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of 0 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.