
Solid patterns for building semantic search systems with vector databases like Pinecone and Qdrant. Covers the essentials you actually need: distance metrics, indexing strategies, batch operations, and hybrid search with reranking. The templates handle real production concerns like quantization for memory efficiency, filtering, and proper batching. One thing I appreciate is it doesn't oversell approximate search accuracy, giving you realistic recall expectations for different index types. If you're building RAG systems or recommendation engines, this gives you working code that scales beyond toy datasets.
$ npx -y skills add wshobson/agents --skill similarity-search-patterns --agent claude-codeInstalls into .claude/skills of the current project.
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.
Sponsors