Skip to content
Edit this page

A smaller encoder for queries

Documents through modernbert-ja-310m, queries through modernbert-ja-30m, built as the guide describes and compared with the symmetric models of The published SAE. The two encoders have the same tokenizer: 102,400 entries with the same ids.

Everything but --query-model is the symmetric run: 2,000 steps of 16 queries on the retrieval subsets of cl-nagoya/ruri-v3-dataset-ft without jqara, the settings tuned on the small encoder, a FLOPS term on both sides. --query-regularizer l1, the other half of the efficiency study the idea comes from, was not used. Seeds 42, 43 and 44 on one NVIDIA RTX 4090.

Accuracy

nDCG@10 on 800 test queries of JQaRA with 100 candidates each:

Head Query encoder nDCG@10 Vectors capped at 64 / 256 weights Non-zero weights, query / document FLOPS
Vocabulary (logit shift, 16 logits per position) 310M, the same as documents 0.640 / 0.645 / 0.643 0.614 / 0.630 / 0.617 about 102 / 470 6.1 to 6.6
30M 0.592 / 0.598 / 0.586 0.566 / 0.583 / 0.571 about 82 / 476 2.3 to 3.1
Frozen SAE (65,536 latents) 310M, the same as documents 0.640 / 0.643 / 0.637 0.638 / 0.647 / 0.633 about 117 / 245 5.9 to 6.4
30M, stitched head 0.361 / 0.333 / 0.337 0.347 / 0.325 / 0.321 about 121 / 213 11.3 to 12.4

Mean differences over the three seeds, small query encoder minus symmetric, with 95% intervals over the queries:

Head No cap 64 / 256
Vocabulary -0.051 (-0.060 to -0.041) -0.047 (-0.056 to -0.037)
SAE -0.297 (-0.313 to -0.280) -0.308 (-0.326 to -0.291)

Time to encode a query

The models of seed 42, 200 queries, milliseconds per query. The CPU is that of the same machine, limited to four threads.

Head Query encoder Parameters on the query side GPU, one query GPU, batches of 32 CPU, one query CPU, batches of 32
Vocabulary 310M 315,304,960 6.3 1.06 113.6 76.6
30M 36,873,728 3.2 0.42 22.6 14.7
SAE 310M 314,611,968 6.1 0.85 103.9 76.1
30M 36,705,536 3.0 0.27 14.9 6.7

What it shows

  • With a vocabulary head the small query encoder costs 0.05 nDCG@10 and a fifth of the time. One query on four CPU threads takes 23 ms instead of 114 ms, and half the time on the GPU. Queries also came out shorter, and FLOPS more than halved.
  • The stitched SAE head did not get there in this run. It starts far lower on the development queries (0.27 against 0.69 for the symmetric head) and reaches 0.64 where the symmetric head reaches 0.95. Its loss was still falling at the last step: 0.53 to 0.58, against 0.15 to 0.17 for the symmetric runs. Whether more steps close the gap was not tried.
  • Nothing aligns the two sides before training. The vocabulary pair also starts lower than the symmetric model on the development queries, 0.44 against 0.60, and ends at 0.90 against 0.93.
  • What this does not say. One pair of encoders, one benchmark, a short run and no distillation. The L1 regulariser on queries was not tried, and the times are of encoding a query, not of a search.

One of the runs:

python examples/train_retriever --head vocab --shift auto --fan-out 16 --regularizer-weight 3.33e-5 \
  --model sbintuitions/modernbert-ja-310m --query-model sbintuitions/modernbert-ja-30m \
  --dataset cl-nagoya/ruri-v3-dataset-ft --subsets auto-wiki-qa-nemotron jaquad jsquad miracl mkqa mr-tydi quiz-works \
  --query-column anc --positive-column pos --negative-column neg --negatives 1 \
  --max-seq-length 256 --max-steps 2000 --batch-size 16 --mini-batch-size 8 \
  --learning-rate 2e-5 --loss-scale 0.2 --seed 42 \
  --eval-benchmark jqara --eval-split dev --eval-caps full 64/256 --out runs/asymmetric

The measured runs also read the subset quiz-no-mori and dropped the training rows whose question is a question of JQaRA (--exclude-queries).