In traditional applications, we use relational databases (like MySQL or Oracle) to store data. However, these systems are built for keyword matching—they look for exact words. In AI, we need Semantic Search, which understands that “Taree Zameen Par” and “A Beautiful Mind” are similar because of their plots, even if they share no common keywords. This is where Vector Stores come in.
1. Why Vector Stores? #
The source identifies three primary challenges when working with Large Language Models and external data:
- Challenge 1: Generation: You must convert millions of documents into Embedding Vectors (numerical representations of meaning).
- Challenge 2: Storage: Traditional databases cannot efficiently store these vectors or calculate similarities between them.
- Challenge 3: Semantic Search: Searching through millions of vectors for the “most similar” one is computationally expensive. You need a system that can perform this search intelligently and fast.
Vector Stores solve all three by providing a specialized system to store, retrieve, and index numerical vectors
2. Working Diagram of a Vector Store #

3. Key Features of Vector Stores #
- Storage: You can store vectors In-Memory (fast, but lost if the app closes) or On-Disk (persistent storage like a hard drive).
- Similarity Search: The ability to compare a “query vector” against millions of stored vectors to find the closest matches using techniques like Cosine Similarity.
- Indexing: A smart method (like clustering) that allows the system to find similar vectors without comparing the query to every single record, making the search significantly faster.
- CRUD Operations: Just like a standard database, you can Create, Read, Update, and Delete vectors.
4. Vector Store vs. Vector Database #
While often used interchangeably, there is a technical difference:
- Vector Store: A lightweight system or library (like FAISS) focused primarily on storage and similarity search. It is ideal for prototyping.
- Vector Database: A full-fledged system (like Pinecone, Milvus, or Qdrant) that adds enterprise features like distributed architecture, backups, security/authentication, and ACID transactions.
5. Implementing with Chroma DB (Code Example) #
LangChain provides a unified interface, meaning the code you write for one store (like Chroma) can easily be switched to another (like Pinecone) with minimal changes.
A. Creating a Vector Store
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import Chroma
# 1. Define the embedding model
embeddings = OpenAIEmbeddings()
# 2. Create the store (persisting data to a local folder)
vector_db = Chroma(
collection_name="my_collection",
embedding_function=embeddings,
persist_directory="./my_chroma_db"
)
B. Adding and Searching Documents
# Adding documents (automatically generates unique IDs)
vector_db.add_documents(docs)
# Performing a similarity search
# k=2 means "give me the top 2 most similar results"
results = vector_db.similarity_search(query="Who is a bowler?", k=2)
# Searching with a similarity score (lower score = more similar)
results_with_scores = vector_db.similarity_search_with_score("Who is the captain?", k=1)
C. Advanced Filtering (Metadata)
You can filter results based on specific criteria stored in your metadata (e.g., only show players from a specific team).
results = vector_db.similarity_search(
query="Show me players",
filter={"team": "Chennai Super Kings"}
)
Conclusion
Vector Stores are the “engine” of RAG applications. By converting text into high-dimensional vectors and using smart indexing, they allow AI to “remember” and retrieve the most relevant information from massive datasets in milliseconds
Vector Stores Quiz #
Q.1 In the context of movie recommendation systems, what is the primary limitation of using keyword matching to determine similarity between two films?
It requires a specialized high-dimensional coordinate system to function.
It fails to capture the underlying semantic meaning or plot similarity.
It can only compare movies released in the same decade.
It is computationally more expensive than generating vector embeddings.
Explanation
Keyword matching only compares exact words and misses semantic meaning. Two movies with similar themes or plots but different wording may appear unrelated, whereas embeddings capture their conceptual similarity.
Q.2 Which component is responsible for converting a piece of text into a numerical representation that captures its semantic meaning?
Embeddings
Relational Databases
Text Splitters
Document Loaders
Explanation
Embedding models transform text into dense numerical vectors that capture semantic meaning, enabling similarity searches based on concepts rather than exact keywords.
Q.3 When storing vectors in a system, what does the 'associated metadata' typically refer to?
The raw binary code of the embedding model.
The mathematical formula used to calculate cosine similarity.
Additional information about the vector, such as a movie's ID, title, or category.
The historical logs of all searches performed by users.
Explanation
Metadata stores descriptive information related to each embedding, such as document ID, title, source, category, author, or page number, making retrieved results easier to identify and filter.
Q.4 What is the primary purpose of 'Indexing' within a vector store?
To convert the dimensions of a vector from 784 to a smaller number.
To ensure that vectors are encrypted for security purposes.
To automatically delete outdated or irrelevant documents from the store.
To organize vectors into data structures that enable faster similarity searches.
Explanation
Indexing organizes vectors into efficient data structures so that nearest-neighbour searches can be performed quickly without comparing every stored vector.
Q.5 How does a 'Vector Database' differ from a basic 'Vector Store' according to the source?
A Vector Store cannot perform similarity searches, whereas a Vector Database can.
A Vector Database is only used for image data, while Vector Stores are for text.
A Vector Database includes enterprise features like ACID transactions, backups, and access control.
Vector Stores are stored on disk, while Vector Databases are always in-memory.
Explanation
A Vector Database provides enterprise capabilities such as persistence, ACID transactions, authentication, backups, scalability, and access control, while a Vector Store is typically a lightweight storage library.
Q.6 In LangChain, what is the advantage of using the standard method signatures provided for different vector store wrappers?
It allows the application to automatically choose the cheapest embedding model.
It automatically generates metadata for every document inserted into the system.
It enables developers to switch between different vector stores (e.g., from FAISS to Pinecone) with minimal code changes.
It ensures that the vectors are compatible with traditional SQL databases.
Explanation
LangChain standardizes vector store APIs so developers can replace one vector store with another, such as FAISS, Chroma, or Pinecone, without rewriting most of their application code.
Q.7 What does a lower score represent when using the similarity_search_with_score function in a vector store like Chroma?
A higher similarity, because the distance between the vectors is smaller.
The number of keywords that matched between the query and the document.
Lower accuracy in the embedding model.
A greater distance between the vectors, indicating less similarity.
Explanation
In many vector stores, the score represents distance. A lower distance means the query vector is closer to the stored vector, indicating greater semantic similarity.
Q.8 Which operation is most commonly performed by a Vector Store during a Retrieval-Augmented Generation (RAG) pipeline?
Sorting documents alphabetically before retrieval.
Performing similarity search to find the most semantically relevant documents.
Converting PDF files into text documents.
Training the embedding model using retrieved documents.
Explanation
After the user’s query is converted into an embedding vector, the Vector Store performs a similarity search (such as cosine similarity or Euclidean distance) to retrieve the most semantically relevant document chunks, which are then supplied to the LLM for generating an accurate response.
Q.9 In the indexing example provided in the source, how does using 'centroids' help speed up search?
It allows the system to compare a query vector against a few group averages first, narrowing down the search area.
It converts text directly into vectors without using a neural network.
It reduces the number of dimensions in every vector to a single point.
It encrypts the data so that only authorized users can perform similarity searches.
Explanation
Centroids represent clusters of similar vectors. The search first finds the closest centroid and then searches only within that cluster, greatly reducing the number of comparisons required.
Q.10 When building a RAG application, why would a developer choose 'On-disk' storage over 'In-memory' storage for a vector store?
On-disk storage is faster for real-time similarity searches.
On-disk storage ensures that vectors are persistent and remain available after the application is closed.
In-memory storage is limited to 512 dimensions, while on-disk supports 784 dimensions.
In-memory storage automatically updates metadata based on user feedback.
Explanation
On-disk storage persists embeddings on permanent storage, so they remain available even after the application or computer is restarted, unlike in-memory storage which is lost when the program exits.