Command Palette

Search for a command to run...

Hectal
Phase 12: Advanced Patterns
RAG and Vector Search · Exercise 2 of 5 PreviousNext
Intermediate

MaxSim by hand

Vectors are tuples of two numbers. Write dot(a, b) and maxsim(query, doc).

query and doc are lists of vectors. maxsim returns, for each query vector, its highest dot product with any vector of doc, added up over the query vectors.

What Check tests

  1. dot multiplies and adds
  2. An exact cover scores the number of query tokens
  3. A passage covering one query token scores less
  4. The best partner is used, not the sum

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.