Module 6 Wrap-up: Storing Your AI's Memory
Hands-on: Build a local knowledge base using ChromaDB and perform semantic queries.
Module 6 Wrap-up: The Librarian
You have successfully turned "Words" into "Vectors" and "Folders" into "Indexes." You now possess the core infrastructure required to solve the biggest problem in AI: Hallucinations. By storing facts in a vector store, you give your model a "Reference Book" to read from.
Hands-on Exercise: The Local Semantic Search
1. The Goal
Build a script that:
- Takes 3 text Strings (e.g. news about space, cooking, and football).
- Stores them in a Chroma vector store.
- Asks a question that doesn't use the exact words (e.g., "Tell me about celestial bodies").
- Verifies the "Space" document is returned.
2. The Implementation Plan
- Install Chroma:
pip install langchain-chroma - Use your
OpenAIEmbeddingsfrom Lesson 1. - Experiment with
k=1to get just the single best result.
Module 6 Summary
- Embeddings: Mathematical meaning (vectors).
- Vector Store: The semantic database (Chroma, FAISS, Pinecone).
- Similarity: Math-based relevance (Distance scores).
- k value: Controls the quantity of retrieved context.
- Persistence: Saving the memory to disk.
Coming Up Next...
In Module 7, we combine everything into RAG (Retrieval-Augmented Generation). We will link our Vector Store (Module 6) with our Chains (Module 4) to build an agent that can answer questions about any data you give it.
Module 6 Checklist
- I can explain the difference between a string and a vector.
- I have chosen my preferred embedding model (OpenAI vs. Local).
- I understand that k=4 means I am retrieving 4 text chunks.
- I have successfully saved a vector store to my local drive.
- I know that switching embedding models requires a full database rebuild.