Vector Database Patterns
БесплатноБез исполняемых скриптовНе проверенComprehensive guide to vector databases including Pinecone, Qdrant, Weaviate, embedding strategies, and similarity search.
от majiayu000★ 31 звезда на GitHubОб этом скилле
Vector Database Patterns
Overview
Vector databases are specialized databases designed to store, index, and query high-dimensional vectors efficiently. They enable similarity search by finding vectors that are "closest" to a query vector using various distance metrics. This skill covers Pinecone, Qdrant, Weaviate, embedding strategies, similarity search, performance optimization, and production considerations.
Prerequisites
- Understanding of vectors and embeddings
- Knowledge of machine learning concepts
- Familiarity with Python or TypeScript
- Understanding of similarity metrics (cosine, Euclidean, dot product)
- Basic knowledge of database concepts
Key Concepts
Vector Database Fundamentals
- Vectors: Numerical representations of data (text, images, audio) in high-dimensional space
- Embeddings: Vectors generated by machine learning models that capture semantic meaning
- Distance Metrics: Measures of similarity between vectors (cosine, Euclidean, dot product)
- Indexing: Data structures that enable fast similarity search
- Metadata: Additional information associated with vectors for filtering
Vector Database Types
- Pinecone: Managed service, easy setup, good for production
- Qdrant: Open-source, self-hosted option, flexible
- Weaviate: Open-source, GraphQL API, good for multimodal
Use Cases
- Semantic search (finding similar documents, products, images)
- Recommendation systems
- Anomaly detection
- Natural language processing tasks
- Computer vision applications
- Personalization engines
- Knowledge retrieval for RAG (Retrieval-Augmented Generation)
Implementation Guide
Pinecone
Setup and Indexing
# Install Pinecone client
# pip install pinecone-client
import pinecone
from pinecone import Pinecone, ServerlessSpec
# Initialize Pinecone
pc = Pinecone(api_key="your-api-key")
# Create index
pc.create_index(
name="my-index",
dimension=1536, # OpenAI embedding dimension
metric="cosine", # or "euclidean", "dotproduct"
spec=ServerlessSpec(
cloud="aws",
region="us-east-1"
)
)
# Connect to index
index = pc.Index("my-index")
# Check index stats
stats = index.describe_index_stats()
print(f"Total vectors: {stats['total_vector_count']}")
print(f"Dimension: {stats['dimension']}")
// Install Pinecone client
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Initialize Pinecone
const pinecone = new Pinecone({
apiKey: 'your-api-key'
});
// Create index
await pinecone.createIndex({
name: 'my-index',
dimension: 1536,
metric: 'cosine',
spec: {
serverless: {
cloud: 'aws',
region: 'us-east-1'
}
}
});
// Connect to index
const index = pinecone.index('my-index');
// Check index stats
const stats = await index.describeIndexStats();
console.log('Total vectors:', stats.totalVectorCount);
console.log('Dimension:', stats.dimension);
Upserting Vectors
# Upsert single vector
index.upsert(
vectors=[
{
"id": "doc1",
"values": [0.1, 0.2, 0.3, ...], # 1536-dimensional vector
"metadata": {
"title": "Document 1",
"category": "technology",
"date": "2024-01-01"
}
}
]
)
# Upsert multiple vectors
index.upsert(
vectors=[
{
"id": "doc1",
"values": vector1,
"metadata": {"title": "Document 1", "category": "tech"}
},
{
"id": "doc2",
"values": vector2,
"metadata": {"title": "Document 2", "category": "science"}
},
{
"id": "doc3",
"values": vector3,
"metadata": {"title": "Document 3", "category": "tech"}
}
],
namespace="documents"
)
# Upsert in batches
from tqdm import tqdm
def upsert_in_batches(vectors, batch_size=100):
for i in tqdm(range(0, len(vectors), batch_size)):
batch = vectors[i:i + batch_size]
index.upsert(vectors=batch)
// Upsert single vector
await index.upsert([
{
id: 'doc1',
values: [0.1, 0.2, 0.3, ...], // 1536-dimensional vector
metadata: {
title: 'Document 1',
category: 'technology',
date: '2024-01-01'
}
}
]);
// Upsert multiple vectors
await index.upsert([
{
id: 'doc1',
values: vector1,
metadata: { title: 'Document 1', category: 'tech' }
},
{
id: 'doc2',
values: vector2,
metadata: { title: 'Document 2', category: 'science' }
},
{
id: 'doc3',
values: vector3,
metadata: { title: 'Document 3', category: 'tech' }
}
]);
// Upsert with namespace
await index.upsert([
{
id: 'doc1',
values: vector1,
metadata: { title: 'Document 1' }
}
], 'documents');
Querying
# Basic similarity search
results = index.query(
vector=query_vector,
Установить Vector Database Patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Vector Database Patterns?
Comprehensive guide to vector databases including Pinecone, Qdrant, Weaviate, embedding strategies, and similarity search.
Как установить скилл Vector Database Patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Vector Database Patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub