Use when user needs to search across multiple vector fields. Triggers on: multi-vector, multiple embeddings, multi-field search, title + content, combined vectors, different aspects of same item.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Use when user needs to search across multiple vector fields. Triggers on: multi-vector, multiple embeddings, multi-field search, title + content, combined vectors, different aspects of same item.
Multi-Vector Search
Search across multiple vector fields simultaneously — find items that match across different semantic aspects like title, description, and reviews.
When to Activate
Activate this skill when:
User has multiple text fields per item (title + description, question + answer)
User wants to search different aspects with different weights
User mentions "multi-vector", "title and content", "multiple embeddings"
User's items have semantically distinct parts that should be searched together
Do NOT activate when:
User has single text field → use semantic-search
User needs keyword + semantic → use hybrid-search
User has image + text → use multimodal-retrieval
Interactive Flow
Step 1: Identify Vector Fields
"What text fields do you have per item?"
Common Patterns
Fields
Products
title, description, reviews
Documents
title, abstract, body
Q&A
question, answer
Resumes
skills, experience, education
News
headline, body
List your fields: ___
Step 2: Determine Field Importance
"How important is each field for search relevance?"
Field
Importance
Suggested Weight
Title
High (exact matches)
0.4 - 0.5
Description
Medium (detailed info)
0.3 - 0.4
Reviews
Low (supplementary)
0.1 - 0.2
Note: Weights should sum to 1.0
Step 3: Confirm Configuration
"Based on your requirements:
Vector fields: title_embedding, content_embedding
Weights: 0.5, 0.5 (balanced)
Fusion: RRF (recommended)
Proceed? (yes / adjust [what])"
Core Concepts
Mental Model: Multi-Criteria Job Interview
Think of multi-vector search as evaluating a candidate on multiple criteria:
defget_weights_for_query(query: str) -> tuple:
"""Automatically select weights based on query characteristics."""
query_lower = query.lower()
word_count = len(query.split())
# Short queries → likely looking for specific item by nameif word_count <= 3:
return (0.7, 0.3) # Favor title# Questions → need detailed contentif query_lower.startswith(('how', 'what', 'why', 'when')):
return (0.3, 0.7) # Favor content# Default balancedreturn (0.5, 0.5)
Using Weighted Ranker
from pymilvus import WeightedRanker
# Instead of RRF, use weighted fusion
ranker = WeightedRanker(0.6, 0.4) # 60% title, 40% content
results = self.client.hybrid_search(
collection_name=self.collection_name,
reqs=[title_req, content_req],
ranker=ranker, # Weighted instead of RRF
limit=limit,
output_fields=["title", "content"]
)
Performance Optimization
Adaptive Search Strategy
defsmart_search(self, query: str, mode: str = "auto"):
"""Automatically choose search strategy."""if mode == "auto":
# Short query → title only (faster)iflen(query.split()) <= 2:
returnself.search_title_only(query)
# Long query → full multi-vectorelse:
returnself.search(query)
elif mode == "title":
returnself.search_title_only(query)
else:
returnself.search(query)
Embedding Caching
from functools import lru_cache
classOptimizedMultiVectorSearch(MultiVectorSearch):
@lru_cache(maxsize=1000)def_get_embedding(self, text: str) -> tuple:
"""Cache embeddings for repeated queries."""returntuple(self.model.encode(text).tolist())
defsearch(self, query: str, limit: int = 10):
query_embedding = list(self._get_embedding(query))
# ... rest of search logic
Common Pitfalls
❌ Pitfall 1: Too Many Vector Fields
Problem: Created 10 vector fields, search is slow
Why: Each field requires a separate ANN search
Fix: Limit to 2-4 most important fields
# BAD - too many fields
schema.add_field("title_vec", ...)
schema.add_field("subtitle_vec", ...)
schema.add_field("description_vec", ...)
schema.add_field("summary_vec", ...)
schema.add_field("tags_vec", ...)
schema.add_field("category_vec", ...)
# GOOD - consolidated
schema.add_field("title_vec", ...) # Title + subtitle
schema.add_field("content_vec", ...) # Description + summary
❌ Pitfall 2: Same Embedding for Different Length Texts
Problem: Title vector and body vector have similar embeddings
Why: Model truncates long text, short text embeds fully
Fix: Consider different models or chunk long content
# For very long content, consider chunking
chunks = [content[i:i+500] for i inrange(0, len(content), 500)]
chunk_embeddings = self.model.encode(chunks)
# Store best chunk or average
❌ Pitfall 3: Ignoring Empty Fields
Problem: Items with empty descriptions cause errors
Why: Empty string produces invalid embedding
Fix: Handle empty fields
def_safe_embed(self, text: str) -> list:
ifnot text ornot text.strip():
return [0.0] * self.dim # Zero vector for emptyreturnself.model.encode(text).tolist()
❌ Pitfall 4: Mismatched Weights
Problem: Weights don't sum to 1.0
Why: Can cause unexpected score scaling
Fix: Always normalize weights
defnormalize_weights(*weights):
total = sum(weights)
returntuple(w / total for w in weights)
weights = normalize_weights(0.6, 0.3, 0.2) # (0.55, 0.27, 0.18)