Video summary

Vector Stores in LangChain | Generative AI using LangChain | Video 12 | CampusX

Main summary

Key takeaways

Technology

Summary: Vector Stores in LangChain (RAG component)

This video is part of a LangChain/RAG learning series. After covering Document Loaders and Text Splitters, the speaker focuses on Vector Stores—explaining why they’re needed, what capabilities they provide, and how to use them in LangChain with a working code walkthrough using Chroma DB.


1) Why vector stores are needed (movie recommender → semantic similarity)

The speaker builds motivation using a movie recommendation example, showing why simple approaches fail.

Keyword matching recommender (baseline)

Compares movies using overlapping metadata/keywords (e.g., director, actors, genre, release timing).

  • Flaw #1: Can produce logically weak matches (movies share keywords but not similar plots/story).
  • Flaw #2: Misses similarity when different movies have similar meaning but few/no shared keywords.

Plot-based semantic similarity (better approach)

Instead of keywords, represent each movie’s plot as embeddings (vectors) using deep learning.

  • Similarity is then computed between vectors (e.g., cosine similarity / angular distance).

Engineering challenges at scale

When doing embedding-based similarity at scale, there are three key challenges:

  1. Generate embeddings for potentially millions of items.
  2. Storage: embeddings shouldn’t live in a typical relational DB, since you need efficient vector similarity behavior.
  3. Semantic search at scale: comparing a query against 1M+ vectors via brute force is too slow; you need efficient nearest-neighbor search.

Vector stores are introduced to solve these challenges—especially the fast similarity search part.


2) What a vector store is (definition + core features)

A vector store is defined as a system to store and retrieve numerical vector representations (embeddings).

Core features covered

  • Storage

    • Keeps vectors plus associated metadata (e.g., movie ID/name).
    • Supports in-memory (RAM) and on-disk (persistent) storage.
  • Similarity search

    • Given a query vector, returns the most similar vectors and their associated payload/documents.
    • Variants mentioned:
      • similarity_search (returns top matches)
      • similarity_search_with_score (returns distance/similarity score; lower distance = better match)
  • Indexing for fast search

    • Uses indexing structures to speed up search in high-dimensional spaces.
    • Example concept: clustering + centroids to avoid comparing with every vector.
    • Also mentions Approximate Nearest Neighbor (ANN) as a research-backed acceleration strategy.
  • CRUD-like operations

    • Add vectors/documents, update them, delete outdated ones.

3) Vector Store vs Vector Database (terminology clarification)

The speaker clarifies common confusion:

  • Vector store: typically focuses on storing vectors + similarity retrieval (often lightweight; great for prototyping/smaller setups).
  • Vector database: a more complete database system that includes features like:
    • scaling/distributed architecture
    • durability/persistence
    • backup/restore
    • transactions/asset transactions
    • concurrency control
    • authentication/authorization

Key takeaway: Every vector database is effectively a vector store, but not every vector store is a vector database.


4) How LangChain uses vector stores (abstraction + wrappers)

LangChain supports many vector stores via wrappers that share common method signatures.

Key ideas

  • LangChain provides interchangeable vector store interfaces so you can switch vendors (e.g., Chroma, Pinecone, FAISS, Qdrant, Weaviate) with minimal code changes.
  • Shared methods mentioned conceptually:
    • create from documents/text (e.g., from_documents / from_text)
    • add (add_documents / add_texts)
    • similarity search
    • metadata filtering

5) Tutorial/code walkthrough with Chroma DB in LangChain (Colab)

The speaker demonstrates how to implement vector store operations using Chroma DB.

Chroma DB overview

  • Lightweight open-source, suitable for local development and small-to-medium production.
  • Hierarchy:
    • Tenant (top-level; user/org/team)
    • Database
    • Collection (like a table)
    • Documents inside collections
  • Each stored document includes:
    • embedding vector
    • metadata

Setup in Google Colab

  • Install libraries (OpenAI embeddings + Chroma wrapper).
  • Import:
    • OpenAI embeddings from LangChain
    • Chroma vector store module from LangChain

Creating data as LangChain Document objects

  • Five Document objects about cricket players (example names: Virat Kohli, Rohit Sharma, MS Dhoni, Jasprit Bumrah, Ravindra Jadeja).
  • Each includes:
    • page_content (text about the player)
    • metadata (e.g., IPL team for that player)

Creating the vector store (Chroma)

Configure:

  • embedding function (OpenAI embeddings)
  • persist directory on disk (local folder for Chroma data)
  • collection name (e.g., "samples")

Vector store operations shown

  1. Add documents

    • add_documents(docs)
    • Automatically assigns unique IDs unless custom IDs are provided.
  2. Inspect stored contents

    • get to view:
      • stored documents
      • IDs
      • embeddings
      • metadata
  3. Similarity search

    • similarity_search(query, k=...)
    • Example query: asking “who among these are a bowler?”
    • Shows how:
      • k=1 returns one best match
      • increasing k returns more semantically relevant results (e.g., “all-rounder”)
  4. Similarity search with scores

    • similarity_search_with_score(...)
    • Demonstrates distance/similarity scoring (lower distance = better).
  5. Metadata filtering

    • Filter search results by metadata fields (e.g., only players whose team matches Chennai Super Kings).
  6. Update documents

    • update_document(document_id, new_document)
    • Replaces/updates an existing document by ID.
  7. Delete documents

    • delete(ids=[...])
    • Removes documents by ID and verifies remaining count.

Main speaker / source

  • Speaker: Nitesh (host of the “CampusX” YouTube channel), guiding through a LangChain / RAG educational series.

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video