Command Palette

Search for a command to run...

Hectal
Phase 6: Hybrid Search and Re-ranking
RAG and Vector Search · Exercise 2 of 5 PreviousNext
Intermediate

Normalise two score lists and mix them

Write min_max(scores): rescale a list to 0..1 with (score - lowest) / (highest - lowest). If all scores are equal, return a list of 0.0 of the same length.

Write mix(keyword, vector, alpha): normalise both lists with min_max, then return the list alpha * k + (1 - alpha) * v for each position.

What Check tests

  1. The best score becomes 1 and the worst 0
  2. Equal scores give zeros, not an error
  3. Alpha 1 keeps only the keyword list
  4. Alpha 0.5 mixes both normalised lists
  5. Raw scales do not leak through

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.