术语表

矢量搜索

了解矢量搜索如何通过在 NLP、可视化搜索、推荐系统等数据检索中实现语义相似性来彻底改变人工智能!

使用Ultralytics HUB 对YOLO 模型进行简单培训

了解更多

Vector Search is a powerful technique used in Artificial Intelligence (AI) and Machine Learning (ML) to find items that are semantically similar, rather than just matching keywords. It operates by representing data points—such as text documents, images, audio clips, or user profiles—as numerical vectors called embeddings. These embeddings capture the underlying meaning or characteristics of the data. Vector search then finds the vectors in a dataset that are "closest" to a given query vector in a high-dimensional space, typically using distance metrics like cosine similarity or Euclidean distance. This allows for more nuanced and context-aware searching compared to traditional methods.

矢量搜索的工作原理

The process typically involves several key steps:

  1. Embedding Generation: Data is converted into high-dimensional vectors (embeddings) using pre-trained deep learning (DL) models, such as BERT for text or Vision Transformers (ViT) for images. These models are trained on vast datasets to learn meaningful representations. For instance, Ultralytics YOLO models, primarily known for object detection, also generate feature vectors that could potentially be adapted for visual search tasks.
  2. Indexing: The generated vectors are stored and indexed in a specialized vector database. These databases are optimized for efficiently querying high-dimensional data, often using Approximate Nearest Neighbor (ANN) algorithms like HNSW (Hierarchical Navigable Small World) or ScaNN (Scalable Nearest Neighbors). ANN techniques trade a small amount of accuracy for significant speed improvements, making vector search feasible for large datasets.
  3. Querying: When a search query is made (e.g., a text phrase or an image), it is first converted into the same vector format using the same embedding model.
  4. Similarity Calculation: The vector database then searches its index to find the vectors most similar to the query vector based on a chosen distance metric (e.g., cosine similarity, Euclidean distance, dot product).
  5. Retrieval: The items corresponding to the closest vectors are returned as the search results.

Key Concepts and Technologies

  • Vector Embeddings: Numerical representations capturing semantic meaning. Models learn these during training on large datasets like ImageNet.
  • Vector Databases: Systems like Pinecone, Weaviate, Milvus, and Chroma DB are designed for storing and querying vectors.
  • Similarity Metrics: Mathematical functions (e.g., Cosine Similarity, Euclidean Distance) used to measure the "closeness" between vectors.
  • Approximate Nearest Neighbor (ANN): Algorithms that efficiently find likely nearest neighbors, crucial for performance on large scale. Libraries like Faiss (Facebook AI Similarity Search) provide implementations.
  • Dimensionality Reduction: Techniques like PCA (Principal Component Analysis) can sometimes be used to reduce vector dimensions, potentially speeding up search at the cost of some information loss.

实际应用

Vector search enables a wide range of intelligent applications:

  • Semantic Search: Powering search engines (like Google Search) or internal knowledge bases to understand query intent beyond keywords. For example, searching for "healthy dinner ideas" might return recipes for salads, grilled chicken, and quinoa bowls, even if those exact words aren't in the documents, because their vector embeddings are close in meaning.
  • Recommendation Systems: Platforms like Netflix or Spotify use vector search to find items (movies, songs, products) similar to those a user has liked or interacted with previously, based on similarities in their vector representations.
  • Image Recognition and Search: Finding visually similar images (reverse image search) or identifying products in photos for e-commerce. This is a core application area within Computer Vision (CV).
  • Anomaly Detection: Identifying unusual data points (e.g., fraudulent transactions, network intrusions) whose vectors lie far from clusters of normal data vectors.
  • Natural Language Processing (NLP): Enhancing applications like question answering, duplicate detection, and clustering text data based on topic or sentiment.
  • Retrieval-Augmented Generation (RAG): Used in Large Language Models (LLMs) to retrieve relevant context from a knowledge base before generating a response, improving factual accuracy and reducing hallucinations.
阅读全部