0
0
LangChainframework~30 mins

Chroma vector store setup in LangChain - Mini Project: Build & Apply

Choose your learning style9 modes available
Chroma Vector Store Setup
📖 Scenario: You are building a simple application that stores text data as vectors using the Chroma vector store from LangChain. This will help you quickly find similar texts later.
🎯 Goal: Create a Chroma vector store with some sample documents and set it up to be ready for similarity search.
📋 What You'll Learn
Create a list of documents with exact texts
Set a collection name for the Chroma vector store
Initialize the Chroma vector store with the documents and collection name
Add the final step to persist the vector store
💡 Why This Matters
🌍 Real World
Vector stores help applications find similar texts quickly, useful in chatbots, search engines, and recommendation systems.
💼 Career
Understanding how to set up vector stores is important for roles in AI development, data science, and software engineering working with natural language processing.
Progress0 / 4 steps
1
Create the documents list
Create a list called documents with these exact strings: 'Hello world', 'LangChain is awesome', and 'Vector stores are useful'.
LangChain
Need a hint?

Use a Python list with the exact strings inside quotes.

2
Set the collection name
Create a variable called collection_name and set it to the string 'my_collection'.
LangChain
Need a hint?

Assign the exact string 'my_collection' to the variable collection_name.

3
Initialize the Chroma vector store
Import Chroma from langchain.vectorstores and OpenAIEmbeddings from langchain.embeddings. Then create a variable called embedding as an instance of OpenAIEmbeddings(). Finally, create a variable called vectordb by initializing Chroma with embedding, documents, and collection_name as the collection name.
LangChain
Need a hint?

Use Chroma.from_texts with the exact parameters: texts=documents, embedding=embedding, and collection_name=collection_name.

4
Persist the vector store
Call the persist method on the vectordb variable to save the vector store data.
LangChain
Need a hint?

Call persist() on the vectordb variable to save the data.