similarity-search-patterns – Other skill for AI agents
Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
Install the similarity-search-patterns skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/similarity-search-patterns-9941d.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /similarity-search-patterns – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/similarity-search-patterns-9941d.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $similarity-search-patterns – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/similarity-search-patterns-9941d.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /similarity-search-patterns – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/similarity-search-patterns-9941d.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /similarity-search-patterns – then describe the task you want done.
SKILL.md content
Similarity Search Patterns
Patterns for implementing efficient similarity search in production systems.
When to Use This Skill
- Building semantic search systems
- Implementing RAG retrieval
- Creating recommendation engines
- Optimizing search latency
- Scaling to millions of vectors
- Combining semantic and keyword search
Core Concepts
1. Distance Metrics
| 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 |
2. Index Types
┌─────────────────────────────────────────────────┐
│ 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 │
└─────────────┴───────────────┴───────────────────┘Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Use appropriate index - HNSW for most cases
- Tune parameters - ef_search, nprobe for recall/speed
- Implement hybrid search - Combine with keyword search
- Monitor recall - Measure search quality
- Pre-filter when possible - Reduce search space
Don'ts
- Don't skip evaluation - Measure before optimizing
- Don't over-index - Start with flat, scale up
- Don't ignore latency - P99 matters for UX
- Don't forget costs - Vector storage adds up
Related skills
- meetings – Use when someone wants to decide whether a meeting is worth calling, price a meeting in…
- ddd-context-mapping – Map relationships between bounded contexts and define integration contracts using DDD…
- decision-navigator – Guide stuck or overwhelmed users through targeted branching questions until they reach…
- deed-page – Publish an HTML file or static folder to a permanent public https://<slug>.deed.page/…
- defi-protocol-templates – Implement DeFi protocols with educational templates for staking, AMMs, governance, and…
- defi-yield-strategy-allocator – Multi-vault automated yield strategy allocation register: APY benchmarks, impermanent…
- scikit-survival – Builds, evaluates, and audits right-censored or competing-risk survival workflows with…
- dei-dashboard – Diversity, equity and inclusion dashboard: metric by department and period, value…