Challenge - 5 Problems
Pinecone Vector Store Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Pinecone index creation code?
Consider this code snippet using Pinecone with Langchain:
What will this code output if the index "example-index" exists and contains 100 vectors?
import pinecone
pinecone.init(api_key="test-key", environment="us-west1-gcp")
index = pinecone.Index("example-index")
print(index.describe_index_stats())What will this code output if the index "example-index" exists and contains 100 vectors?
LangChain
import pinecone pinecone.init(api_key="test-key", environment="us-west1-gcp") index = pinecone.Index("example-index") print(index.describe_index_stats())
Attempts:
2 left
💡 Hint
Check the structure of the dictionary returned by describe_index_stats and the default namespace key.
✗ Incorrect
The describe_index_stats method returns a dictionary with keys like 'dimension', 'index_fullness', and 'namespaces'. The default namespace key is an empty string "", not 'default'. So option D matches the expected output.
📝 Syntax
intermediate1:30remaining
Which option correctly initializes Pinecone with Langchain?
You want to initialize Pinecone to use it with Langchain. Which code snippet is syntactically correct and will NOT raise an error?
Attempts:
2 left
💡 Hint
Check the exact method name and parameter names in Pinecone's init function.
✗ Incorrect
The correct method is pinecone.init with keyword arguments api_key and environment. Option A uses the correct syntax. Option A misses keywords, C uses wrong method name, D uses wrong parameter names.
❓ state_output
advanced2:00remaining
What is the value of 'vector_count' after upserting vectors?
Given this code snippet:
What will be printed if the index was empty before?
import pinecone
pinecone.init(api_key="key", environment="us-west1-gcp")
index = pinecone.Index("test-index")
vectors = [("id1", [0.1]*1536), ("id2", [0.2]*1536)]
index.upsert(vectors)
stats = index.describe_index_stats()
print(stats["namespaces"][""]["vector_count"])What will be printed if the index was empty before?
LangChain
import pinecone pinecone.init(api_key="key", environment="us-west1-gcp") index = pinecone.Index("test-index") vectors = [("id1", [0.1]*1536), ("id2", [0.2]*1536)] index.upsert(vectors) stats = index.describe_index_stats() print(stats["namespaces"][""]["vector_count"])
Attempts:
2 left
💡 Hint
Upsert adds or updates vectors, increasing the count accordingly.
✗ Incorrect
Upserting two vectors adds them to the index. The vector_count in the default namespace (key "") will be 2 after this operation.
🔧 Debug
advanced2:00remaining
Why does this Pinecone query raise a TypeError?
Look at this code:
Why does this raise a TypeError?
import pinecone
pinecone.init(api_key="key", environment="us-west1-gcp")
index = pinecone.Index("my-index")
query_result = index.query(queries=[0.5]*1536, top_k=3)
print(query_result)Why does this raise a TypeError?
LangChain
import pinecone pinecone.init(api_key="key", environment="us-west1-gcp") index = pinecone.Index("my-index") query_result = index.query(queries=[0.5]*1536, top_k=3) print(query_result)
Attempts:
2 left
💡 Hint
Check the expected type for the 'queries' parameter in Pinecone's query method.
✗ Incorrect
The 'queries' parameter expects a list of vectors (each vector is a list of floats). Passing a single vector list without wrapping it in another list causes a TypeError.
🧠 Conceptual
expert2:30remaining
Which option best describes Pinecone's namespace behavior?
In Pinecone, what is the correct understanding of namespaces when storing vectors?
Attempts:
2 left
💡 Hint
Think about how namespaces help organize vectors and affect queries.
✗ Incorrect
Namespaces in Pinecone separate vectors logically. Queries target vectors only in the specified namespace. The default namespace is represented by an empty string "" key.