0
0
Prompt Engineering / GenAIml~20 mins

Re-ranking retrieved results in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Re-ranking Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use re-ranking in search results?

Imagine you have a list of search results from a simple keyword match. Why might you want to re-rank these results using a machine learning model?

ATo remove all results that contain stop words
BTo reduce the number of results shown to zero
CTo randomly shuffle results for variety
DTo improve the order by considering relevance beyond keyword matches
Attempts:
2 left
💡 Hint

Think about how simple keyword matching might miss the best answers.

Predict Output
intermediate
1:30remaining
Output of re-ranking scores

What is the output of the following Python code that re-ranks a list of documents by their scores?

Prompt Engineering / GenAI
docs = ['doc1', 'doc2', 'doc3']
scores = [0.3, 0.9, 0.5]
ranked_docs = [doc for _, doc in sorted(zip(scores, docs), reverse=True)]
print(ranked_docs)
A['doc1', 'doc3', 'doc2']
B['doc2', 'doc3', 'doc1']
C['doc3', 'doc2', 'doc1']
D['doc1', 'doc2', 'doc3']
Attempts:
2 left
💡 Hint

Look at how sorting with reverse=True orders scores from highest to lowest.

Model Choice
advanced
2:00remaining
Best model type for re-ranking

You want to re-rank search results by understanding the meaning of queries and documents. Which model type is best suited for this?

AA pretrained transformer-based language model fine-tuned for ranking
BA simple linear regression model
CA k-means clustering model
DA decision tree classifier without text features
Attempts:
2 left
💡 Hint

Think about models that understand language context deeply.

Hyperparameter
advanced
2:00remaining
Choosing hyperparameters for re-ranking model training

When training a neural re-ranking model, which hyperparameter setting is most important to prevent overfitting on a small dataset?

AUse a very high learning rate like 1.0
BUse batch size of 1 with no shuffling
CUse dropout regularization with rate around 0.3 to 0.5
DUse zero epochs to avoid training
Attempts:
2 left
💡 Hint

Regularization helps models generalize better on small data.

Metrics
expert
2:30remaining
Evaluating re-ranking effectiveness

You have two re-ranking models. Model A has a Mean Reciprocal Rank (MRR) of 0.75, Model B has an MRR of 0.65. What does this tell you?

AModel A generally ranks the correct answer higher than Model B
BModel B is better because lower MRR means better ranking
CBoth models perform the same because MRR is not useful here
DModel B has fewer results to rank, so MRR is not comparable
Attempts:
2 left
💡 Hint

MRR measures how high the first correct answer appears on average.