Challenge - 5 Problems
Retrieval Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Similarity-Based Retrieval
Which statement best describes how similarity-based retrieval works in information retrieval systems?
Attempts:
2 left
💡 Hint
Think about how a search engine finds documents that are most relevant to what you type.
✗ Incorrect
Similarity-based retrieval measures how close the content of documents is to the query, often using scores like cosine similarity, to rank and retrieve the most relevant documents.
❓ Model Choice
intermediate2:00remaining
Choosing a Retrieval Strategy for Diverse Results
You want to retrieve documents that are not only relevant but also diverse to avoid redundancy. Which retrieval strategy should you choose?
Attempts:
2 left
💡 Hint
Consider a method that balances relevance and diversity.
✗ Incorrect
MMR balances relevance to the query and diversity among selected documents to reduce redundancy in results.
❓ Predict Output
advanced3:00remaining
Output of MMR Score Calculation
Given the following Python code snippet that calculates MMR scores for candidate documents, what is the output of the print statement?
Agentic AI
query_vec = [1, 0] candidate_vecs = [[0.9, 0.1], [0.1, 0.9], [0.8, 0.2]] selected = [] import numpy as np def cosine_similarity(a, b): return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)) lambda_param = 0.5 mmr_scores = [] for i, doc_vec in enumerate(candidate_vecs): sim_to_query = cosine_similarity(query_vec, doc_vec) sim_to_selected = max([cosine_similarity(doc_vec, candidate_vecs[j]) for j in selected] or [0]) score = lambda_param * sim_to_query - (1 - lambda_param) * sim_to_selected mmr_scores.append(score) print([round(s, 2) for s in mmr_scores])
Attempts:
2 left
💡 Hint
Calculate cosine similarity carefully and apply the MMR formula.
✗ Incorrect
The first document has high similarity to the query and no penalty since no documents are selected yet, so score is 0.5*0.9 - 0.5*0 = 0.45 rounded to 0.45 (not 0.9). The others have lower scores due to similarity and penalty terms.
❓ Hyperparameter
advanced2:00remaining
Effect of Lambda in MMR
In Maximal Marginal Relevance (MMR), what happens when the lambda parameter is set close to 1?
Attempts:
2 left
💡 Hint
Lambda controls the trade-off between relevance and diversity.
✗ Incorrect
Lambda near 1 means the formula weights relevance heavily and diversity very little, so results are mostly relevant but may be redundant.
🔧 Debug
expert3:00remaining
Debugging Hybrid Retrieval Code
Consider this hybrid retrieval code combining similarity and MMR. What error will it raise when run?
Agentic AI
def hybrid_retrieval(query_vec, candidate_vecs, lambda_param=0.7): import numpy as np def cosine_similarity(a, b): return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)) selected = [] scores = [] for i, doc_vec in enumerate(candidate_vecs): sim_query = cosine_similarity(query_vec, doc_vec) sim_selected = max([cosine_similarity(doc_vec, candidate_vecs[j]) for j in selected] or [0]) score = lambda_param * sim_query - (1 - lambda_param) * sim_selected scores.append(score) return scores query = [1, 0] candidates = [[0.9, 0.1], [0.1, 0.9]] print(hybrid_retrieval(query, candidates))
Attempts:
2 left
💡 Hint
Look at the max() function call when selected is empty.
✗ Incorrect
When selected is empty, the list comprehension inside max() is empty, causing max() to raise a ValueError for empty sequence.