Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a list of queries for multi-query retrieval.
Prompt Engineering / GenAI
queries = ["What is AI?", [1], "Explain machine learning."]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-string values as queries.
Leaving the blank empty.
✗ Incorrect
The list of queries must contain strings representing questions. Option C is a valid query string.
2fill in blank
mediumComplete the code to initialize the retrieval model for multi-query retrieval.
Prompt Engineering / GenAI
model = RetrievalModel([1]=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated parameters like batch_size or learning_rate.
Misspelling the parameter name.
✗ Incorrect
The parameter 'multi_query=True' enables multi-query retrieval in the model initialization.
3fill in blank
hardFix the error in the code to correctly perform multi-query retrieval.
Prompt Engineering / GenAI
results = model.retrieve(queries=[1], top_k=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular 'query' instead of 'queries'.
Misspelling the parameter name.
✗ Incorrect
The method expects the argument named 'queries' to receive the list of queries.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps each query to its top result.
Prompt Engineering / GenAI
top_results = {q: results[[1]][[2]] for q in queries} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or indices to access results.
Confusing the query variable with the results variable.
✗ Incorrect
For each query q, results[q][0] gives the top result. So BLANK_1 is 'q' and BLANK_2 is '0'.
5fill in blank
hardFill all three blanks to filter queries and create a dictionary of their top results only if the score is above 0.8.
Prompt Engineering / GenAI
filtered_results = {q: results[q][[1]] for q in queries if results[q][[2]] [3] 0.8} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up indices for result and score.
Using wrong comparison operators.
✗ Incorrect
Index 0 accesses the top result, index 1 accesses the score. We filter where score > 0.8.