tirtho149's picture
Add retriever study (code, predictions, one-pager), refresh response cache
874eec2 verified
|
Raw History Blame Contribute Delete
5.15 kB
# Retriever pilot (branch `retriever-pilot`, 2026-11-17)
Question (Shreyan): can a small neural retrieval function, possibly with weights written by a bigger LLM, replace BM25 in MACE?
Setting: P1 MACE, Sonnet captions, seed 0, K = 4, the same per-query memory banks, 1,600 queries (1,000 IID, 600
held-out). Retrieval only, no diagnosis call. Proxies: hit@4 (true disease among the four retrieved entries; MACE gains
only on hits), vote (majority label of the four), top-1 label. Equal-crop means (%), paired crop-stratified bootstrap
for the hit@4 difference against BM25.
All retrievers score a (test caption, memory caption) pair from the same 16 features: whole-caption BM25 (the current
retriever), per-field BM25 and Jaccard for the seven caption fields, and organ match.
| Retriever | hit@4 IID | hit@4 held-out | vote IID | vote held-out | top-1 IID | top-1 held-out | hit@4 vs BM25, IID [95% CI] | held-out |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| BM25 (paper) | 83.1 | 73.3 | 55.0 | 43.8 | 53.0 | 40.7 | | |
| Trained linear | 83.4 | 73.3 | 56.0 | 44.5 | 52.6 | 41.7 | +0.3 [-1.5, 2.1] | +0.0 [-2.7, 2.7] |
| Trained MLP (16-16-1) | 82.0 | 73.0 | 55.0 | 43.8 | 51.5 | 40.5 | -1.1 [-3.1, 0.8] | -0.3 [-3.0, 2.3] |
| LLM weights, schema only | 83.1 | 73.7 | 54.2 | 41.0 | 52.1 | 39.8 | +0.0 [-2.2, 2.1] | +0.4 [-3.0, 3.5] |
| LLM weights, schema + memory captions | 82.5 | 73.2 | 54.3 | 41.2 | 51.6 | 41.7 | -0.6 [-2.7, 1.5] | -0.1 [-3.3, 3.0] |
- BM25 here reproduces the recorded P1 retrieval on 1,600/1,600 queries.
- Trained models: leave-one-out pseudo-queries over the 20 memory banks only (74,376 pairs); no query image or label.
- LLM weights: Sonnet writes 16 linear weights per crop (one call per crop and context, 20 calls, USD 0.35). Context A:
feature definitions, crop, disease list. Context B: the same plus the crop's memory captions and labels.
- Finding: no variant moves hit@4 by more than about one point; every interval includes zero. With lexical caption
features, BM25 is already near what a small reweighting can reach, and giving the LLM the memory captions did not help.
Not tested: a network over learned text or image embeddings, LLM-written term weights, and diagnosis accuracy. Run
`python -m experiments.retriever_pilot.pilot` (add `--no-llm` to skip the 20 calls; cached calls cost nothing).
## Tuning (`tune.py`)
Tuned on a clean validation set, then one look at the 1,600 test queries. Validation: 2,215 training-fold images that are
in the seed-0 K=16 memory but not in the K=4 memory MACE uses, and are never test queries, scored against that K=4
memory. Search: BM25 k1, b and organ repeat; DINOv2 image similarity added with weight alpha; at most `cap` entries per
disease. 1,296 configs; objective hit@4, then true-disease entries among the four.
| Retriever | config (k1, b, organ x; alpha; cap) | hit@4 IID | hit@4 held-out | true entries IID | held-out | vote IID | vote held-out | hit@4 vs BM25, IID [95% CI] | held-out |
|---|---|---:|---:|---:|---:|---:|---:|---:|---:|
| BM25 (paper) | (1.2, 0.75, 3); 0; 4 | 83.1 | 73.3 | 1.64 | 1.29 | 55.0 | 43.8 | | |
| Image only (DINOv2) | -; image; 4 | 81.0 | 69.3 | 1.55 | 1.11 | 50.7 | 36.0 | -2.1 [-4.7, 0.5] | -4.0 [-8.0, 0.0] |
| Text + image, no cap | (2.0, 0.3, 0); 1.5; 4 | 86.3 | 74.2 | 1.75 | 1.25 | 60.1 | 40.7 | +3.2 [1.3, 5.2] | +0.8 [-2.0, 3.7] |
| Text + image, one per disease | (2.0, 0.3, 0); 1.5; 1 | 89.3 | 80.3 | 0.89 | 0.80 | 58.3 | 42.7 | +6.2 [4.2, 8.1] | +7.0 [4.2, 9.8] |
- Adding image similarity to BM25 raises IID coverage (+3.2 hit@4, +5 vote) but not held-out (vote drops 3 points).
- One entry per disease is the largest coverage win on both splits, but the VLM then sees each disease once, so the label
majority signal that drives most of MACE's gain disappears. Whether coverage or repetition matters more can only be
settled by a diagnosis run; these are retrieval proxies.
- Retrieved ids for every selected config: `out/tune_retrieved.json`.
## Diagnosis check (`diag.py`, 200-query efficiency panel, Sonnet, USD 4.32)
Same request as MACE except which four entries are listed. The BM25 arm went through the same code path and hit the
cache of the recorded P1 calls on 200/200 queries with 200/200 identical predictions.
| Method | IID | held-out | vs MACE (BM25), IID [95% CI] | held-out |
|---|---:|---:|---:|---:|
| SAGE | 32.0 | 38.0 | -23.0 [-32.0, -14.0] | -22.0 [-30.0, -14.0] |
| MACE (BM25) | 55.0 | 60.0 | | |
| Text + image retrieval | 56.0 | 63.0 | +1.0 [-5.0, +7.0] | +3.0 [-4.0, +10.0] |
| One entry per disease | 47.0 | 58.0 | -8.0 [-15.0, -1.0] | -2.0 [-10.0, +6.0] |
- The retrieval-coverage win did not become a diagnosis win. One entry per disease raised hit@4 by 6 to 7 points but
lowered IID accuracy by 8: the VLM needs the true label repeated, which matches the paper's finding that the retrieved
labels carry most of the gain.
- Text + image retrieval is directionally positive (+1 IID, +3 held-out) but far inside the noise on 200 queries.
Telling a 1 to 3 point gain apart from zero would need the full 1,600 queries (about USD 25 for this one arm).