similarity-search-patterns
Helps your agent find similar items in large datasets. It's useful for building similarity searches or finding an item's nearest neighbors.
What it does
This tool helps find similar information within large datasets, like searching for 'similar items' in a huge catalog. It uses advanced techniques to do this quickly and efficiently.
When to use it
- ✓When you want to build a search system that understands the meaning of your query.
- ✓When building a system that answers questions based on documents.
- ✓To create personalized recommendations for products or content.
Example of what to ask your AI
“Find documents similar to this text about vegan cooking.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
Internally, it converts your data into numbers (vectors) and uses mathematical methods to calculate which numbers are closest to each other. It organizes these numbers into special indexes for very fast searching.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add wshobson/agents --skill similarity-search-patternsOr download just the file:
curl -L https://raw.githubusercontent.com/wshobson/agents/main/plugins/llm-application-dev/skills/similarity-search-patterns/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
FAQ
What are 'distance metrics'?
These are mathematical formulas that measure how 'far' or 'close' two sets of numbers (vectors) are to each other. This helps in finding similar information.
What are 'index types'?
These are different ways to organize the numerical data to make searching faster. Some are more accurate, others faster, and each is good for a different data size.
What is 'hybrid search'?
It's combining meaning-based (semantic) search with exact keyword search. This way, you find results that are both semantically relevant and contain the words you typed.
Details
Original description by the author
Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.
repo: wshobson/agents
Popularity
- GitHub stars
- 41k
- Ranking position
- #4893
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
screen-reader-testing
Has your agent test websites using screen readers to ensure they are accessible.
wshobson/agents
wcag-audit-patterns
Helps your agent audit websites for accessibility and fix issues according to WCAG guidelines.
wshobson/agents
multi-reviewer-patterns
Enables your agent to coordinate parallel code reviews, deduplicating findings and consolidating reports.
wshobson/agents
parallel-debugging
Allows the agent to debug complex issues with parallel investigations and root cause analysis.
wshobson/agents
Similar skills
pytorch-patterns
Helps your agent use PyTorch for machine learning models. It applies best practices for efficient model training and ensures reproducible results.
affaan-m/ECC
evm-token-decimals
Helps your agent avoid errors with decimal numbers across different blockchain networks. It ensures token values are accurate in transactions and calculations.
affaan-m/ECC
knowledge-agent
Creates and queries knowledge bases using AI. It allows asking questions about past work or compiling expertise on a topic.
thedotmack/claude-mem