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

































