AI Model Wiki

    Skip to main content
    9 min read
    Lesson 2 of 5

    Embedding Models and Vector Databases Explained

    From the course RAG & Knowledge Bases: Ground AI in Your Data

    To make RAG work, you need two key technologies: embedding models that convert text to numbers, and vector databases that store and search those numbers efficiently.

    What Are Embeddings?

    An embedding is a numerical representation of text — a list of numbers (a "vector") that captures the meaning of words, sentences, or documents.

    • "The cat sat on the mat" → [0.12, -0.45, 0.78, ...] (1536 numbers)
    • "A feline rested on the rug" → [0.11, -0.44, 0.79, ...] (very similar numbers!)
    • "Stock prices rose sharply" → [-0.89, 0.23, -0.15, ...] (very different numbers)

    Similar meanings produce similar vectors. This is how semantic search works — you find documents by meaning, not just keyword matching.

    Popular Embedding Models

    ModelDimensionsProviderBest For
    text-embedding-3-large3072OpenAIHighest accuracy
    text-embedding-3-small1536OpenAIGood balance
    Gemini text-embedding768GoogleCost-effective
    Cohere embed-v31024CohereMultilingual
    BGE-M31024Open sourceSelf-hosted
    Nomic Embed768Open sourceLocal deployment

    What Are Vector Databases?

    A vector database is optimized for storing and searching vectors. Unlike traditional databases that match exact values (SQL WHERE clauses), vector databases find the most similar vectors to a query — even if there's no exact match.

    How Vector Search Works

    1. Store document embeddings with metadata
    2. Convert user query to an embedding
    3. Find the K nearest vectors (most similar documents)
    4. Return those documents ranked by similarity

    Popular Vector Databases

    Cloud-hosted:

    • Pinecone — Fully managed, easy to start, scales well. Best for teams that want zero infrastructure.
    • Weaviate Cloud — Supports hybrid search (vector + keyword). Good for complex queries.
    • Qdrant Cloud — High performance, rich filtering. Good for production workloads.

    Self-hosted / Open source:

    • Chroma — Lightweight, Python-native. Perfect for prototyping and small projects.
    • pgvector (PostgreSQL) — Add vector search to your existing Postgres database. Great if you're already using PostgreSQL.
    • Milvus — Highly scalable, designed for billions of vectors. Enterprise-grade.
    • FAISS (Facebook) — In-memory vector search library. Fast but no persistence built-in.

    Choosing an Embedding Model

    Key factors:

    • Dimensions — Higher dimensions = more nuance but more storage/compute
    • Speed — How fast are embedding API calls?
    • Cost — Per-token pricing adds up at scale
    • Language support — Some models handle multilingual content better
    • Domain — Some models are fine-tuned for specific domains (code, medical, legal)

    Best Practice: Test Before Committing

    Embed a sample of your documents with 2-3 different models. Run test queries and compare retrieval quality. The best model for your use case depends on your specific documents and query patterns.

    Key Takeaways

    • •Embeddings convert text into numerical vectors that capture semantic meaning
    • •Similar meanings produce similar vectors — enabling search by meaning
    • •Vector databases are optimized for finding the most similar vectors efficiently
    • •Popular options range from managed (Pinecone) to self-hosted (pgvector, Chroma)
    • •Always test multiple embedding models on your actual data before choosing one
    0 of 5 lessons marked complete

    Progress is kept in this browser only.