Definition given in lecture
A vector database is really a document database plus one extra data type — a vector (embedding), i.e. a large array of floating-point numbers (
1:09:11).
- What it actually provides is approximate nearest-neighbor (ANN) search over those vectors (
1:09:11,1:09:31). - "At the end of the day there's just a fast index to do approximate nearest neighbor search" (
1:09:31).
The pipeline
flowchart LR
L[Album lyrics] --> T[Transformer<br/>OpenAI / HuggingFace]
T --> E[Embeddings<br/>float arrays]
E --> I[Vector index<br/>HNSW / IVF-Flat]
Q["Query: albums similar to<br/>Liquid Swords"] --> T2[Same transformer] --> I
I --> R[Ranked list of matches]
M[JSON metadata] -.->|filter e.g. year > 2012| R
- Index implementations named: HNSW (Hierarchical Navigable Small Worlds) — the most common — and IVF-Flat; libraries include Meta's FAISS and Spotify's Annoy (
1:10:11,1:10:30). - Query flow: embed the query with the same transformer used at load time, run ANN search, get a ranked list (
1:10:56). - Vector DBs also store metadata as JSON, letting you combine semantic search with predicates ("albums like Liquid Swords released after 2012") (
1:10:56).
The argument against a separate system
- Essentially all relational databases have added vector indexes in the past year (
1:11:30,1:16:11). - Nearest-neighbor search does not require throwing away everything the course teaches — it is an extra thing the relational model can accommodate (
1:11:30). - Standards status: the SQL standard has no notion of nearest-neighbor search. Postgres shipped pgvector with its own API, Oracle copied it, and the lecturer expects it in the SQL standard within a few years (
1:11:48).
Use cases (from Q&A)
- Semantic search rather than exact matching — "find albums similar to Liquid Swords" without defining what similar means (
1:15:33). - The transformer supplies meaning: a query for "slinging rocks" can match content about dealing drugs (
1:15:33). - Prior art was fuzzy matching (find albums containing the word "swords") — which has no understanding of semantics (
1:16:11,1:16:49).