AI Dictionary of Terms

Vector Database

A specialized database designed to store, index, and search high-dimensional vectors (embeddings), enabling fast and efficient similarity searches across massive datasets based on semantic meaning rather than exact keyword matches.

The Simple Version

Imagine a traditional library catalog. If you search for “automobile,” it only finds books with the exact word “automobile.” It misses books that say “car” or “vehicle.”

A vector database is like a library where every book has been assigned a “theme coordinate” in a massive, multi-dimensional room. If you search for “automobile,” the system doesn’t look for the word; it goes to the “automobile” coordinate and grabs all the books physically located nearby, which naturally include books about “cars” and “vehicles.” It finds things by meaning, not by exact spelling.

Detailed Explanation

As AI models generate embeddings (dense vectors representing data), traditional relational databases (SQL) or document stores (NoSQL) struggle to search them efficiently. Vector databases solve this.

Core Components:

  1. Vector Storage: Stores the high-dimensional arrays (e.g., 1536 floats per item) alongside metadata (e.g., document ID, source URL, date).
  2. Indexing Algorithms: Uses Approximate Nearest Neighbor (ANN) algorithms like HNSW (Hierarchical Navigable Small World) or IVF (Inverted File Index) to organize vectors for lightning-fast search, sacrificing a tiny bit of accuracy for massive speed gains.
  3. Similarity Metrics: Calculates distance between vectors using Cosine Similarity, Euclidean Distance (L2), or Dot Product.

How it powers RAG (Retrieval-Augmented Generation):

  1. User asks a question.
  2. Question is converted into an embedding.
  3. Vector database finds the top K most similar document embeddings.
  4. Those documents are sent to the LLM as context to generate an accurate answer.

Key Characteristics

Business Context

Vector databases are the critical infrastructure layer for enterprise Generative AI:

Real-World Analogy

A music streaming service’s “Discover Weekly” playlist. It doesn’t just recommend songs with the same genre tag. It analyzes the audio features (tempo, key, instrumentation) of songs you like, places them in a “musical space,” and recommends other songs that are mathematically close to your favorites in that space.

Code Example

# Simple vector search using ChromaDB (a popular local vector database)
import chromadb

# 1. Initialize the vector database (in-memory for this example)
client = chromadb.Client()
collection = client.create_collection(name="company_docs")

# 2. Add documents and their pre-computed embeddings
# (In practice, you would generate these embeddings using a model like OpenAI or SentenceTransformers)
collection.add(
    documents=[
        "Our Q3 revenue increased by 15% due to strong enterprise sales.",
        "The new employee handbook outlines a 4-day work week policy.",
        "The IT department will perform server maintenance this Sunday."
    ],
    ids=["doc1", "doc2", "doc3"],
    # Mock embeddings for demonstration (normally these are 1536-dim arrays)
    embeddings=[
        [0.1, 0.8, 0.2], 
        [0.9, 0.1, 0.1], 
        [0.2, 0.2, 0.9]
    ]
)

# 3. Perform a semantic search
results = collection.query(
    query_embeddings=[[0.15, 0.75, 0.25]], # Embedding for "How did the company perform financially?"
    n_results=1
)

print("Most relevant document:", results['documents'][0][0])

Common Misconceptions

Sources & Further Reading