Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 5 · 4. Embeddings & Vector Stores
Lesson 32 of 68

Embedding Models in LangChain

Interchangeable but not equivalent. Choosing the right engine.

Derpx0610 Jan · 1 min read
LangChain Mastery
Embeddings: What Matters in PracticeEmbedding Models in LangChainVector Stores: FAISS, ChromaPersisting & Reloading IndexesMetadata FilteringDense vs Sparse (BM25 Overview)Hybrid Search Concepts
Contents
1. The Abstraction Layer2. Model Selection Trade-offs3. The Silent Failure: Mixing Models4. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Embeddings: What Matters in PracticeEmbedding Models in LangChainVector Stores: FAISS, ChromaPersisting & Reloading IndexesMetadata FilteringDense vs Sparse (BM25 Overview)Hybrid Search Concepts
Contents
1. The Abstraction Layer2. Model Selection Trade-offs3. The Silent Failure: Mixing Models4. Summary

1. The Abstraction Layer

LangChain abstracts embedding providers into a single class: Embeddings. Method: embed_query(text) -> List[float].

This means you can swap OpenAI for HuggingFace with one line of code:

swap_embeddings.py
from langchain_openai import OpenAIEmbeddings
from langchain_huggingface import HuggingFaceEmbeddings

# model = OpenAIEmbeddings()
model = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")

2. Model Selection Trade-offs

  • OpenAI (text-embedding-3-small): High quality, cheap, but sends data to API (Privacy risk).
  • Local (all-MiniLM-L6-v2): Free, private, runs on CPU, but lower semantic understanding.
  • Cohere (embed-english-v3.0): Specialized for RAG (retrieval quality).

3. The Silent Failure: Mixing Models

CRITICAL WARNING: If you embed your documents with Model A, and embed your user query with Model B... It will not work. The vectors live in different mathematical universes. You will get random results. Once you pick an embedding model for an index, you are married to it.

4. Summary

LangChain makes it easy to experiment. But make a choice early. Changing models later requires re-embedding your entire database ($$$).

Key Intuition: "Vectors are not portable. They are model-specific signatures."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonEmbeddings: What Matters in PracticeNext lesson →Vector Stores: FAISS, Chroma