Appearance
Day 1 -- Embeddings & Vector Stores
You can't build RAG without embeddings. They're the bridge between natural language and math that lets a database find "sentences about cats" when you type "feline behavior." Day 1 takes you from zero to a working vector store: what embeddings are, how to generate them, how to stuff them into PostgreSQL with pgvector, and how to query them with similarity search. By the end of today you'll have a database that understands meaning, not just keywords.
What you'll have by the end of today
- A working PostgreSQL database with pgvector, populated with real embeddings and queryable by semantic similarity
- The ability to generate embeddings from OpenAI, Gemini, or Cohere APIs with working Python code
- A clear understanding of what an embedding is, why cosine similarity matters, and when k-NN search breaks down
- Hands-on experience with HNSW indexes, distance thresholds, and metadata filtering
Before you start
| Tool | Version | Purpose | Install |
|---|---|---|---|
| Python | 3.10+ | All code examples | python.org |
| PostgreSQL | 16+ | Vector store host | apt install postgresql-16 |
| pgvector extension | 0.7+ | Vector type + indexes | apt install postgresql-16-pgvector |
| An API key | -- | Embeddings provider | OpenAI, Google Gemini, or Cohere |
bash
pip install psycopg2-binary pgvector openaiYou'll also want the psql client available. If PostgreSQL isn't set up yet, run through the Practical Fundamentals database setup -- it takes about 20 minutes.
Lessons
- What Are Embeddings -- dense vectors that capture semantic meaning, the embedding space, cosine similarity, and why embeddings work for search when keywords fail
- Generating Embeddings -- calling OpenAI text-embedding-3-small, Gemini embedding-2, and Cohere embed; understanding dimensionality, batching, and cost per token
- pgvector Setup -- CREATE EXTENSION vector, creating tables with vector(768), HNSW indexes, connecting from Python with psycopg2
- Storing and Querying -- INSERT with embeddings, cosine similarity search with
<=>, ORDER BY distance, LIMIT, and basic filtering - Similarity Search -- k-NN fundamentals, threshold filtering to avoid garbage results, metadata filtering, and interpreting distance scores