0
0
Prompt Engineering / GenAIml~20 mins

Hybrid search (semantic + keyword) in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Hybrid Search Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why combine semantic and keyword search in hybrid search?

Hybrid search uses both semantic and keyword search methods. What is the main benefit of combining these two?

AIt reduces the time needed to index documents by skipping keyword extraction.
BIt improves search accuracy by capturing both exact matches and related meanings.
CIt eliminates the need for any text preprocessing before searching.
DIt guarantees that only exact keyword matches are returned.
Attempts:
2 left
💡 Hint

Think about how semantic search understands meaning and keyword search looks for exact words.

Predict Output
intermediate
1:30remaining
Output of hybrid search scoring function

Given the following Python code snippet for a hybrid search score, what is the printed output?

Prompt Engineering / GenAI
semantic_score = 0.7
keyword_score = 0.5
alpha = 0.6
hybrid_score = alpha * semantic_score + (1 - alpha) * keyword_score
print(round(hybrid_score, 2))
A0.65
B0.58
C0.60
D0.62
Attempts:
2 left
💡 Hint

Calculate weighted average: multiply semantic score by alpha, keyword score by (1 - alpha), then add.

Model Choice
advanced
2:00remaining
Choosing a model for semantic search in hybrid search

You want to build a hybrid search system combining keyword and semantic search. Which model is best suited for the semantic search part?

AA pretrained transformer-based sentence embedding model like Sentence-BERT
BA simple TF-IDF vectorizer without embeddings
CA rule-based keyword matching system
DA clustering algorithm like K-Means
Attempts:
2 left
💡 Hint

Semantic search needs to understand meaning, not just word counts.

Hyperparameter
advanced
1:30remaining
Effect of alpha in hybrid search scoring

In hybrid search, the combined score is calculated as:
hybrid_score = alpha * semantic_score + (1 - alpha) * keyword_score.
What happens if alpha is set to 1?

AOnly semantic search scores are used, ignoring keyword matches.
BThe scores are averaged equally between semantic and keyword search.
COnly keyword search scores are used, ignoring semantic matches.
DThe hybrid score becomes zero regardless of input scores.
Attempts:
2 left
💡 Hint

Consider what multiplying by 1 or 0 does to each score.

Metrics
expert
2:30remaining
Evaluating hybrid search effectiveness

You run a hybrid search system and want to measure how well it balances semantic and keyword search results. Which metric best captures both relevance and ranking quality?

ARoot Mean Squared Error (RMSE)
BPrecision at K (P@K)
CNormalized Discounted Cumulative Gain (NDCG)
DMean Reciprocal Rank (MRR)
Attempts:
2 left
💡 Hint

Look for a metric that considers position of relevant results and graded relevance.