Similarity Search Patterns
Unverified●30/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add similarity-search-patternsWho is stuck, and on what
Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
The whole source
Frontmatter — 2 properties
| name | similarity-search-patterns |
|---|---|
| description | Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance. |
| 1 | --- |
| 2 | name: similarity-search-patterns |
| 3 | description: Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance. |
| 4 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 5 | |
| 6 | # Similarity Search Patterns |
| 7 | |
| 8 | Patterns for implementing efficient similarity search in production systems. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | - Building semantic search systems |
| 13 | - Implementing RAG retrieval |
| 14 | - Creating recommendation engines |
| 15 | - Optimizing search latency |
| 16 | - Scaling to millions of vectors |
| 17 | - Combining semantic and keyword search |
| 18 | |
| 19 | ## Core Concepts |
| 20 | |
| 21 | ### 1. Distance Metrics |
| 22 | |
| 23 | | Metric | Formula | Best For | |
| 24 | | ------------------ | ------------------ | --------------------- | --- | -------------- | |
| 25 | | **Cosine** | 1 - (A·B)/(‖A‖‖B‖) | Normalized embeddings | |
| 26 | | **Euclidean (L2)** | √Σ(a-b)² | Raw embeddings | |
| 27 | | **Dot Product** | A·B | Magnitude matters | |
| 28 | | **Manhattan (L1)** | Σ | a-b | | Sparse vectors | |
| 29 | |
| 30 | ### 2. Index Types |
| 31 | |
| 32 | ``` |
| 33 | ┌─────────────────────────────────────────────────┐ |
| 34 | │ Index Types │ |
| 35 | ├─────────────┬───────────────┬───────────────────┤ |
| 36 | │ Flat │ HNSW │ IVF+PQ │ |
| 37 | │ (Exact) │ (Graph-based) │ (Quantized) │ |
| 38 | ├─────────────┼───────────────┼───────────────────┤ |
| 39 | │ O(n) search │ O(log n) │ O(√n) │ |
| 40 | │ 100% recall │ ~95-99% │ ~90-95% │ |
| 41 | │ Small data │ Medium-Large │ Very Large │ |
| 42 | └─────────────┴───────────────┴───────────────────┘ |
| 43 | ``` |
| 44 | |
| 45 | ## Templates and detailed worked examples |
| 46 | |
| 47 | Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates. |
| 48 | |
| 49 | ## Best Practices |
| 50 | |
| 51 | ### Do's |
| 52 | |
| 53 | - **Use appropriate index** - HNSW for most cases |
| 54 | - **Tune parameters** - ef_search, nprobe for recall/speed |
| 55 | - **Implement hybrid search** - Combine with keyword search |
| 56 | - **Monitor recall** - Measure search quality |
| 57 | - **Pre-filter when possible** - Reduce search space |
| 58 | |
| 59 | ### Don'ts |
| 60 | |
| 61 | - **Don't skip evaluation** - Measure before optimizing |
| 62 | - **Don't over-index** - Start with flat, scale up |
| 63 | - **Don't ignore latency** - P99 matters for UX |
| 64 | - **Don't forget costs** - Vector storage adds up |
| 65 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Task Coordination StrategiesDecompose complex tasks, design dependency graphs, and coordinate multi-agent work with proper task descriptions and workload balancing. Use this skill when breaking down work for agent teams, managing task dependencies, or monitoring team progress.◐◐◐◐◐●35/40Ebay Seller Tools·····●34/40Tough Decision Advisor: Every Angle ConsideredHand in a decision you're stuck on. Get back a clear breakdown of every angle — the trade-offs, the risks, the blind spot, and a recommended path.●····●32/40DHDNA Profiler — Cognitive Pattern ExtractionPaste any email, proposal, or note someone wrote, and get back a plain-language read on how they think, what drives their decisions, and how they communicate.●····●32/40