liveBook · Manning

Vector database

As explained in Generative AI in Action

A vector database is a data-management system that stores and provides access to data together with numerical vector representations and supports vector-based retrieval.

A vector database stores content alongside its embeddings: numerical representations used to find semantically similar content. In an enterprise retrieval-augmented generation (RAG) application, it lets a retriever find relevant passages in proprietary data before an LLM generates an answer. This avoids reloading and embedding the entire source collection for every question. section 7.4 section 8.1.2

The database and its vector index do different jobs. The database persists content, embeddings, and associated metadata; the index organizes vectors for fast similarity lookup. Searching every stored vector directly can be prohibitively expensive for a large corpus. Index choices include exact and approximate nearest-neighbor methods, with speed, accuracy, and memory trade-offs. section 7.4 section 7.5 section 7.5.1

A typical RAG workflow is:

  • Read source data, split it into chunks, create embeddings, and retain links to the source as metadata. section 7.4
  • Save the chunks and embeddings, then create an index suited to the search requirements. section 7.5 section 7.5.1
  • Embed a user query, retrieve matching chunks, and place them with the question in the LLM prompt. section 8.6

Chat over a blog

For a blog spanning nearly 20 years, Redis holds previously ingested posts as chunks and embeddings. A chat application embeds each new question, uses a hybrid search index to retrieve the top five matches, and supplies those chunks to the LLM. Redis Stack in a local Docker container makes the workflow easy to try; that local setup is not, by itself, a production deployment. section 8.1.2 section 8.2 section 8.6

Listing 8.1 docker-compose file for redis-stack
version: '3.7'
services:

  vector-db:
    image: redis/redis-stack:latest
    ports:
      - 6379:6379
      - 8001:8001
    environment:
      - REDISEARCH_ARGS=CONCURRENT_WRITE_MODE
    volumes:
      - vector-db:/var/lib/redis
      - ./redis.conf:/usr/local/etc/redis/redis.conf
    healthcheck:
      test: ["CMD", "redis-cli", "-h", "localhost", "-p", "6379", "ping"]
      interval: 2s
      timeout: 1m30s
      retries: 5
      start_period: 5s

volumes:
  vector-db:

The Redis Stack Compose listing shows the local vector-database service, ports, volume, and health check used for the example setup. section 8.2

Production use requires more than selecting a database. Plan for ingestion and refresh, index size and schema, scaling, security, and operations. The right database and index depend on the source data and the required retrieval performance; managed services can take on some operational demands. section 8.9 section 10.4.2

How Generative AI in Action covers it

How deep it goes
Defines storage and indexing roles, then walks through local ingestion and retrieval; leaves production clustering and operations beyond the example.
Examples
Uses Redis Stack for chat over blog posts and Chroma with Semantic Kernel for question answering over PDFs.
What it assumes
Assumes Docker is installed for the local Redis setup and introduces the database’s role alongside embeddings and indexes.
What you can do after
Build it from scratch as a local Redis-backed RAG retrieval workflow, while recognizing additional production engineering needs.
How it connects
Connects embeddings, vector indexes, semantic search, hybrid search, and retrieval-augmented generation.

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 Generative AI in Action. The section links point to the parts of the book it draws on.