Explanations that Transfer: Interpreting Medical Retrieval with Sparse AutoEncoders
Organizations: Doctolib AI Research Lab, Paris, France
Abstract
Medical AI systems that answer users' queries rely on retrieving medical knowledge from large document collections. In this context, finetuning general models on medical datasets can improve retrieval relevance. Yet the dense embeddings underlying modern retrieval systems remain largely opaque, making it difficult to understand the mechanics behind their results. Moreover, adapting to a specific medical dataset risks losing transferability to new clinical corpora. In this work, we tackle these issues by applying Sparse Autoencoders (SAEs) to medical information retrieval, transforming dense text embeddings into semantically interpretable representations. To do so, our model combines a reconstruction objective with an InfoNCE contrastive loss that directly preserves query-document relevance. We evaluate three embedding models across six medical retrieval datasets, both in-domain and out-of-domain. Trained on a medical corpus, our sparse codes improve in-domain retrieval over the original embeddings, and lose less out-of-domain performance than their dense counterparts, especially when the target corpus is distant from the training one. Importantly, our experiments show that the method yields interpretable features whose semantic content can be inferred from the queries and documents that activate them most strongly. The interpretation of these features sheds light on why a particular document was retrieved, and transfers beyond the training distribution.
Figures & tables
| academic literature | StackExchange queries over Wikipedia | ||||||
| R2MED | |||||||
| CURE | NFCorpus | MIRIAD | Bioinformatics | Biology | Medical-Sciences | ||
| Gemini | original | 52.77 | 42.22 | 84.93 | 51.35 | 32.94 | 52.51 |
| k=64 | 58.05 1.33 | 32.98 3.62 | 76.33 3.79 | 39.84 8.38 | 20.64 8.57 | 39.57 2.60 | |
| k=128 | 58.76 0.47 | 35.19 0.23 | 79.07 0.45 | 41.48 2.83 | 23.26 1.30 | 44.23 4.85 | |
| k=256 | 59.85 0.45 | 37.42 1.06 | 80.49 0.78 | 44.80 2.66 | 26.36 1.59 | 47.86 2.50 | |
| Neuron 2177 : bone | |
|---|---|
| Snippets | Doc [0.29] A common view on bone tissue engineering portrays four vital aspects for bone regeneration. A scaffold that… Query [0.27] What is the role of cells in these bone grafts? |
| TF-IDF terms | bone, osteomyelitis, cells, bone grafts, recognised |
| Interpreter LLM | bone: This neuron reacts to documents and queries about bone tissue, bone regeneration, bone remodeling, and bone cells. (keywords: bone, regeneration, cells, tissue, remodeling, vascularization) |
| Med-Sciences | [0.27] Osteocyte feedback Feedback from physical activity maintains bone mass, while feedback from osteocytes limits… |
| Dataset | TF-IDF terms | Interpreter LLM | Snippets |
|---|---|---|---|
| CURE | 0.439 | 0.440 | 0.308 |
| NFCorpus | 0.236 | 0.257 | 0.190 |
| Bioinformatics | 0.276 | 0.290 | 0.183 |
| Biology | 0.235 | 0.226 | 0.142 |
| Med-Sciences | 0.281 | 0.286 | 0.173 |
Appendix figures & tables27 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Role | Documents | Queries | Rel./query | Relevance |
|---|---|---|---|---|---|
| CURE | ID | 244600 | 400 | 39.3 | graded |
| MIRIAD | OOD | 31000 | 1000 | 1.0 | binary |
| NFCorpus | OOD | 3633 | 323 | 38.2 | graded |
| R2MED Biology | OOD | 57359 | 103 | 3.6 | binary |
| R2MED Bioinformatics | OOD | 47473 | 77 | 2.9 | binary |
| R2MED Medical-Sciences | OOD | 34810 | 88 | 2.8 | binary |
| Count | Shared span |
|---|---|
| 134 | the patient was admitted to the hospital due |
| 61 | the patient was admitted to the hospital for |
| 57 | patient was advised to follow up with her |
| 24 | stable condition and advised to follow up with |
| 19 | the patient was discharged from the hospital in |
| 17 | year old female patient was admitted to the |
| Dataset | =64 | =128 | =256 | dense ( ) | Original | |
|---|---|---|---|---|---|---|
| BGE | ||||||
| CURE | 57.07 1.25 | 59.35 0.35 | 60.50 1.02 | 61.87 0.55 | 60.18 0.56 | 53.06 |
| NFCorpus | 31.89 0.59 | 34.48 3.70 | 35.61 0.08 | 36.62 0.29 | 36.83 2.06 | 38.17 |
| MIRIAD | 68.75 0.49 | 71.83 1.54 | 73.85 0.92 | 75.05 0.36 | 75.27 1.60 | 77.24 |
| Bioinformatics | 22.50 1.61 | 27.42 3.21 | 28.10 0.89 | 27.21 1.98 | 26.89 2.46 | 27.04 |
| Biology | 8.30 2.93 | 9.76 2.91 | 10.06 1.17 | 8.37 0.65 | 10.31 1.15 | 12.72 |
| academic literature | StackExchange queries over Wikipedia | |||||
| R2MED | ||||||
| CURE | NFCorpus | MIRIAD | Bioinformatics | Biology | Medical-Sciences | |
| Gemini | ||||||
| original | 52.77 | 42.22 | 84.93 | 51.35 | 32.94 | 52.51 |
| =64 | ||||||
| =9216 | 58.05 1.33 | 32.98 3.62 | 76.33 3.79 | 39.84 8.38 | 20.64 8.57 | 39.57 2.60 |
| academic literature | StackExchange queries over Wikipedia | |||||
| R2MED | ||||||
| CURE | NFCorpus | MIRIAD | Bioinformatics | Biology | Medical-Sciences | |
| Gemini | ||||||
| k=64 | ||||||
| k=128 | ||||||
| k=256 | ||||||
| academic literature | StackExchange queries over Wikipedia | |||||
| R2MED | ||||||
| CURE | NFCorpus | MIRIAD | Bioinformatics | Biology | Medical-Sciences | |
| Gemini | ||||||
| k=64 | ||||||
| k=128 | ||||||
| k=256 | ||||||
| Dataset | TF-IDF terms | Interpreter LLM | Snippets |
|---|---|---|---|
| CURE | 0.465 | 0.491 | 0.360 |
| NFCorpus | 0.304 | 0.330 | 0.257 |
| Bioinformatics | 0.330 | 0.347 | 0.229 |
| Biology | 0.246 | 0.258 | 0.194 |
| Med-Sciences | 0.319 | 0.333 | 0.245 |
| Dataset | TF-IDF terms | Interpreter LLM | Snippets |
|---|---|---|---|
| CURE | 0.439 | 0.439 | 0.320 |
| NFCorpus | 0.262 | 0.279 | 0.187 |
| Bioinformatics | 0.288 | 0.287 | 0.158 |
| Biology | 0.203 | 0.209 | 0.145 |
| Med-Sciences | 0.278 | 0.298 | 0.194 |
| Dataset | TF-IDF terms | Interpreter LLM | Snippets |
|---|---|---|---|
| CURE | 0.732 | 0.739 | 0.665 |
| NFCorpus | 0.625 | 0.635 | 0.600 |
| Bioinformatics | 0.644 | 0.649 | 0.595 |
| Biology | 0.623 | 0.620 | 0.577 |
| Med-Sciences | 0.645 | 0.651 | 0.594 |
| MIRIAD | 0.665 | 0.677 | 0.619 |
| Corpus | Interpretation | 1-5 | 6-10 | 11-15 | 16-20 | |
|---|---|---|---|---|---|---|
| CURE | TF-IDF | 0.525 | 0.388 | 0.314 | 0.271 | |
| Interpreter LLM | 0.449 | 0.321 | 0.246 | 0.210 | ||
| Snippets | 0.554 | 0.434 | 0.368 | 0.338 | ||
| NFCorpus | TF-IDF | 0.315 | 0.218 | 0.159 | 0.129 | |
| Interpreter LLM | 0.385 | 0.252 | 0.202 | 0.180 | ||
| Snippets | 0.487 | 0.386 | 0.355 | 0.318 |
| Corpus | Interpretation | 1-5 | 6-10 | 11-15 | 16-20 | |
|---|---|---|---|---|---|---|
| CURE | TF-IDF | 0.509 | 0.420 | 0.349 | 0.303 | |
| Interpreter LLM | 0.445 | 0.344 | 0.279 | 0.247 | ||
| Snippets | 0.553 | 0.469 | 0.420 | 0.372 | ||
| NFCorpus | TF-IDF | 0.342 | 0.228 | 0.201 | 0.160 | |
| Interpreter LLM | 0.414 | 0.278 | 0.250 | 0.217 | ||
| Snippets | 0.492 | 0.392 | 0.364 | 0.322 |
| Corpus | Interpretation | 1-5 | 6-10 | 11-15 | 16-20 | |
|---|---|---|---|---|---|---|
| CURE | TF-IDF | 0.518 | 0.396 | 0.309 | 0.262 | |
| Interpreter LLM | 0.436 | 0.308 | 0.244 | 0.197 | ||
| Snippets | 0.537 | 0.419 | 0.357 | 0.319 | ||
| NFCorpus | TF-IDF | 0.333 | 0.220 | 0.168 | 0.142 | |
| Interpreter LLM | 0.392 | 0.273 | 0.208 | 0.185 | ||
| Snippets | 0.475 | 0.384 | 0.327 | 0.309 |
| Corpus | Interpretation | 1-5 | 6-10 | 11-15 | 16-20 | 21-30 | 31-45 | 46-64 | Inactive | |
|---|---|---|---|---|---|---|---|---|---|---|
| CURE | TF-IDF | 0.528 | 0.448 | 0.371 | 0.321 | 0.240 | 0.201 | 0.193 | 0.109 | |
| Interpreter LLM | 0.461 | 0.326 | 0.312 | 0.225 | 0.190 | 0.141 | 0.127 | 0.061 | ||
| Snippets | 0.549 | 0.466 | 0.419 | 0.384 | 0.354 | 0.316 | 0.303 | 0.269 | ||
| NFCorpus | TF-IDF | 0.338 | 0.260 | 0.182 | 0.137 | 0.135 | 0.112 | 0.113 | 0.083 | |
| Interpreter LLM | 0.383 | 0.272 | 0.221 | 0.169 | 0.165 | 0.141 | 0.144 | 0.105 | ||
| Snippets | 0.444 | 0.394 | 0.408 | 0.337 | 0.352 | 0.324 | 0.306 | 0.285 |
| TF-IDF terms | Interpreter LLM | Snippets | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Dataset | SAE | Original | SAE | Original | SAE | Original | |||
| CURE | 0.439 | 0.255 | 0.190 | 0.440 | 0.317 | 0.210 | 0.308 | 0.184 | 0.141 |
| NFCorpus | 0.236 | 0.153 | 0.106 | 0.257 | 0.191 | 0.149 | 0.190 | 0.114 | 0.091 |
| Bioinformatics | 0.276 | 0.154 | 0.074 | 0.290 | 0.194 | 0.110 | 0.183 | 0.115 | 0.056 |
| Biology | 0.235 | 0.094 | 0.036 | 0.226 | 0.138 | 0.052 | 0.142 | 0.096 | 0.018 |
| Med-Sciences | 0.281 | 0.151 | 0.072 | 0.286 | 0.200 | 0.086 | 0.173 | 0.114 | 0.052 |
| LLM | CURE | NFCorpus | Bioinformatics | Biology | Med-Sciences | MIRIAD |
|---|---|---|---|---|---|---|
| TF-IDF terms | ||||||
| Gemma3-4B | 0.453 | 0.302 | 0.292 | 0.272 | 0.313 | 0.374 |
| MedGemma | 0.439 | 0.236 | 0.276 | 0.235 | 0.281 | 0.313 |
| Qwen2.5-3B | 0.373 | 0.263 | 0.214 | 0.145 | 0.173 | 0.279 |
| Interpreter LLM | ||||||
| Gemma3-4B | 0.482 | 0.289 | 0.283 | 0.256 | 0.299 | 0.380 |
| rank | n2668 | n1976 | n1460 | n7 | n869 | |||
| Passage | orig. | SAE | rel. | smok. | pregn. | infant | matern. | patern. |
| Smoking_Pregnancy_And_Babies_6 | 2 | 1 | 0.284 | 0.099 | 0.097 | 0.082 | 0.000 | |
| Smoking_During_Pregnancy_5 | 12 | 2 | 0.314 | 0.095 | 0.069 | 0.089 | 0.000 | |
| Smoking_During_Pregnancy_1 | 7 | 3 | 0.250 | 0.073 | 0.112 | 0.068 | 0.000 | |
| Smoking_During_Pregnancy_2 | 10 | 4 | 0.299 | 0.080 | 0.080 | 0.045 | 0.000 | |
| Birth_Defect_15 (paternal) | 4 | 5 | 0.324 | 0.035 | 0.080 | 0.000 | 0.036 | |
| dead latents | % of | ||||
| BGE ( =3072) | |||||
| 64 | 167.3 | 39.6 | 5.45 | 1.29 | |
| 128 | 36.3 | 2.9 | 1.18 | 0.09 | |
| 256 | 29.7 | 20.7 | 0.97 | 0.67 | |
| Gemini ( =9216) | |||||
| 64 | 2713.0 | 156.1 | 29.44 | 1.69 | |
Information Retrieval
Information Retrieval studies how to find, rank, and organize relevant information in large collections of data.
See all 495 papers