Basics · Inside MDBR-LEAF-IR · Asymmetric Prefix & MRL Lab

Asymmetric Query Prefix, Pairwise Matrix & MRL Probe

Inspect three mechanics that make MongoDB/mdbr-leaf-ir punch above its 23 MB weight: asymmetric query prompting, full pairwise cosine geometry, and Matryoshka truncation from 384d down to 64d.

1. Configure query & passage set

Initialise MDBR-LEAF-IR above to run the asymmetric prefix + MRL lab.

2. Asymmetric Query Prefix vs Raw Query

The exact same query is encoded twice in one worker pass: once with MongoDB's prompt "Represent this sentence for searching relevant passages: " and once raw. Passages are never prefixed.

Prefixed margin –
Unprefixed margin –
Margin delta –
Forward pass –
Live cosine similarity per passage: prefixed query vs unprefixed query
Passage Prefixed Q Raw Q Delta Tokens

3. Interactive N×N Cosine Heatmap & Matryoshka (MRL) Retention

N×N Cosine Heatmap Canvas

Includes Q+ (prefixed query), Q0 (raw query), and every passage. Click a cell or use the keyboard selectors below to inspect any pair.

Run the lab to inspect exact cosine pairs.

Matryoshka (MRL) Truncation Curve (64d → 384d)

Computed instantly in-memory by slicing the first d dimensions of the live 384-d embeddings and re-normalizing — zero extra model passes.

MRL dimension retention & storage footprint
Dim Pos cos Margin Top-1 fp32 / int8

Exact implementation code

Show the code — Mean-pooled 384-d worker inference (worker.js) Lines 189–264
Show the code — Matryoshka (MRL) retention curve (leaf-core.mjs) Lines 282–312