Log inStart free
LESSON 22.07 · 5 STAGES · 2 CONTROLS · 2 CHECKSPRO · PREVIEW

Dense retrieval with bi-encoders

Watch documents and a query become vectors, then the closest vectors come back.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 2 controls and 2 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 22.07 · SEARCH BAY12 DOCUMENTS · 12 ENCODER CALLS, ONCE
01
Stage 1 of 5 · Encode documents
A bi-encoder runs an encoder on each document once, before any query. Each document becomes a vector of 6 numbers.
Explain it simply

Each row is one help page. The encoder reads the teal words and adds up their meanings, one column per meaning. A word like the or fast has no meaning here, so it adds nothing. This runs once for all 12 pages, before anyone searches.

A table of 12 documents. Each document has a vector of 6 numbers: battery, charging, heat, screen, keys and error. D1 has the vector [1.8, 0, 0, 2.3, 0, 0].

words with a vector, vectorsscore, top 3, relevantwrong in top 3, missedno vector, zero
D1Batterydrainsfast? Lowerthescreen…1.8002.300D2Batterytips: acoolbatteryisa…3.601.0000D3ThelaptopchargesfastwiththeUSB-C…0.72.20000D4Myoldlaptopfromschoolnowshuts…2.50.60000.2D5ErrorE42meansthelaptopcannotfind…1.000001.2D6FixerrorE42: openthelaptop, reseat…1.00.50001.5D7Fannoiseandoverheating: cleanthe…002.4000.7D8Ifthelaptopfeelswarm, keepitona…000.7000D9Screenflickers? Restartthecomputer…0001.301.9D10PrintererrorE42: thepapertrayis…000001.2D11Hotkeys: pressFnandF2todimthe…001.01.62.60D12Keysstick? Cleanthekeyboardwithdry…000.302.20.6document vectors, built oncebatterychargingheatscreenkeyserrordocumentD1 = battery + drains + lower + screen + brightness= [1.8, 0, 0, 2.3, 0, 0]D1Batterydrainsfast? Lowerthescreen…1.8002.300D2Batterytips: acoolbatteryisa…3.601.0000D3ThelaptopchargesfastwiththeUSB-C…0.72.20000D4Myoldlaptopfromschoolnowshuts…2.50.60000.2D5ErrorE42meansthelaptopcannotfind…1.000001.2D6FixerrorE42: openthelaptop, reseat…1.00.50001.5D7Fannoiseandoverheating: cleanthe…002.4000.7D8Ifthelaptopfeelswarm, keepitona…000.7000D9Screenflickers? Restartthecomputer…0001.301.9D10PrintererrorE42: thepapertrayis…000001.2D11Hotkeys: pressFnandF2todimthe…001.01.62.60D12Keysstick? Cleanthekeyboardwithdry…000.302.20.6document vectors, built oncebatterychargingheatscreenkeyserrordocumentD1 = battery + drains + lower + screen + brightness= [1.8, 0, 0, 2.3, 0, 0]
Toy: 12 help-centre documents and 3 queries, shared with 22.C1; a hand-made 6-concept encoder, not trained
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
d=∑w∈docE(w)\sy{d}{data}{\mathbf d} = \sum_{w \in \text{doc}} \sy{e}{param}{E(w)}
d1=[1.8,0,0,2.3,0,0]\mathbf d_1 = [1.8, 0, 0, 2.3, 0, 0]

A document vector adds the vectors of its words.

Common mix-ups

MYTHA page needs the query's words to be found.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
2 CHECKS · PRO
Q01With the dot product, which page leads for "battery drains fast"?

Make your guess, then test it in the diagram. All 2 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 2 live controls
  • 2 mix-up cards and 2 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.