Vector Stores
Search by meaning.
A vector store keeps chunks together with their embeddings, and finds the closest ones to a question, fast. LangChain has an in memory vector store, perfect for learning, and connectors for production stores.

- Chunks + embeddings
- Find the closest, fast
- In-memory to start
Building and searching
From documents embeds every chunk and stores them, in one step. Similarity search takes a question, embeds it, and returns the k closest chunks. Run it. For a question about refunds, the top result comes from the returns policy, even though the question is worded differently.
from pathlib import Path
from langchain_core.documents import Document
from langchain_core.vectorstores import InMemoryVectorStore
from langchain_google_genai import GoogleGenerativeAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
docs = [Document(p.read_text(), metadata={"source": p.name})
for p in sorted(Path("kb").glob("*.md"))]
chunks = RecursiveCharacterTextSplitter(chunk_size=300, chunk_overlap=40).split_documents(docs)
embeddings = GoogleGenerativeAIEmbeddings(model="gemini-embedding-001")
store = InMemoryVectorStore.from_documents(chunks, embeddings)
for doc in store.similarity_search("Can I get my money back?", k=2):
print(f"[{doc.metadata['source']}]", doc.page_content[:60].replace("\n", " "))[returns.md] Refunds go back to the original payment method within 5 work [returns.md] # Returns and refunds You can return any book within 30 days
Also uses kb/shipping.md
# Shipping
Standard delivery in the UK takes 3 to 5 working days and costs £2.99.
Delivery is free on orders over £25.
Express delivery arrives the next working day if you order before 2pm, and costs £5.99.
We ship to Ireland and France in 5 to 8 working days for £7.50.
Every order gets a tracking link by email once it leaves our warehouse.Also uses kb/returns.md
# Returns and refunds
You can return any book within 30 days of delivery for a full refund.
Books must be unread and in the condition you received them.
Damaged or faulty books can be returned at any time, and we pay the return postage.
Refunds go back to the original payment method within 5 working days of us receiving the book.
To start a return, reply to your order confirmation email.Also uses kb/gift_cards.md
# Gift cards
Riverside Books gift cards come in values from £10 to £100.
Gift cards never expire and can be used online or in our shop.
A gift card can be used across several orders until the balance is spent.
Gift cards cannot be exchanged for cash.Also uses kb/loyalty.md
# Riverside Readers loyalty club
Joining the Riverside Readers club is free.
Members earn one point for every pound they spend.
100 points can be swapped for a £5 voucher.
Members get early access to signed editions and a birthday discount of 10 percent.Also uses kb/shop.md
# About the shop
Riverside Books has one physical shop, at 12 Mill Lane, Bath.
The shop is open from 9am to 6pm Monday to Saturday, and 11am to 4pm on Sunday.
We sell new and second-hand books, and run a children's story time every Saturday at 10am.
You can contact us at hello@riverside-books.example or on 01225 000 000.Vector stores you can use
In memory is great for learning and small apps. Chroma and FAISS run locally, and save to disk. Postgres with the PG vector extension keeps vectors in a database you may already have. And managed services, like Pinecone, scale to billions of vectors. They all share the same LangChain interface.
| Store | Good for |
|---|---|
| InMemoryVectorStore | learning, small apps |
| Chroma, FAISS | local, saved to disk |
| Postgres + pgvector | your existing database |
| Pinecone and others | huge, managed |
Summary
A vector store embeds and stores chunks, then finds the most similar ones to a question. Every store shares the same interface. Next, seeing how close each result is.
Key takeaways- from_documents
- similarity_search(q, k)
- Same interface everywhere