0
0
Prompt Engineering / GenAIml~20 mins

Vector database operations (CRUD) 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 Insert Operation

Which statement best describes what happens during the insert operation in a vector database?

AThe vector database adds new vectors along with their metadata to the storage, making them available for future queries.
BThe vector database removes vectors that match a given query from the storage permanently.
CThe vector database compresses all stored vectors to save space without changing their content.
DThe vector database updates the similarity scores of existing vectors without changing the stored vectors themselves.
Attempts:
2 left
💡 Hint

Think about what it means to add new data to a database.

Predict Output
intermediate
2:00remaining
Output of Vector Deletion Code

What will be the output of the following code snippet that deletes a vector by ID and then queries the database?

Prompt Engineering / GenAI
vectors = {'v1': [0.1, 0.2], 'v2': [0.4, 0.5]}

# Delete vector with ID 'v1'
del vectors['v1']

# Query remaining keys
print(list(vectors.keys()))
A['v1', 'v2']
B[]
C['v2']
DKeyError
Attempts:
2 left
💡 Hint

Deleting a key removes it from the dictionary.

Model Choice
advanced
2:00remaining
Choosing the Best Model for Vector Similarity Search

You want to build a vector database that supports fast similarity search on high-dimensional image embeddings. Which model type is best suited for this task?

AA pre-trained transformer model fine-tuned for text generation
BA vector embedding model trained to produce compact, meaningful image feature vectors
CA dense neural network trained for classification tasks
DA clustering algorithm like K-means used directly as a model
Attempts:
2 left
💡 Hint

Think about which model creates vectors that capture image features well.

Hyperparameter
advanced
2:00remaining
Effect of Changing Vector Search 'k' Parameter

In a vector database query, the parameter k controls how many nearest neighbors are returned. What happens if you increase k from 5 to 20?

AThe query will fail because <code>k</code> must be less than 10.
BThe query returns fewer vectors, making the search faster but less comprehensive.
CThe query ignores the <code>k</code> value and returns all vectors in the database.
DThe query returns more vectors, increasing the chance of finding relevant results but taking more time.
Attempts:
2 left
💡 Hint

Think about what increasing the number of neighbors means for results and speed.

🔧 Debug
expert
2:00remaining
Debugging Vector Update Operation

Given the following code to update a vector in a vector database, what error will it raise?

Prompt Engineering / GenAI
vectors = {'v1': [0.1, 0.2], 'v2': [0.4, 0.5]}

# Attempt to update vector 'v3'
vectors['v3'][0] = 0.9

print(vectors)
AKeyError because 'v3' does not exist in the dictionary
BIndexError because the vector has no elements
CTypeError because list elements cannot be assigned
DNo error; the vector 'v3' is created and updated
Attempts:
2 left
💡 Hint

Consider what happens when you try to access a key that is not in a dictionary.