Questions as extra keys for a passage
Jaccard on word sets stands in for a real similarity. The written questions are hand-made stand-ins for a model's output. The point is the rule: score a passage by its best key.
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.
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.
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
Why might a passage need more than one vector?
What are hypothetical questions as keys, and how do they differ from HyDE?
Explain MaxSim and why a pooled vector can rank passages differently.
What are the cost trade-offs of the three multi-vector ideas?
Expected output
Q: I forgot my login, how do I get back in?
D1 whole passage 0.074 | best question key 0.308
key: Can I get my money back if I cancel?
D3 whole passage 0.037 | best question key 0.800
key: I forgot my password, how do I get back in?