liveBook · Manning

Vector database

As explained in Retrieval Augmented Generation, The Foundational Ideas

A vector database is a database system designed to store and retrieve vector representations using similarity search.

A vector database stores vector representations and retrieves them by similarity, providing the memory layer for AI applications. In retrieval-augmented generation, it supports the search half of retrieve-then-answer or retrieve-then-generate workflows. section 4.7.1 section 7.3

Treat the database as one component in a retrieval system rather than as an answer source:

  • Use dense-vector similarity for thematic matches, but combine or route to sparse search when exact entity matches matter. section 11.6
  • Separate offline storage and indexing from online query behavior: a query may be transformed, embedded, searched, evaluated, reranked, or rejected. section 7.3 section 11.6
  • Expect production retrieval to handle stale or thin results through evaluation, correction, fallback search, or refusal rather than trusting every nearest-neighbor result. section 11.6

HyDE query integration

A HyDE retriever asks an LLM to write hypothetical answer text, embeds that text, and searches a vector store with the resulting vector. With an FAISS index, the application can call similarity_search_by_vector; a higher-level retriever can hide these steps behind get_relevant_documents(query). section 7.3

Listing 7.3 HyDE in LangChain.
from providers import get_chat_model, get_embeddings
from langchain_core.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_classic.chains.hyde.base import (
    HypotheticalDocumentEmbedder)
llm = get_chat_model(temperature=0)
base_embeddings = get_embeddings()
prompt = PromptTemplate(
    input_variables=["question"],
    template=("Please write a passage to answer the question.\n"
              "Question: {question}\nPassage:")
)  #A
hyde_embedder = HypotheticalDocumentEmbedder(
    llm_chain=prompt | llm | StrOutputParser(),  #B
    base_embeddings=base_embeddings,
)
query = "What are the best practices for a startup's user growth?"
hypothetical_doc_embedding = hyde_embedder.embed_query(query)  #C
 

Shows the compact LangChain construction of a hypothetical-document embedder, including prompt generation, embedding, and query-vector creation. section 7.3

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains vector storage, similarity search, query transformation, and retrieval safeguards without detailing database indexing internals.
Examples
Names Weaviate, Pinecone, Qdrant, Chroma, and FAISS, then demonstrates HyDE-generated vectors in a LangChain retrieval flow.
What it assumes
Assumes embeddings, language models, and retrieval-augmented generation while showing how these components connect through a vector store.
What you can do after
Apply it via FAISS or a managed vector database, then inspect, rerank, route, or reject retrieved results in a RAG pipeline.
How it connects
Connects vector databases to embeddings, dense retrieval, sparse search, reranking, retrieval-augmented generation, and language models.

Also explained in

Compare how 34 books explain vector database →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.