What is it?
A vector database allows you to many forms of data (text, image, audio, etc.) and lets you query through the data based on similarity. For example, let’s say we have a vector database storing a bunch of news article titles. If you take a title, for example:What is it used for?
Vector databases has many uses such as:- Retrieval-Augmented Generation (RAG)
- AI Agents
- Content-based recommendation engines
- Semantic search
k
-most similar songs to a target song, where all songs are represented as vectors.
There is a great episode of the NerdOut@Spotify podcast that talks about their recommendation engine and vector databases as a whole. Highly recommend it.
How does it actually work? Why vectors?
Vector databases allow you to store multiple forms of data, but as vectors. This is because vectors are an efficient way of universally storing features or characteristics about a piece of data. Data is converted into a vector by passing it through machine-learning models (referred to as embedding models) which extracts features from your data and generates a vector (also referred to as an embedding) containing the extracted features. When comparing the similarity between two pieces of data, the vector database compares the vectors representing each piece of data. The closer the vectors are from each other, the more similar is the data. For example, let’s represent three fruits as 3-dimensional vectors. We’ll define each fruit by three simple features:- Sweetness (scale of 0 to 10)
- Sourness (scale of 0 to 10)
- Size (scale of 0 to 10)
How is similarilty between vectors calculated?
Vector databases usually support various similarity metrics, which are mathematical methods of defining the distance between two vectors.- Euclidean
- Cosine
- Inner Product