liveBook · Manning

Vector database

As explained in Data Storytelling with Altair and AI

A vector database is a database optimized for storing and retrieving numerical vector representations by similarity or other vector operations.

A vector database stores vector representations of content so an application can retrieve relevant material for a query. In retrieval-augmented generation (RAG), it acts as an external knowledge source: retrieved facts are supplied to an LLM, which uses them when generating a response. section 7.4.2 section 7.6

A practical workflow starts with source content rather than a model prompt alone. Load a document, split its text into manageable chunks, represent those chunks as vectors, and store them in a collection. A retriever can then query the collection and pass returned context into a question-answering chain. section 7.4.2

In a product-information RAG system, the vector database supports these stages:

  • Load the product HTML page into documents. section 7.4.2
  • Split documents into overlapping text chunks before storage. section 7.4.2
  • Create OpenAI embeddings and persist the chunks in a Chroma collection. section 7.4.2
  • Expose the collection as a retriever for a LangChain RetrievalQA application. section 7.4.2
  • Constrain the prompt to answer from retrieved context and admit when the context is insufficient. section 7.4.2

Answering questions about a smartphone

Store chunks from a New SmartX 2023 product page in Chroma, then ask for a 30-word description. The retrieval chain returns a description grounded in product details and includes the source documents used as context. section 7.4.2

This pattern is useful when an LLM needs current or topic-specific context, such as product details, real-time data, customer reviews, or other relevant information. It can support ad hoc commentaries and annotations for data storytelling without relying only on the model's existing knowledge. section 7.4.2 section 7.6

Figure 7.13 A RAG-based system
figure

The architecture diagram situates the vector database between prepared source content and the LLM application that queries it. section 7.4.2

How Data Storytelling with Altair and AI covers it

How deep it goes
Walks through loading HTML, chunking text, generating embeddings, persisting Chroma data, and querying it through RetrievalQA.
Examples
Uses a New SmartX 2023 HTML product page, a Chroma collection, and a 30-word product-description query.
What it assumes
Assumes readiness to install and use LangChain, Chroma, and OpenAI tools while demonstrating the storage workflow step by step.
What you can do after
Apply it via Chroma and LangChain to build a retriever-backed LLM question-answering application.
How it connects
Connects vector databases with retrieval-augmented generation, embeddings, LangChain, prompt templates, 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 Data Storytelling with Altair and AI. The section links point to the parts of the book it draws on.