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.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
