Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

A vector database is a tool that helps AI systems find information by meaning instead of only matching exact words. It turns text, images, audio, or other data into lists of numbers called vectors. Similar ideas become points that are close together in a mathematical space.

This matters because chatbots, search engines, and recommendation systems need to find useful matches even when people use different wording.

The process usually starts with an AI model that converts data into embeddings, which are numerical summaries of meaning. The vector database stores these embeddings and quickly compares a new question to millions of stored vectors. It looks for the nearest neighbors, which are the data points most similar to the question.

This makes vector databases important for semantic search, retrieval augmented generation, image search, and personalized recommendations.

Key Facts

  • A vector is an ordered list of numbers, such as v = [0.2, 1.4, -0.7].
  • An embedding is a vector that represents the meaning or features of data.
  • Vector databases search by similarity, not just by exact keyword matches.
  • Cosine similarity is often used: cos(theta) = (A · B) / (|A||B|).
  • Euclidean distance measures straight-line distance: d = sqrt((x2 - x1)^2 + (y2 - y1)^2).
  • Nearest neighbor search finds the stored vectors closest to a query vector.

Vocabulary

Vector database
A database designed to store and search numerical vectors that represent data such as text, images, or sounds.
Embedding
A numerical representation of data that captures useful meaning, patterns, or features.
Vector space
A mathematical space where vectors can be placed and compared by distance or direction.
Similarity search
A search method that finds items most similar to a query based on their vector representations.
Nearest neighbor
The data point or points closest to a query point according to a chosen distance or similarity measure.

Common Mistakes to Avoid

  • Thinking a vector database understands words exactly like a human, which is wrong because it compares numerical patterns created by a model.
  • Using only keyword matching for a meaning-based task, which is wrong because related ideas can use different words and still be similar.
  • Assuming closer vectors are always correct answers, which is wrong because embeddings can contain errors, bias, or missing context.
  • Forgetting to choose a similarity measure, which is wrong because cosine similarity and distance formulas can rank results differently.

Practice Questions

  1. 1 A query vector is Q = [3, 4] and a stored vector is A = [6, 8]. What is the cosine similarity between Q and A?
  2. 2 In a 2D vector space, a query is at (2, 3). Stored points are A(5, 7), B(3, 4), and C(8, 1). Using Euclidean distance, which point is the nearest neighbor?
  3. 3 A student searches for “how do plants make food” but a document is titled “photosynthesis in leaves.” Explain why a vector database may find this document even though the exact words are different.