0
0
LangChainframework~20 mins

Chroma vector store setup in LangChain - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Chroma Vector Store Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
Chroma vector store initialization output
What will be the output behavior when initializing a Chroma vector store with the following code snippet?
LangChain
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings

embeddings = OpenAIEmbeddings()
vectorstore = Chroma(collection_name="test_collection", embedding_function=embeddings)
print(vectorstore._collection_name)
ARaises a TypeError because embedding_function expects a list, not an object
BRaises a NameError because OpenAIEmbeddings is not imported
CPrints the memory address of the vectorstore object
DPrints 'test_collection' indicating the collection name used
Attempts:
2 left
💡 Hint
Check how the collection_name attribute is stored and accessed in Chroma vector store.
📝 Syntax
intermediate
1:30remaining
Correct syntax for adding documents to Chroma vector store
Which option correctly adds a list of documents to an existing Chroma vector store instance named 'vectorstore'?
LangChain
docs = ["Hello world", "Langchain is great"]
Avectorstore.add_documents(docs)
Bvectorstore.add(docs)
Cvectorstore.append_documents(docs)
Dvectorstore.insert_documents(docs)
Attempts:
2 left
💡 Hint
Check the official method name for adding documents in Chroma vector store.
🔧 Debug
advanced
2:00remaining
Identify the error in Chroma vector store setup
What error will this code raise when trying to create a Chroma vector store without specifying the embedding function?
LangChain
from langchain.vectorstores import Chroma

vectorstore = Chroma(collection_name="my_collection")
ATypeError: __init__() missing 1 required positional argument: 'embedding_function'
BValueError: collection_name cannot be empty
CRuntimeError: Chroma client not found
DNo error, vector store initializes with default embedding function
Attempts:
2 left
💡 Hint
Check the required parameters for Chroma vector store initialization.
state_output
advanced
2:00remaining
Number of documents after adding to Chroma vector store
Given this code, what is the number of documents stored in the vector store after execution?
LangChain
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings

embeddings = OpenAIEmbeddings()
vectorstore = Chroma(collection_name="col1", embedding_function=embeddings)
docs = ["doc1", "doc2", "doc3"]
vectorstore.add_documents(docs)
count = vectorstore._collection.count()
print(count)
ARaises AttributeError because _collection has no count method
B0
C3
DRaises RuntimeError because documents are not indexed yet
Attempts:
2 left
💡 Hint
Check how add_documents affects the internal collection count.
🧠 Conceptual
expert
2:30remaining
Effect of persistent directory in Chroma vector store
What is the effect of specifying the 'persist_directory' parameter when initializing a Chroma vector store?
AIt encrypts the vector store data in memory for security
BIt saves the vector store data to disk, allowing data to persist across program runs
CIt limits the vector store size to the specified directory's free space
DIt disables in-memory caching, forcing all queries to read from disk
Attempts:
2 left
💡 Hint
Think about why you would want to save vector data to a folder.