Deep dive into Vector DB essentials
Vector Databases Demystified: The Backbone of Modern AI Applications
MAKE IT SIMPLE AI SERIES — UNDERSTANDING FUNDAMENTALS OF VECTORS, EMBEDDINGS & DATABASES: A MODERN DATA REVOLUTION
❑ Overview
In the AI era, traditional databases fall short in handling complex, high-dimensional data. Vector databases offer smarter, faster search by storing data as multi-dimensional vectors. In this blog, I will help you learn what vectors are and how embeddings transform raw data into searchable formats, explore how vector databases power semantic search & compare vector vs. traditional databases to understand when each is best used.
Whether you’re building AI apps or exploring intelligent search, this guide is your starting point.
❑ What is Vector?
A vector is a mathematical object which has both magnitude and direction(dimension) and can be represented by an ordered list of numbers.
Real-Life Example:
- Imagine a car moving at 40 miles per hour toward the East.
- Magnitude: 40 miles per hour (this tells us how fast the car is moving)
- Direction: East (this tells us where the car is heading)
So, the car’s velocity is a vector because it combines:
Velocity=40 mph East\text {Velocity} = 40 \text {mph East} Velocity=40 mph East
If you only said, “40 mph,” that would be a scalar (speed), because it lacks direction.
2. Airplane in Wind (Multi-Dimensional) — Because the airplane’s motion is influenced by two components (North and East), forming a vector in 2D space.
An airplane is flying with:
- Air Speed: 500 mph toward the North
- Wind Speed: 100 mph toward the East
❑ What is a high-dimensional vector?
Think of a vector as an arrow that points somewhere. In math and AI, this arrow doesn’t just point in one direction — it can have many directions at once, each representing a feature.
For example:
- A simple vector for a dog picture might only include color and type.
- A high-dimensional vector could include hundreds or thousands of features: ear shape, eye color, fur texture, background details, and more.
So, a high-dimensional vector is like a super-detailed description packed into one long arrow.
[Ear Shape=0.8, Eye Color=0.3, Fur Texture=0.9, Tail Length=0.6, Background Color=0.2, …]
Question — So now how is vector related to AI & machine learning?
These vectors help machine learning models understand complex things and the relationships between them.
❑ Why Vector? Why has it become more relevant in Generative AI?
So, coming back to WHY Vectors are Famous in Generative AI?
- Efficient Data Representation — Vectors have become increasingly relevant in generative AI because they allow complex, unstructured data — like text, images, and audio — to be converted into high-dimensional numerical arrays that capture semantic meaning, relationships, and context. This representation enables
- Semantic Representation — Vectors (embeddings) encode the essence and “meaning” of data, allowing AI to understand concepts and relationships. For instance, the vector for “king” is close to “queen” in vector space, meaning they are related semantically
- Efficient Similarity Search: Generative models need to find related content quickly. Vectors make it possible to compare vast sets of data using mathematical metrics (like cosine similarity) to retrieve the most relevant information.
- Data Manipulation & Latent Space Navigation: Vectors allow AI models to interpolate and manipulate data by simple arithmetic. For example, calculating vector(“king”) — vector(“man”) + vector(“woman”) produces a vector close to “queen”. This is critical for creative generation, style transfer, and controlled output.
2. Optimized for Modern Hardware —
Vectors are ideal data structures for machine learning, as modern CPUs and GPUs are optimized for the mathematical operations they require.
- Matrix multiplications, dot products, and cosine similarity are core to neural network operations.
- GPUs excel at parallelizing these operations across large batches of vectors, enabling real-time inference and training.
❑ What is embedding?
Embedding is numeric representation of objects within highly dimensional spaces. Example of an embedding model is the popular word2vec, which is regularly used for a wide variety of text-based tasks. Also look at TensorFlow’s projector tool, which makes it easy to visualize embeddings.
Consider a simplified two-dimensional vector space where words are represented as points. For instance, the point (2, 3) represents the word joy while the point (3, 4) represents happy. Because these words have similar meanings, their vectors are located close to each other in the vector space. On the other hand, the point (-5, -8) represents the word sad. Since it has the opposite meaning of joy, and their vectors are situated far apart from each other.
➟Types of Embedding Models
Below are types on embedding model available -
1. Text Embedding Models —
These models convert textual data into vector representations.
OpenAI
text-embedding-ada-002: 1536 dimensions, widely used for semantic search and RAG.text-embedding-3-smallandtext-embedding-3-large: Faster and cheaper successors to ada-002.- Cohere
Cohere
embed-english-v3.0,embed-multilingual-v3.0: Known for normalized vectors and multilingual support.
textembedding-gecko,universal-sentence-encoder: Versatile models supporting various similarity metrics.
2. Image and Document Embeddings
- CNN-based models: Used for image embeddings.
- Doc2Vec: Extends Word2Vec to entire documents.
❑ Vector database (Vector DB)
Vector databases is a specialized database designed to handle highly dimensional vectors primarily generated from embeddings of complex data type such as text, images, audio. It provides capabilities to store and index unstructured data and enhance searches, as well as retrieval capabilities as a service.
Below are some of the key factors/characteristics of a vector Database -
- Indexing — Indexing refers to the process of organizing highly dimensional vectors in a way that allows for efficient similarity searches and retrievals.
- Flat — index structure that stores vectors in a flat, unstructured format. Flat index doesn’t have any precomputed structures, which means each query needs to go through every single vector in the database to find its nearest neighbors.
- IVF — stands for Inverted File. In an IVF system, the dataset is first partitioned into several clusters. For each cluster, an inverted file (a list) is created that keeps track of the vectors that belong to this cluster. The advantage is during a search; you only need to search within the relevant clusters instead of the entire dataset. IVF index can significantly reduce the computational cost and improve search efficiency.
- HNSW (Hierarchical Navigable Small World) — Builds a graph where each node (vector) connects to its neighbors. Search starts from a high-level graph and navigates down. Very fast and accurate; excellent for high-dimensional data. Memory-intensive; slower to build.
- Product Quantization (PQ) — Compresses vectors by splitting them into sub-vectors and quantizing each part separately. Great for reducing memory usage & enables fast approximate search. It has lower accuracy compared to HNSW.
2. Search & retrieval — Instead of relying on exact matches as traditional DB’s, Vector DBs provide vector search capabilities to quickly find vectors that are roughly closest to a give input. Vector DB uses similarity measures which are the foundation of how a vector database compares and identifies the most relevant results for a given query.
Here are the most common ones:
- Cosine Similarity
Measures the angle between two vectors. 1 = identical ,0 = completely unrelated, -1 = opposite direction - Euclidean Distance
Measures the straight-line distance between vectors. 0 = identical, larger values = more different - Dot Product
Combines vector magnitudes and their directional alignment. Positive = same direction, 0 = no relation, Negative = opposite direction
3. Create, Read, Update & Delete (CRUD) — A vector DB manages highly dimensional vectors and offers create, read, update & delete operations to vectorized data.
4. Easy Integration - Vector DB’s provide seamless integration to LLM orchestration frameworks and SDK such as Langchain and Semantic Kernel.
Vector DB Limitations
- Accuracy vs Speed Trade-off — While dealing with high dimensional data, vector DB’s face a tradeoff between speed and accuracy for similarity searches.
- Embedding Quality — The effectiveness of vector db is dependent on quality of the vector embedding used. Poorly designed embeddings can lead to inaccurate search results or missed connections.
❑ Vector Database Query Process Flow
Based on the diagram, here’s a clear process flow for how a vector database ingests raw data (Step 1–4) & retrieve results from a query (Step 5–8) using vector embeddings from a vector database:
- Raw Data/Content — Original data (e.g., text, image, audio) that needs to be stored.
- Embedding Model — A machine learning model (e.g. OpenAI Embeddings) converts raw data into high-dimensional vector representations.
- Vector Embedding — The output of the embedding model: a numerical vector (e.g., [0.45, -1.7, 1.33, …, -0.03, 1.42]) representing the semantic meaning of the data.
- Vector Database — Stores all vector embeddings and supports efficient similarity search using indexing algorithms (e.g., HNSW, IVF).
- Query — A user or system submits a query (e.g., a sentence or image) to find similar items.
- Query Gets Embedded — The query is passed through the same embedding model to generate its vector representation.
- Embedded Query Gets Fired in Vector DB — The query vector is used to search the vector database for nearest neighbors (similar vectors).
- Query Result Returned — The database returns the most similar items based on vector proximity (e.g., cosine similarity or Euclidean distance).
❑ Vector database VS Traditional Database
➟ Purpose & Use Case
- Vector Databases are designed for similarity search and AI-driven applications. They store high-dimensional data like embeddings from text, images, or audio, making them ideal for semantic search, recommendation systems, and machine learning.
- Traditional Databases (e.g., MySQL, PostgreSQL) are optimized for structured data, supporting transactional systems, reporting, and analytics with well-defined schemas and SQL queries.
➟ Data Type & Structure
- Vector DBs store unstructured or semi-structured data as vectors in high-dimensional space.
- Traditional DBs store structured data in tables with rows and columns, using relational models.
➟ Query Mechanism
- Vector DBs use nearest neighbor algorithms (e.g., k-NN, ANN, DiskANN) to find similar vectors.
- Traditional DBs use SQL or NoSQL queries for exact matches and predefined conditions.
➟ Performance & Scalability
- Vector DBs are optimized for fast similarity searches and scale horizontally across distributed systems.
- Traditional DBs excel in transactional consistency and complex relational queries, with scalability depending on architecture.
➟ Examples
- Vector DBs: Milvus, Pinecone, Weaviate, FAISS (Facebook AI Similarity Search), Azure Cosmos DB (with vector indexing)
- Traditional DBs: SQL Server, MySQL, PostgreSQL, Oracle, MongoDB
➟ When to Use What
- Use Case — Semantic search, AI/ML, image/text/audio similarity
- Best Fit — Vector Database
- Use Case — Financial records, inventory, structured reporting
- Best Fit — Traditional Database
❑ References
Understanding Vector Databases | Microsoft Learn
What is a Vector Database & How Does it Work? Use Cases + Examples | Pinecone
Integrated vector store — Azure Cosmos DB for NoSQL | Microsoft Learn
“What’s My Vector, Victor?” Understanding Vectors in Generative AI — DTiQ
❑ Conclusion
I hope this blog helped you to go through the basic of Vector databases. We will surely explore and continue with advance topics of AI in upcoming blogs, Till then, Happy Learning!!!
Please Note — All opinions expressed here are my personal views and not of my employer.
