Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 12.3 — More Than One Vector per Passage
RAG and Vector Search · Example 2 of 2

Late interaction (MaxSim) by hand with 2-number vectors

A toy with literal vectors to show the arithmetic. Real late-interaction models produce one vector per token with many more numbers, and compress them.

One vector per passage is a compromise. A passage can have several: one per sentence, one per question it answers, or one per token with late interaction. Each helps a different failure and costs more storage.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write best_key_score(question, keys) that returns the highest Jaccard similarity between the question's word set and the word set of any key (a key is a passage or a question written for it). Print it with 3 decimals for the question "How do I get my money back?" against the keys of passage D1 in Topic 12.3.

02

A passage of 200 tokens is stored in two ways: one vector per token with 128 numbers of 4 bytes each, or one vector of 384 numbers of 4 bytes. Write the byte counts and print how many times larger the per-token storage is, to one decimal. These sizes are examples for the arithmetic, not those of any named model.

Explain it without notes

01

Why might a passage need more than one vector?

02

What are hypothetical questions as keys, and how do they differ from HyDE?

03

Explain MaxSim and why a pooled vector can rank passages differently.

04

What are the cost trade-offs of the three multi-vector ideas?

Late interaction (MaxSim) by hand with 2-number vectors
Sign in to run this example in your browser.

Expected output

A: one pooled vector 0.500 | MaxSim 2.000
B: one pooled vector 0.700 | MaxSim 1.400
C: one pooled vector 0.500 | MaxSim 1.000