0
0
Prompt Engineering / GenAIml~20 mins

Vector databases (Pinecone, ChromaDB, Weaviate) in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Vector Database Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Vector Database Indexing

Which of the following best describes how vector databases like Pinecone, ChromaDB, and Weaviate index data for fast similarity search?

AThey convert data into fixed-length vectors and use approximate nearest neighbor algorithms for indexing.
BThey store raw text data and perform keyword matching during queries.
CThey use relational tables with primary keys to index data for exact matches.
DThey compress images and store them as binary blobs without indexing.
Attempts:
2 left
💡 Hint

Think about how similarity search works with numbers instead of text.

Model Choice
intermediate
2:00remaining
Choosing a Vector Database for Real-Time Search

You want to build a real-time recommendation system that updates frequently and requires low latency. Which vector database is best suited for this use case?

AChromaDB, because it only supports batch updates and slower queries.
BWeaviate, because it does not support vector search but excels in text search.
CPinecone, because it supports dynamic updates and low-latency queries.
DNone of these, because vector databases cannot handle real-time data.
Attempts:
2 left
💡 Hint

Consider which database supports fast updates and quick queries.

Metrics
advanced
2:00remaining
Evaluating Vector Search Quality

Which metric is most appropriate to evaluate the quality of a vector database's approximate nearest neighbor search results?

ABLEU score, measuring similarity between text sequences.
BPrecision@k, measuring how many of the top k results are relevant.
CAccuracy, measuring the percentage of correct classifications.
DMean Squared Error, measuring the difference between predicted and true values.
Attempts:
2 left
💡 Hint

Think about how to measure how many returned results are actually relevant.

🔧 Debug
advanced
2:00remaining
Debugging Vector Search Result Errors

You notice that your vector database returns very poor search results despite correct vector embeddings. Which of the following is the most likely cause?

AThe distance metric used for search does not match the embedding space properties.
BThe database is missing some raw text data fields.
CThe vectors are stored as integers instead of floats, causing syntax errors.
DThe database index is too large, causing it to crash on queries.
Attempts:
2 left
💡 Hint

Consider how similarity is measured between vectors.

Predict Output
expert
3:00remaining
Output of Vector Similarity Query Code

What is the output of the following Python code snippet using a vector database client?

Prompt Engineering / GenAI
import numpy as np

# Sample vectors
vectors = {
    'id1': np.array([1.0, 0.0]),
    'id2': np.array([0.0, 1.0]),
    'id3': np.array([1.0, 1.0])
}

# Query vector
query = np.array([1.0, 0.5])

# Function to compute cosine similarity
def cosine_similarity(a, b):
    return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

# Find id with highest similarity
best_id = max(vectors, key=lambda k: cosine_similarity(query, vectors[k]))
print(best_id)
Aid1 and id3 tie
Bid1
Cid2
Did3
Attempts:
2 left
💡 Hint

Calculate cosine similarity for each vector with the query.