liveBook · Manning

Vector database

As explained in Just Use Postgres!

A vector database is a database designed to store vector representations and support efficient similarity searches over them.

A vector database stores vector embeddings and supports efficient similarity searches over vectorized data. It commonly supplies specialized indexes that speed up these searches. section 8.3 section 8.6

Postgres becomes a vector database when the pgvector extension adds the vector data type, similarity operators, and specialized vector indexes. section 8.2 section 8.7

A vector database supports an embedding-based application flow:

  • Split target text into chunks when necessary and send the chunks to an embedding model. section 8.3
  • Store the generated embeddings in Postgres and retrieve relevant records through vector similarity search. section 8.3 section 8.6
  • Use retrieved context to augment an LLM through retrieval-augmented generation. section 8.6

Run Postgres with pgvector

Create a Docker volume, start the pgvector/pgvector:0.8.0-pg17 image on port 5432, connect with psql, and run CREATE EXTENSION vector;. section 8.2

Figure 8.10 Implementing RAG with an LLM, an embedding model, and Postgres
A diagram of a process

AI-generated content may be incorrect.

Trace how a chatbot sends a prompt to a backend, retrieves context from Postgres, and uses an embedding model and LLM to generate a response. section 8.6

How Just Use Postgres! covers it

How deep it goes
Explains storage, similarity search, embeddings, and specialized indexes, while deferring detailed index operation and deployment guidance.
Examples
Uses a movie recommendation service, private datasets, Docker commands, and pgvector extension setup as concrete examples.
What it assumes
Assumes familiarity with Postgres and Docker while introducing embeddings, chunking, vector data, and similarity search.
What you can do after
Operate/configure Postgres with pgvector and use stored embeddings for similarity search and RAG context retrieval.
How it connects
Connects embeddings, embedding models, vector similarity search, Postgres, pgvector, specialized indexes, RAG, and LLMs.

Also explained in

Compare how 26 books explain vector database →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.