liveBook · Manning

Redis

As explained in Generative AI in Action

Redis is an open-source in-memory data store that supports key-value storage and multiple data structures for database, caching, and messaging workloads.

Redis is an open-source, in-memory key–value store used as a database, cache, or message broker. For a retrieval-augmented generation (RAG) chat application, Redis Stack provides a local place to store and search embeddings instead of reloading and re-embedding source documents for every question. section 8.2 section 8.1.2

A blog-post Q&A workflow uses Redis in four steps:

  • Run Redis Stack in Docker; Docker must already be installed and configured. section 8.2
  • Read posts from an RSS feed, retain their content and metadata, and create embeddings. section 8.3 section 8.6
  • Create a Redis Search index with text, tag, and vector fields. The example stores embeddings in a FLOAT32 vector field using HNSW and cosine distance. section 8.3
  • Embed each question, search for matching chunks, and place retrieved results alongside the question in the LLM prompt. section 8.6
Listing 8.2 Redis index schema
SCHEMA = [
    TagField("url"),
    TextField("title"), 
    TextField("description"),
    TextField("publish_date"),
    TextField("content"),
    VectorField("embedding", "HNSW",
                {"TYPE": "FLOAT32",
                 "DIM": 1536,
                 "DISTANCE_METRIC": "COSINE"}),
   ]

The index schema makes the division of work concrete: searchable post metadata and text sit beside a 1,536-dimensional embedding field. section 8.3

The local container and index are an implementation example, not a complete production deployment guide. The chat flow retrieves the top five matches and instructs the model to say when the posts do not contain an answer. section 8.2 section 8.6

How Generative AI in Action covers it

How deep it goes
Works through local deployment, index fields, and chat retrieval, while leaving Docker installation outside scope.
Examples
Uses an RSS-fed blog index and a chat application that retrieves five matching chunks for a question.
What it assumes
Assumes Docker is installed and configured, then walks through running Redis locally and creating an index.
What you can do after
Apply it via Redis Stack and Python to index post embeddings and retrieve context for RAG answers.
How it connects
Connects Redis Search, vector similarity search, embeddings, hybrid search, and retrieval-augmented generation.

Also explained in

Compare how 6 books explain Redis →

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.