AI / LangGraph LangChain Interview questions II
How do vector stores work in LangChain?
A vector store in LangChain stores text (documents, chunks) as high-dimensional embedding vectors so you can perform semantic similarity search — finding documents whose meaning is close to a query, even if the exact words don't match. Every vector store integrates an embedding model and a storage backend.
The standard workflow:
- Embed documents with an embedding model (
OpenAIEmbeddings,HuggingFaceEmbeddings, etc.) - Store the vectors in a vector database (FAISS, Chroma, Pinecone, Weaviate, PGVector)
- At query time, embed the query and retrieve the k nearest vectors
from langchain_community.vectorstores import FAISS from langchain_openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() # Create store from documents vectorstore = FAISS.from_documents(docs, embeddings) # Similarity search results = vectorstore.similarity_search("How does LangChain work?", k=4) # Use as a retriever in a chain retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs={"k": 5})
Search types: similarity returns the k most similar documents; mmr (Maximal Marginal Relevance) balances similarity with diversity to avoid returning near-duplicate chunks. Most production vector stores (Pinecone, Weaviate, Qdrant) support metadata filtering so you can scope searches to a subset of documents.
More Related questions...