Challenge - 5 Problems
Chroma Vector Store Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2: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)
Attempts:
2 left
💡 Hint
Check how the collection_name attribute is stored and accessed in Chroma vector store.
✗ Incorrect
The Chroma vector store stores the collection name in the _collection_name attribute. Printing it outputs the string 'test_collection'.
📝 Syntax
intermediate1: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"]
Attempts:
2 left
💡 Hint
Check the official method name for adding documents in Chroma vector store.
✗ Incorrect
The correct method to add documents to a Chroma vector store is add_documents. Other method names do not exist and cause AttributeError.
🔧 Debug
advanced2: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")
Attempts:
2 left
💡 Hint
Check the required parameters for Chroma vector store initialization.
✗ Incorrect
The embedding_function parameter is required when creating a Chroma vector store. Omitting it causes a TypeError.
❓ state_output
advanced2: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)
Attempts:
2 left
💡 Hint
Check how add_documents affects the internal collection count.
✗ Incorrect
After adding 3 documents, the internal collection count method returns 3.
🧠 Conceptual
expert2: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?
Attempts:
2 left
💡 Hint
Think about why you would want to save vector data to a folder.
✗ Incorrect
The persist_directory parameter tells Chroma where to save data on disk so it can be reused later without rebuilding the index.