0
0
Prompt Engineering / GenAIml~10 mins

Multi-query retrieval in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
ANone
B42
C"How does retrieval work?"
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-string values as queries.
Leaving the blank empty.
2fill in blank
medium

Complete 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'
Abatch_size
Bmulti_query
Clearning_rate
Dnum_epochs
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated parameters like batch_size or learning_rate.
Misspelling the parameter name.
3fill in blank
hard

Fix 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'
Aqueries
Bquery
Cquery_list
Dquerys
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular 'query' instead of 'queries'.
Misspelling the parameter name.
4fill in blank
hard

Fill 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'
Aq
B0
C1
Dresults
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or indices to access results.
Confusing the query variable with the results variable.
5fill in blank
hard

Fill 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'
A0
B1
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up indices for result and score.
Using wrong comparison operators.