No history yet

Introduction to Vector Databases

A New Kind of Database

Traditional databases are excellent at finding exact matches. If you search for the word "cat," a relational database will find every entry that contains the precise string "cat." But what if you wanted to find things that are like a cat, such as a lion, a tiger, or even a picture of a kitten? That's where traditional databases fall short.

A vector database is a specialized database designed to index and store vector embeddings for fast retrieval and similarity search.

Instead of storing data in rows and columns, vector databases store information as mathematical representations called vector embeddings. This allows them to search for data based on its meaning and context, not just keywords. They answer questions of similarity, making them a cornerstone of modern AI applications that deal with unstructured data like text, images, and audio.

Embeddings The Language of AI

A vector embedding is a list of numbers that represents a piece of data. Think of it like a set of coordinates on a high-dimensional map. On this map, items with similar meanings are located close to one another. The word "king" might be near "queen," while the word "banana" would be far away from both.

An embedding model, often a type of neural network, is trained on vast amounts of data to learn these relationships. It converts complex, unstructured data into these numerical vectors. For example:

  • Text: A sentence can be converted into a vector that captures its semantic meaning.
  • Images: A picture of a golden retriever can be turned into a vector. This vector would be close to the vector for a picture of a labrador but far from one of a motorcycle.
  • Audio: A clip of a song can be represented by a vector that captures its genre, tempo, and mood.
Lesson image

By representing data this way, we can use mathematical calculations to find the "distance" between two vectors. A smaller distance implies greater similarity. This is the core principle that enables semantic search.

How They Differ

The fundamental difference between vector and traditional databases lies in how they query data. Traditional systems are built for structured data and exact matches, while vector databases are optimized for similarity searches on unstructured data.

Unlike traditional databases (SQL and NoSQL) which look for exact matches, vector databases look for similar matches.

Here’s a direct comparison:

FeatureTraditional Database (e.g., SQL, NoSQL)Vector Database
Primary Data TypeStructured (e.g., text, numbers, dates)Unstructured (represented as vector embeddings)
Query MethodExact match (e.g., WHERE name = 'John')Similarity search (e.g., find vectors closest to a query vector)
Core OperationFiltering, joining, and aggregating structured recordsApproximate Nearest Neighbour (ANN) search
Use CaseTransactional systems, business analyticsSemantic search, recommendation engines, AI applications

Powering Modern AI

Vector databases are not just a theoretical concept; they are the engines behind many cutting-edge AI features.

Semantic Search: Go beyond keyword matching to find results based on conceptual understanding. If you search for "films about monarchs in the UK," a system using a vector database could return results for "The Crown" even if the exact search terms aren't present.

Recommendation Systems: Services like Netflix or Spotify suggest content by finding items whose vector embeddings are similar to the ones you've already enjoyed.

Retrieval-Augmented Generation (RAG): This is a powerful technique for improving the responses of large language models (LLMs). The LLM's knowledge is supplemented with relevant, up-to-date information retrieved from a vector database. This reduces hallucinations and allows the model to use proprietary or recent data.

Lesson image

As AI continues to evolve, the ability to efficiently search and retrieve information based on meaning is critical. Vector databases provide the foundational infrastructure for this new generation of intelligent applications.

Quiz Questions 1/5

What is a vector embedding?

Quiz Questions 2/5

How do vector databases primarily determine if two pieces of data are similar?