rag-implementation
БесплатноБез исполняемых скриптовНе проверенComprehensive guide to implementing RAG systems including vector database selection, chunking strategies, embedding models, and retrieval optimization. Use…
Об этом скилле
RAG Implementation Patterns
Comprehensive guide to implementing Retrieval-Augmented Generation (RAG) systems including vector database selection, chunking strategies, embedding models, retrieval optimization, and production deployment patterns.
Quick Reference
When to use this skill:
- Building RAG/semantic search systems
- Implementing document retrieval pipelines
- Optimizing vector database performance
- Debugging retrieval quality issues
- Choosing between vector database options
- Designing chunking strategies
- Implementing hybrid search
Technologies covered:
- Vector DBs: Qdrant, Pinecone, Chroma, Weaviate, Milvus
- Embeddings: OpenAI, Sentence Transformers, Cohere
- Frameworks: LangChain, LlamaIndex, Haystack
Part 1: Vector Database Selection
Database Comparison Matrix
| Database | Best For | Deployment | Performance | Cost |
|---|---|---|---|---|
| Qdrant | Self-hosted, production | Docker/K8s | Excellent (Rust) | Free (self-host) |
| Pinecone | Managed, rapid prototyping | Cloud | Excellent | Pay-per-use |
| Chroma | Local development, embedded | In-process | Good (Python) | Free |
| Weaviate | Complex schemas, GraphQL | Docker/Cloud | Excellent (Go) | Free + Cloud |
| Milvus | Large-scale, distributed | K8s | Excellent (C++) | Free (self-host) |
Qdrant Setup (Recommended for Production)
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct
# Initialize client (local or cloud)
client = QdrantClient(url="http://localhost:6333") # or cloud URL
# Create collection
client.create_collection(
collection_name="documents",
vectors_config=VectorParams(
size=1536, # OpenAI text-embedding-3-small dimension
distance=Distance.COSINE # or DOT, EUCLID
)
)
# Insert vectors with payload
client.upsert(
collection_name="documents",
points=[
PointStruct(
id=1,
vector=[0.1, 0.2, ...], # 1536 dimensions
payload={
"text": "Document content",
"source": "doc.pdf",
"page": 1,
"metadata": {...}
}
)
]
)
# Search
results = client.search(
collection_name="documents",
query_vector=[0.1, 0.2, ...],
limit=5,
score_threshold=0.7 # Minimum similarity
)
Pinecone Setup (Managed Service)
from pinecone import Pinecone, ServerlessSpec
# Initialize
pc = Pinecone(api_key="your-key")
# Create index
pc.create_index(
name="documents",
dimension=1536,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-east-1")
)
# Get index
index = pc.Index("documents")
# Upsert vectors
index.upsert(vectors=[
("doc1", [0.1, 0.2, ...], {"text": "...", "source": "..."})
])
# Query
results = index.query(
vector=[0.1, 0.2, ...],
top_k=5,
include_metadata=True
)
Part 2: Chunking Strategies
Strategy 1: Fixed-Size Chunking (Simple, Fast)
def fixed_size_chunking(text: str, chunk_size: int = 512, overlap: int = 50) -> list[str]:
"""
Split text into fixed-size chunks with overlap.
Pros: Simple, predictable chunk sizes
Cons: May break mid-sentence, poor semantic boundaries
"""
words = text.split()
chunks = []
for i in range(0, len(words), chunk_size - overlap):
chunk = ' '.join(words[i:i + chunk_size])
chunks.append(chunk)
return chunks
# Usage
chunks = fixed_size_chunking(document, chunk_size=512, overlap=50)
When to use:
- Simple documents (logs, transcripts)
- Prototyping/MVP
- Consistent token budgets needed
Strategy 2: Semantic Chunking (Better Quality)
from langchain.text_splitter import RecursiveCharacterTextSplitter
def semantic_chunking(text: str, chunk_size: int = 1000, overlap: int = 200) -> list[str]:
"""
Split on semantic boundaries (paragraphs, sentences).
Pros: Preserves meaning, better retrieval quality
Cons: Variable chunk sizes, slower processing
"""
splitter = RecursiveCharacterTextSplitter(
chunk_size=chunk_size,
chunk_overlap=overlap,
separators=["\n\n", "\n", ". ", " ", ""], # Priority order
length_function=len
)
return splitter.split_text(text)
# Usage
chunks = semantic_chunking(document, chunk_size=1000, overlap=200)
When to use:
- Long-form documents (articles, books, reports)
- Quality > speed
- Natural language content
Strategy 3: Hierarchical Chunking (Best for Structured Docs)
def hierarchical_chunking(document: dict) -> list[dict]:
"""
Chunk based on document structure (sections, subsections).
Pros: Preserves hierarchy, enables parent-child retrieval
Cons: Requires structured input, more complex
"""
chunks = []
for section in document['sections']:
# Parent chunk (section summary)
Установить rag-implementation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл rag-implementation?
Comprehensive guide to implementing RAG systems including vector database selection, chunking strategies, embedding models, and retrieval optimization. Use when building RAG systems, implementing semantic search, optimizing retrieval quality, or debugging RAG performance issues.
Как установить скилл rag-implementation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rag-implementation запускает скрипты?
Нет, скилл состоит только из инструкций (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