When a language model answers a question in medicine or applied mathematics, it usually fails for a specific reason: one or two concepts in the question are missing from what it learned in training. Systems that add a search step, called retrieval-augmented generation, ignore this. They build the search query from the question text alone, so the same passages come back whether the model already knows the concept or has never seen it. This proposal uses the model's own internal state to decide which parts of the question to search for. We take the activations of a fixed language model (the "reader") on a large set of domain concepts and compare the ones it demonstrably knows with the ones it does not. The difference gives a direction in activation space that marks a concept as unfamiliar to the model. At query time we score every span of the question along this direction. The spans the model does not know are sent as exact-match keyword queries to a sparse index, and the whole question goes to a dense semantic index. The balance between the two indices is set by how much of the question the model does not know.
The claim that can be tested is that retrieval should depend on the reader as well as the question. Two readers given the same question should receive different evidence, and each should answer better with its own evidence than with the other's. Query-only methods cannot do this by construction. If the claim holds, it gives a clean way to connect interpretability methods to retrieval in domains where models are known to lack knowledge. If it fails, cheaper signals such as rare-word statistics or token surprisal are enough, and that is also worth knowing.
Core Claim
Contrastive activation analysis compares a model's internal states under two conditions so that shared background activity cancels and only the signal of interest remains. Steering Llama 2 via Contrastive Activation Addition averages differences between positive and negative prompts into a single direction. Latent Fact-Checking applies the same recipe to find a "falsehood direction" and classifies claims by projecting onto it. On LIAR it reaches 0.70 accuracy with Llama-3.2-1B, against 0.47 for prompting.
That paper both motivates and constrains this proposal. Its projection degrades on AVeriTeC, where the truth depends on outside evidence. The authors name "incorporating representations of retrieved web evidence" as future work. We read their negative result as useful: the direction encodes what the model has stored in its weights, and that is exactly the signal needed to locate where stored knowledge runs out.
Our claim is that a direction contrasting known and unknown domain concepts has three properties. It identifies, span by span, which parts of a query the reader cannot answer from memory. It does so better than how surprising the words are, because a model can predict a technical string fluently without knowing what it means. And using it to shape hybrid retrieval, meaning combined keyword and semantic search, improves downstream answers at a fixed passage budget.
Positioning Against Prior Work
The closest retrieval work is Contextualized Query Embeddings for Conversational Search (CQE). CQE reads term importance from the size (L2 norms) of token embeddings inside a query encoder, builds a keyword query from them, and runs BM25 alongside dense search in about 11ms. CQE supplies the mechanism we reuse: turning dense internal states into a sparse query.
We change two things relative to CQE. Our signal comes from the reader rather than a retrieval encoder. And it is contrastive and defined by knowledge (known versus unknown) rather than by salience. A term can be highly important to the query and already known to the reader, and in that case we deliberately do not spend keyword budget on it.
Two systems motivate the problem without solving it. Domain-specific Question Answering with Hybrid Search combines a fine-tuned dense retriever, BM25 and host boosting with fixed weights. On its Adobe dataset it reaches nDCG 0.847, against 0.760 for OpenAI embeddings and 0.640 for BM25. Augmenting Black-box LLMs with Medical Textbooks (LLM-AMT) pairs SPLADE and DPR with a cross-encoder reranker over 51 textbooks, retrieves for every query, and treats the reader as a black box. We keep their insistence on dense, authoritative corpora and replace their reader-blind query with a reader-aware one.
Sparse, Dense, and Attentional Representations for Text Retrieval supplies the standard linear fusion that we make query-dependent. BEIR supplies the evidence that dense retrievers collapse out of domain, which is why the keyword channel matters for unfamiliar technical terms.
Two activation-analysis papers also stay entirely inside the model. Enhancing Chain-of-Thought Reasoning via Neuron Activation Differential Analysis amplifies neurons that fire differently on good and bad reasoning, and SADI steers with contrastive masks. Both assume the knowledge is already in the weights. We target the opposite case, where it is absent.
Steering Large Language Model Activations in Sparse Spaces warns that directions in the model's raw (dense) activation space mix several concepts together. It motivates a variant that uses a sparse autoencoder, a model trained to break activations into interpretable features, as a check on whether our dense direction is confounded.
TheoremQA is a constraint that cuts against us. Putting theorem definitions in context did not significantly help, so retrieving the right fact may not be enough. We address this directly in the experiments rather than assume it away.
Research Program
The first step builds the direction. For a fixed open reader, such as Llama-3-8B and Llama-3.2-3B as the two readers for the crossover test, we assemble several thousand domain concepts. They come from the medical textbook corpus used by LLM-AMT and from the 350 theorems named in TheoremQA. No concept that appears in an evaluation question goes into this set.
Each concept is labeled known or unknown by closed-book probing. The reader must define the concept and answer one short application question. A judge grades the answers against the textbook passage, and a subset is checked by hand to estimate how noisy the labels are.
We record activations on the concept's tokens at intermediate layers. If $\mu_{u}$ and $\mu_{k}$ are the mean activations at layer $\ell$ over unknown and known concepts, the gap score of a query span $t$ is
$$s(t) = \langle \bar h_\ell(t) - \tfrac{1}{2}(\mu_u+\mu_k),\; \mu_u-\mu_k \rangle,$$
where $\bar h_\ell(t)$ is the mean activation over the span's tokens. The layer is chosen on a held-out set of concepts by how well $s(t)$ separates known from unknown. We also train a logistic probe and a sparse-autoencoder variant to see whether a simple mean-difference direction is enough.
The second step uses the score for retrieval. We split each query into noun-phrase and entity spans. Spans whose score exceeds a threshold form a weighted keyword query for BM25 or SPLADE, with weights proportional to $s(t)$. The full question forms the dense query. Writing $g(q)$ for the fraction of the query's span mass that lies above the threshold, the fused score is
$$\text{Score}(q,p) = g(q)\cdot \text{Score}_{\text{sparse}}(q_{\text{gap}},p) + (1-g(q))\cdot \text{Score}_{\text{dense}}(q,p),$$
where $p$ is a passage and $q_{\text{gap}}$ is the gap-span query. If no span crosses the threshold, then $g(q)=0$ and retrieval falls back to dense search. We also test skipping retrieval altogether in that case, as a separate gating ablation.
The third step is analysis. We ask whether the direction trained on medical concepts transfers to theorems. We ask where in the network it is best separated. And we ask whether it dissociates from surprisal on concepts with familiar names but unknown content, such as eponymous syndromes and theorems.
Baselines
The naive reference point is the reader answering with no retrieval. Beside it is a static hybrid baseline: BM25 plus a dense retriever with a single fusion weight tuned on the development split, which is the scheme used by the Adobe system and by ME-HYBRID in Sparse, Dense, and Attentional Representations. That paper reports MRR@10 0.343 on MS MARCO, against 0.302 for a single-vector dual encoder.
The strongest existing method is an LLM-AMT-style pipeline: SPLADE plus DPR over the same textbook corpus, followed by the cross-encoder reranker. It is the strongest competitor because it already closes most of the medical gap. With GPT-4-Turbo it reports 88.1% on MedQA-USMLE, against 85.4% for Med-PaLM 2. It also reports gains of 7.8% to 13.7% from textbooks over Wikipedia LLM-AMT. Because we use open readers, we re-run this pipeline with our reader rather than compare against the GPT-4 number.
Every system gets the same corpus, the same reranker, the same reader, the same number of passages placed in context, and the same budget for tuning thresholds and weights on the same development split. Beating it means a statistically significant gain in answer accuracy at equal passage count. On MedQA and MedMCQA that means paired bootstrap over questions. A gain that appears only when our method gets more passages does not count.
Three query-side competitors isolate the key ingredient. The first selects keyword spans by rarity in the corpus (inverse document frequency). The second selects them by CQE-style embedding norms from the dense query encoder CQE. The third selects them by the reader's own per-token surprisal.
A fourth competitor is a small learned router that predicts the fusion weight from query text alone, trained on development queries labeled with the best weight for each.
Two ablations complete the set. One replaces the contrastive direction with a random direction, or with one trained on shuffled known/unknown labels. The other uses the gap score only to set $g(q)$, without building the gap query, and the reverse.
Why not just…?
Why not just always retrieve with the strongest hybrid pipeline and a reranker? This is the real threat. A good reranker over an authoritative corpus may already surface the passages the reader needs, and LLM-AMT's numbers show how far that goes. Our answer is empirical. If gap-aware query construction gives no accuracy gain over the re-run LLM-AMT-style pipeline at equal passage count, the proposal's central claim fails. The place we expect to win is questions with several concepts and a tight passage budget, where a reader-blind query spends slots on concepts the reader already knows. We report accuracy by number of passages and by number of concepts per question so that this regime is visible.
Why not just use the reader's surprisal, or word rarity, to find unfamiliar terms? Surprisal measures whether the model can predict a string, not whether it knows what the string refers to. Eponymous syndromes and named theorems are often predictable as text yet empty as knowledge. TheoremQA's "non-rectifiable errors" in open models below 15% accuracy TheoremQA suggest that failures come from missing content, not unreadable text. We test this directly. We build a dissociation set where surprisal and probe labels disagree, and we report how well each signal separates known from unknown concepts (AUROC) on it. If surprisal matches the contrastive direction there, we would recommend surprisal, since it is cheaper.
Why not just route between keyword and semantic search with a classifier on the query text? A text-only router can learn that queries full of codes or entity names favor BM25, which is the pattern BEIR documents BEIR. It cannot know which reader is downstream. The crossover experiment below is designed so that a text-only router must give identical retrieval to both readers. Any reader-specific benefit therefore counts against it.
Why not just use a bigger model or fine-tune on the domain? Scale does not close these gaps. GPT-4 reaches only 51% on TheoremQA, against 60–95% for human undergraduates. And retrieval from a compact corpus beat a model pretrained on medical text in the LLM-AMT comparison. Fine-tuning changes which concepts the reader knows, which is compatible with our method rather than a substitute: the direction would simply be re-estimated after fine-tuning. We do not run fine-tuning baselines beyond reporting that the gap direction can be recomputed.
Proposed Experiments
The primary end-task benchmarks are MedQA-USMLE, MedQA-MCMLE and MedMCQA over the textbook corpus, and TheoremQA over a corpus of theorem passages, scored by answer accuracy.
Retrieval quality is checked on the BEIR biomedical and scientific subsets: TREC-COVID, NFCorpus, BioASQ and SciFact, scored by nDCG@10. These relevance judgments do not depend on the reader, so this test only shows that gap-aware queries do not damage ordinary retrieval. We also report gap coverage: the fraction of the reader's gap-labeled concepts that appear in the retrieved passages, judged against independent probe labels.
The decisive check is a reader crossover. Retrieval guided by the 3B reader's direction and by the 8B reader's direction is computed for every question. Each reader then answers using both retrieval sets. The proposal predicts an interaction: each reader does better with retrieval built from its own direction. Query-only baselines predict no difference, since they hand both readers the same passages. We will also verify that the two directions actually flag different spans, because if they do not, the test cannot discriminate.
The second check is the dissociation set described above.
The third addresses TheoremQA's definition-versus-application result. We separate two quantities: whether gap-aware retrieval places the needed theorem in context more often, measured as theorem recall, and whether accuracy follows. If recall rises but accuracy does not, we will say that retrieval has done its part and that the remaining bottleneck is applying the theorem. That outcome would support TheoremQA's finding rather than contradict our method, and it points toward combining retrieval with reasoning-neuron steering of the kind in Neuron Activation Differential Analysis as follow-up work.
We report the reader's extra forward pass as added latency per query.
References
- Steering Llama 2 via Contrastive Activation Addition
- Latent Fact-Checking: Detecting Misinformation through Activation Engineering
- Contextualized Query Embeddings for Conversational Search
- Domain-specific Question Answering with Hybrid Search
- Augmenting Black-box LLMs with Medical Textbooks for Biomedical Question Answering
- Sparse, Dense, and Attentional Representations for Text Retrieval
- BEIR: A Heterogeneous Benchmark for Zero-shot Evaluation of Information Retrieval Models
- Enhancing Chain-of-Thought Reasoning via Neuron Activation Differential Analysis
- Semantics-Adaptive Activation Intervention for LLMs via Dynamic Steering Vectors
- Steering Large Language Model Activations in Sparse Spaces
- TheoremQA: A Theorem-driven Question Answering Dataset