pgvector
An open-source PostgreSQL extension that adds a vector column type, distance operators and HNSW and IVF indexes.
In more detail
It keeps vectors next to your relational data, so one query can filter by ordinary columns and rank by similarity. Its operators are <-> for Euclidean distance, <#> for negative inner product and <=> for cosine distance.
Example
ORDER BY embedding <=> $1 LIMIT 5Related terms
- PostgreSQL — A widely used open source relational database server with strict typing, rich data types and extensions.
- vector database — A database or extension that stores embedding vectors with their metadata and answers nearest-neighbour queries.
- HNSW — An approximate vector index built as a layered graph of links between nearby vectors, searched by walking from a coarse top layer down to a dense bottom one.
Taught in
- Embedding Models — AI Engineering: LLM Apps, RAG & Agents
- Vector Indexes And Databases — AI Engineering: LLM Apps, RAG & Agents
- Keyword And Hybrid Search — AI Engineering: LLM Apps, RAG & Agents