Introduction
Before we discuss Vector Search Engine and when to consider using them, let’s start with a simple question.
What is a vector?
In terms of data representation, a vector is a sequence of numbers (or scalars) that can represent data points in a multidimensional space.
It’s not a new concept – its use in mathematics was first introduced by polymath Hermann Grassmann in the mid-19th century. In this article, we will discuss how the vector representation of data works with machine learning, natural language processing (NLP), and image processing. Using vectors to represent data has been around since the 1980s (through Spatial databases). You’ve probably used a spatial database more than once – Google Maps? Two billion users a month rely on that database, which uses vectors to deliver accurate results efficiently to get where they need to go.
So, let’s discuss the difference between a traditional database and a Vector Search Engine. A traditional database is organized on structured data (think rows and columns) and can be paired with a relational database. Traditional databases can be queried with exact match (or range) queries and filtered based on specific criteria, relying on structured query languages (like SQL).
Vector Search Engine represent and store data as vectors, numerical representations of those data points in high-dimensional spaces. High-dimensional spaces are datasets that contain many variables (columns) compared to the number of data points (rows). Vectors capture the underlying meaning of data, enabling similarity searches.
Understanding Vectors
To understand vectors, it starts with embedding.
Embedding is the numerical representation (vector) that captures the meaning and relationships of text, image, and audio files. Each embedding or vector has a high-dimensional aspect. That means that each vector can have hundreds or thousands of dimensions—each dimension captures a different feature or aspect.
When creating those vectors, the goal is to keep data with similar meanings close to each other in the vector space to allow for an optimized similarity search.
Word embedding
Here’s an example of word embedding (provided by Google Gemini):
We have two sentences:
Sentence 1: “The cat is on the mat.”
Sentence 2: “A feline rested on the rug.”
An embedding model (like those used in NLP) would convert these sentences into vectors. These vectors might look something like:
Sentence 1: [0.23, -0.87, 0.56, …, 0.12]
Sentence 2: [0.25, -0.85, 0.58, …, 0.10]
Because the sentences have similar meanings, their vectors would be relatively close to each other in the high-dimensional space.
Image embedding
It is common to use a convolutional neural network (CNN) to extract features of an image and generate image embeddings.1
Here’s an example of image embedding (provided by Google Gemini):
An image of a dog might be represented by a vector like:
[0.78, 0.12, -0.45, …, 0.91]
A similar vector would be used for another image of a dog. Conversely, a significantly different vector would be used for a picture of a cat.
Digging into convolutional neural networks a little more, they excel at learning hierarchical features from images. Their layers can detect patterns like edges, textures, and more complex object parts.
Image embeddings from convolutional neural networks can be used for:
- Similarity search: Finding images that may be visually similar (think two images with two different dog breeds, both are sitting)
- Image retrieval: Searching for images based on their content
- Image classification: Using the embeddings as features for classification tasks
- Facial recognition: Representing faces as embeddings for comparison
An important aspect of Vector Search Engine is their capacity to store, index, and manage high-dimensional data. This concept is not easy to understand, so I asked Gemini to give me an easy way to describe it.
Imagine you want to describe a simple object, like a color. You might use just one number: its position on a rainbow scale (e.g., 0 for red, 100 for violet). That’s a one-dimensional space.
Now, let’s describe a point on a map.
You need two numbers: its latitude and its longitude. That’s a two-dimensional space.
If you want to describe a cube, use its length, width, and height. That’s a three-dimensional space, and we can easily visualize all of these.
Core concepts of Vector Search Engine
A Vector Search Engine is designed for efficiently storing, indexing, and querying high-dimensional vector embeddings. These embeddings are numerical representations of data, capturing the semantic meaning (or features) of various forms of unstructured data. We covered one of the core concepts above – embeddings, and we’ll dig deeper into a few more core concepts.
High-Dimensional Vectors
- Vector embeddings typically have a large number of dimensions.
- Each dimension captures a nuanced aspect of the data, allowing for a rich and detailed representation.
- An embedding with many dimensions requires specialized indexing (and querying) techniques.
These core concepts revolve around representing complex data as high-dimensional vectors, indexing these vectors for efficient similarity search using specialized algorithms and distance metrics, and performing approximate nearest-neighbor searches to retrieve semantically related information quickly.
