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 34 of 68

Persisting & Reloading Indexes

Saving your work. Avoiding expensive re-computation.

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. Embeddings Are Expensive2. In-Memory vs Persistent3. Reloading Strategy4. 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. Embeddings Are Expensive2. In-Memory vs Persistent3. Reloading Strategy4. Summary

1. Embeddings Are Expensive

Calculating embeddings costs time (GPU cycles) and money (API credits). If you re-embed your PDF every time you restart the script, you are burning money. You must Persist (save) the index.

2. In-Memory vs Persistent

  • In-Memory: vectorstore = Chroma.from_documents(...).

    • Fastest.
    • Dies when script ends.
    • Good for testing.
  • Persistent: vectorstore = Chroma(persist_directory="./db").

    • Saves to disk.
    • Reloads instantly on next run.

3. Reloading Strategy

In production, you separate Ingestion from Querying.

Script A (Ingestion): Run nightly. Reads docs -> Embeds -> Save to ./db.

Script B (FastAPI): Run continuously. Loads ./db -> Serves queries.

persist_reload.py
# Script A: Write
db = Chroma(persist_directory="./chroma_db", embedding_function=model)
db.add_documents(docs)

# Script B: Read
db = Chroma(persist_directory="./chroma_db", embedding_function=model)
# No embedding happens here! Instant load.

4. Summary

Treat your Vector Store like a database, not a temporary variable. Persist to disk (or cloud) so your app starts instantly.

Key Intuition: "Compute once, query forever."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonVector Stores: FAISS, ChromaNext lesson →Metadata Filtering