similarity-search-patterns
This skill provides vector similarity search patterns, including distance metrics and index selection for optimizing search performance.
Install
mkdir -p .claude/skills/similarity-search-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/740" && unzip -o skill.zip -d .claude/skills/similarity-search-patterns && rm skill.zipInstalls to .claude/skills/similarity-search-patterns
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.Key capabilities
- →Select appropriate distance metrics
- →Implement different index types
- →Tune search parameters for recall and speed
- →Combine semantic and keyword search
- →Monitor search quality and latency
How it works
It provides patterns for vector similarity search, guiding the selection of distance metrics and index types like HNSW or IVF+PQ based on dataset size and performance needs.
Inputs & outputs
When to use similarity-search-patterns
- →Build a semantic search system using vector embeddings
- →Optimize retrieval latency in a RAG pipeline
- →Implement nearest neighbor search for recommendations
About this skill
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
When not to use it
- →When skipping evaluation of search quality
- →When over-indexing small datasets
Limitations
- →Vector storage costs can increase with scale
- →Requires evaluation to balance recall and latency
How it compares
It offers structured implementation patterns for vector search rather than ad-hoc query implementation.
Compared to similar skills
similarity-search-patterns side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| similarity-search-patterns (this skill) | 3 | 2mo | No flags | Advanced |
| cocoindex | 6 | 9mo | Review | Intermediate |
| rag-index | 0 | 6mo | Review | Intermediate |
| reasoningbank-with-agentdb | 5 | 9mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by wshobson
View all by wshobson →You might also like
cocoindex
cocoindex-io
Comprehensive toolkit for developing with the CocoIndex library. Use when users need to create data transformation pipelines (flows), write custom functions, or operate flows via CLI or API. Covers building ETL workflows for AI data processing, including embedding documents into vector databases, building knowledge graphs, creating search indexes, or processing data streams with incremental updates.
rag-index
brifl
Experimental RAG indexing utilities (scanner + indexer + retriever).
reasoningbank-with-agentdb
ruvnet
Implement ReasoningBank adaptive learning with AgentDB's 150x faster vector database. Includes trajectory tracking, verdict judgment, memory distillation, and pattern recognition. Use when building self-learning agents, optimizing decision-making, or implementing experience replay systems.
ai-engineer
sickn33
Build production-ready LLM applications, advanced RAG systems, and intelligent agents. Implements vector search, multimodal AI, agent orchestration, and enterprise AI integrations. Use PROACTIVELY for LLM features, chatbots, AI agents, or AI-powered applications.
llm-application-dev
skillcreatorai
Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.
langgraph-chat-google-genai
akhilgupta01
Using ChatGoogleGenerativeAI, a chat model wrapper from langchain for Google Gemini series, for various applications including file processing.