Retrieval training on a small scale¶
All of it is small: 2,000 steps of 16 queries, evaluated on JQaRA. None of it is a result about the methods in general.
First runs¶
examples/train_retriever with the defaults it documents: batch 16, one hard negative, 256 tokens, 2,000 steps, learning rate 2e-5 and a FLOPS weight of 3.33e-5 on both sides. The training data are the retrieval subsets of cl-nagoya/ruri-v3-dataset-ft without jqara, which may share documents with the evaluation. Each run is ranked on the same 200 JQaRA queries as the probe above, with a standard error near 0.02. The SAE on modernbert-ja-30m has 8,192 latents and was trained on 30 million tokens of the same data; trained again on the L4 it gave the same FVU (0.203) and masked-language-model loss recovered (0.837).
| Encoder and head | Hardware | nDCG@10 before | nDCG@10 after | Active dimensions, query / document | FLOPS |
|---|---|---|---|---|---|
| modernbert-ja-30m, SAE head | Apple M5 Pro, float32 | 0.371 | 0.459 | 113 / 220 | 46.0 |
| modernbert-ja-30m, SAE head | NVIDIA L4, float32 | 0.372 | 0.467 | 126 / 247 | 54.3 |
| modernbert-ja-30m, SAE head | NVIDIA L4, bfloat16 autocast | 0.372 | 0.400 | 102 / 166 | 42.4 |
ruri-v3-30m, SAE head (the 30-million-token topk SAE) |
Apple M5 Pro, float32 | 0.473 | 0.467 | 70 / 124 | 28.8 |
| modernbert-ja-30m, vocabulary head | NVIDIA L4, both precisions | 0.169 on 20 queries | collapsed | about 94,000 / 99,500 before training | about 92,600 before training |
- The SAE head trains stably. On modernbert-ja-30m, 2,000 steps lift nDCG@10 from 0.37 to about 0.46 and cut the active dimensions of a document from 915 to about 230. The two float32 runs, on different hardware, agree.
- bfloat16 autocast hurt the SAE head. It ended at 0.400 against 0.459 and 0.467 in float32. The head itself computes in float32, so the difference comes from the encoder's hidden states, which the SAE was trained on in float32 and whose rounding changes which latents the Top-K selects. These are single runs, but the gap is more than three standard errors. Train the SAE head in float32.
- The vocabulary head collapsed with this recipe and encoder. The language-model head of modernbert-ja-30m gives a positive logit for 43% of the vocabulary per token on average; its decoder bias, mean -3.6, does not change that much. After
log1p(ReLU)and the maximum over a document, about 99,500 of the 102,400 dimensions are active before training, scores run into the tens of thousands and the first losses are near 30,000. Within the first 100 to 200 steps every logit is pushed below zero and the gradient through the ReLU vanishes; this happened in float32 as well as bfloat16. The SAE head avoids this because its Top-K keeps 16 latents per token from the start. - These first runs do not compare the two heads. The vocabulary head needs a start that is not dense. The next section gives it one, the logit shift and the per-position limit of SPARSEUP, and compares.
- The SAE head on ruri-v3-30m became sparser without gaining accuracy. ruri-v3-30m is already trained for retrieval, on data that includes
jqara, and a short run with small batches leaves it no room to improve here.
The two heads compared¶
The same encoder, modernbert-ja-30m, with the two heads that differ in their dictionary only: the frozen SAE head (8,192 latents, k = 16, the SAE of the section above) and the vocabulary head with a shift at the 99.9th percentile of its logits (about 19 on this encoder) and 16 logits per position. Both pool the same tokens. Training is the same as above except for two settings found in a pilot: the scores are multiplied by 0.2 inside the contrastive loss, and the FLOPS weight of the SAE head is 3e-3 (3.33e-5 for the vocabulary head). Everything is float32, on an NVIDIA L4, with seeds 42, 43 and 44.
Two splits of JQaRA are used. The development split has 1,737 queries with 50 candidates each; its queries were removed from the training data. The test split has 100 candidates per query; 800 sampled queries are used where the vocabulary head is involved, because encoding with a 102,400-dimensional head is slow. "64/256" caps a query vector at its 64 largest weights and a document vector at 256. Intervals are 95% bootstrap intervals over runs and queries together.
| Head | Development, no cap | Development, 64/256 | Development, 64/64 | Test, no cap | Non-zero, query / document | FLOPS |
|---|---|---|---|---|---|---|
| SAE, frozen | 0.855 / 0.861 / 0.861 | 0.851 / 0.854 / 0.850 | 0.794 / 0.797 / 0.791 | 0.499 / 0.495 / 0.476 | about 160 / 310 | about 29 |
| Vocabulary, shifted | 0.873 / 0.875 / 0.874 | 0.877 / 0.876 / 0.869 | 0.782 / 0.788 / 0.777 | 0.574 / 0.568 / 0.559 | about 80 / 390 | about 7 |
(nDCG@10 per seed; non-zero counts and FLOPS on the development split without a cap. The test column of the SAE head is over all 1,667 test queries and that of the vocabulary head over the 800 sampled ones; the differences below use the 800 they share.)
| SAE head minus vocabulary head | Difference | Interval |
|---|---|---|
| Development, 64/256 | -0.022 | -0.031 to -0.013 |
| Development, no cap | -0.015 | -0.024 to -0.007 |
| Development, 64/64 | +0.012 | -0.001 to +0.024 |
| Test, 800 queries, no cap | -0.081 | -0.098 to -0.064 |
| Test, 800 queries, 64/256 | -0.081 | -0.099 to -0.062 |
- With this SAE and this much training, the vocabulary head is ahead, and its vectors cost about a quarter of the FLOPS. The SAE head matches it only under the strongest cap on the development split.
- The development split understates differences. With 50 candidates its scores sit near 0.87. The same pair of models differs by 0.02 there and by 0.08 on the test split; the effect of distillation and of more negatives below is two to four times larger on the test split as well. Some of the rerankers used as teachers below were themselves trained on JQaRA's development split, so that split is also not clean for any run that uses their scores.
- What this does not show. The SAE has 8,192 latents and saw 30 million tokens; published SAE retrievers use 32,768 to 131,072 latents, and the SAE card that states its training length gives about a billion tokens. The encoder is a small one and the retrieval training used 32,000 queries. SAE-SPLADE reports parity with SPLADE at its scale, and the same paper's ablation with the language-model head and 8 entries per token is as good as its SAE head.
Single runs with seed 42 on the same setup (development split unless stated):
| Change | Head | Effect on nDCG@10 |
|---|---|---|
| Scores times 1 instead of 0.2 | vocabulary | 0.843 instead of 0.873 without a cap, but 0.833 instead of 0.782 at 64/64, with 14 / 124 non-zero weights instead of 74 / 426: a sparser operating point |
| Scale moved from 0.2 to 1.0 during training | vocabulary | ends where a constant 1.0 ends (0.845; 16 / 109 non-zero) |
| The same | SAE | 0.831 instead of 0.855 |
| KL distillation from the mean of five rerankers, one negative | SAE | +0.006 (0.000 to 0.011); on the test split +0.015 (0.009 to 0.020) |
| The same | vocabulary | no change without a cap; +0.037 at 64/128 and +0.058 at 64/64, with fewer non-zero weights (48 / 300) |
| Four hard negatives instead of one | SAE | +0.015; on the test split +0.035 (0.029 to 0.042) |
| Training rows filtered by the rerankers' scores | both | +0.012 to +0.017 on the development split, -0.007 to -0.016 on the test split |
- The scale of the contrastive loss decides where the vocabulary head ends up between accurate and sparse; a schedule is no different from its final value.
- Distillation helps the SAE head a little everywhere and the vocabulary head when its vectors are capped.
- The gain from filtered data appears only on the split the teachers saw, which is why the test split is reported.
A 310M encoder with a published SAE¶
The same comparison one size up, to see whether the gap above belongs to SAE heads or to a small SAE. The encoder is modernbert-ja-310m. The SAE is the published one of that encoder, mahiyama/modernbert-ja-310m-sae: 65,536 latents, k = 16, trained by its author on about a billion tokens, brought in with muscari import-sae and kept frozen. The vocabulary head has the shift (9.8 on this encoder) and 16 logits per position. Every setting is the one tuned on the small encoder, unchanged; one run each with seed 42, on an NVIDIA L4 in float32. A training step took 2.5 s with the SAE head and 3.1 s with the vocabulary head.
| Head | Development (500 queries), no cap | 64/256 | 64/64 | Test (800 queries), no cap | 64/256 | Non-zero, query / document | FLOPS |
|---|---|---|---|---|---|---|---|
| SAE, frozen, before training | 0.666 | 0.691 | 0.565 | 274 / 1,044 | 39.8 | ||
| SAE, frozen | 0.946 | 0.944 | 0.927 | 0.637 | 0.638 | 113 / 234 | 5.9 |
| Vocabulary, shifted, before training | 0.601 | 0.627 | 0.570 | 312 / 1,059 | 65.8 | ||
| Vocabulary, shifted | 0.936 | 0.940 | 0.831 | 0.637 | 0.622 | 104 / 407 | 6.2 |
(Non-zero counts and FLOPS are without a cap: on the test queries for the trained models, on the development queries before training.)
On the test queries the SAE head minus the vocabulary head is +0.000 without a cap (95% interval over queries -0.010 to +0.011) and +0.016 at 64/256 (+0.005 to +0.027).
- At this size the two heads are level, and the SAE head keeps its accuracy when the vectors are capped. Its document vectors have 234 non-zero weights against 407.
- The gap on the small encoder was not a property of SAE heads. Between the two comparisons the encoder, the size of the SAE, the amount of text the SAE saw and who trained it all changed, so which of them closed the gap is not known.
- One seed each. The intervals cover the choice of queries only; on the small encoder, runs with different seeds differed by about 0.01 on the test split.