Background-Subtracted Term Proximity for Ranking Long Documents

Search engines often reward a document when the words of a query appear close together, on the reasonable theory that "neutrino" three words from "mass" signals more than the two words sitting in different chapters. In a long document, though, frequent terms land near each other by chance. A 50,000-word regulatory filing that mentions both terms two hundred times will contain many tight pairings that mean nothing. Particle physicists face the same problem when they look for two detector signals that occur close together in space and time. They do not treat every close pair as signal. They predict how many close pairs random, unrelated hits would produce, and they count only the excess. This proposal brings that accounting into text retrieval. The proximity reward becomes the number of close query-term pairs a document contains beyond what its own term counts and length predict by chance.

The opportunity is that one change may fix two separate known failures of proximity scoring. Proximity helps most on long documents but is fragile there, because span-style measures are sensitive to document length and term frequency. Proximity also hurts many broad queries, which is why prior work trained a separate classifier to decide when to switch it on. A chance-corrected score should shrink by itself exactly where close pairs are expected anyway: long documents and frequent, generic terms. It would then do the job of that learned switch without one.

Core Claim

For a query-term pair $(a,b)$ in document $d$, let $O_{ab}(w)$ be the observed number of occurrence pairs within $w$ tokens of each other. Let $n_a, n_b$ be the in-document counts of the two terms and $L$ the document length in tokens. If occurrences were placed at random, the expected number of chance pairs is approximately

$$E_{ab}(w) \approx \frac{2w\, n_a n_b}{L},$$

which follows from each of the $n_a n_b$ pairs independently falling within a window covering a fraction $2w/L$ of the document, ignoring edge effects. We score proximity by the significance of the excess, $S_{ab} = g\big((O_{ab}-E_{ab})/\sqrt{E_{ab}+c}\big)$. Here $g$ is a bounded, monotone transform, and $c$ is a small constant that keeps short documents from producing exploding values.

The analytic $E_{ab}$ assumes uniform placement. Real terms cluster on their own, for example when a term repeats inside a single section. For that reason we also estimate the expectation empirically by cyclically shifting one term's positions relative to the other within the same document and recounting. This keeps each term's own clustering intact while breaking their joint alignment, much as coincidence experiments measure chance pairs from deliberately mismatched windows.

The claim is not that proximity matters; that is established. The claim is that the correct normalization of proximity is a per-document chance expectation. This single correction should make proximity gains larger and more consistent on long-document collections. It should also reproduce the benefit of selective, per-query proximity gating without training a gate.

Grounding in Prior Work

The motivating evidence comes from information retrieval. An exploration of proximity measures in information retrieval defined span-based and pairwise-distance proximity measures. It stated two axioms: closer terms should score higher, and the reward for closeness should fall off convexly with distance. It showed that minimum pairwise distance (MinDist) beats span measures because spans are too sensitive to document length and term frequency. It also found the largest gains on the verbose Federal Register collection. We read both findings as symptoms of uncorrected chance co-occurrence. MinDist is less exposed to the problem only because a single minimum ignores most pairs, not because it accounts for chance. We keep its axioms as constraints our score must satisfy, and we replace its ad hoc robustness with an explicit chance model.

Selective Term Proximity Scoring Via BP-ANN showed that applying proximity to more than about 40% of queries makes Mean Average Precision (MAP) plateau or fall. It addressed this with a neural classifier that switches proximity on or off per query, using query statistics. That paper constrains our design: any proposal must explain the negative transfer on broad queries. Our account is that broad queries have frequent terms, so $E_{ab}$ is large and the excess is near zero. The gating behavior should then emerge from the score rather than from a separate model.

Adapting Learned Sparse Retrieval for Long Documents supplies the strongest modern host. Its ExactSDM rewards exact query-term pairs inside a small window (about 8 tokens) on top of learned sparse retrieval. It found that soft proximity over neural expansion terms added nothing beyond that. We therefore operate on exact original query terms and drop expanded terms. CWI and TU Delft Notebook TREC 2013 adds a practical constraint: stop words must stay in the index, because removing them distorts token distances. That distortion matters even more when $L$ enters the chance model directly.

The physics side supplies the method rather than the data. Independent measurement of the neutrino mixing angle θ13 via neutron capture on hydrogen at Daya Bay required the two halves of a candidate event to lie within 50 cm of each other. That cut rejected 98% of accidental coincidences. It is the direct analogue of a proximity window, but a cut alone never removes all chance pairs. The surviving accidental rate still has to be predicted and subtracted, and our score imports that second step. Model-independent ν̄e short-baseline oscillations from reactor spectral ratios shows the companion idea: comparing observed and expected quantities as a ratio cancels poorly known normalizations, in that case reactor flux. Here the nuisances that cancel are document length and term frequency.

The closest cross-field work, Proximity-Based Evidence Retrieval for Uncertainty-Aware Neural Networks, uses nearest-neighbor proximity in embedding space to calibrate classifier uncertainty on image data. It neither scores text positions nor models chance co-occurrence, so it is related in vocabulary but not in mechanism.

Research Program

The first step is analytic. We will check which choices of $g$ and $c$ satisfy the proximity heuristic and convexity criterion of Tao and Zhai. We will also characterize how the score behaves in three limits: very short documents, single-occurrence terms, and queries with more than two terms. For multi-term queries we aggregate pairwise excesses, either by maximum or by an inverse-variance weighted sum. We will derive the bias of the analytic expectation when terms cluster on their own, which tells us when the cyclic-shift estimate is needed.

The second step is engineering. Both estimates use only the positional postings that any proximity method already loads. The analytic version adds constant work per pair. The cyclic-shift version costs a small, fixed number of extra merge passes, and we will measure its throughput against the original MinDist and the BM25TP-style scoring that Yang et al. timed.

The third step is integration. The excess score is added as a component to BM25, to the query-likelihood language model, and to ExactSDM's proximity term inside learned sparse retrieval. In each case it replaces the raw window count rather than being stacked on top of it.

Baselines

The naive reference point is bag-of-words BM25 with tuned parameters and no proximity. Every proximity method must clear it, and it fixes the scale of possible gains on each collection.

The classical proximity baseline is BM25 and KL-divergence retrieval plus the MinDist component with its log-exponential transform, as in An exploration of proximity measures in information retrieval. It is run on the same five collections (AP, DOE, FR, TREC-8, WT2g), with $\alpha$ and the BM25 parameters tuned by the same cross-validation grid we give our own method. That paper reports significant MAP gains in 8 of 10 settings, but no absolute MAP values were found on Lacuna. We will therefore reproduce it ourselves, and beating it means a statistically significant MAP gain, by paired test across topics, on at least the long-document collections.

The strongest existing method on modern benchmarks is ExactSDM over learned sparse retrieval from Adapting Learned Sparse Retrieval for Long Documents. It reports nDCG@10 gains of 3.9% to 5.8% on TREC Robust04 (zero-shot) and MRR@10 gains of 1.0% to 2.0% on MS MARCO Document, both over Score-max aggregation. We keep its encoder, segmentation and window size fixed and change only the proximity potential from raw window counts to chance-corrected excess. Beating it means a gain over ExactSDM itself, not merely over Score-max, on Robust04 nDCG@10, without losing MS MARCO Document MRR@10.

The selective-gating baseline is the BP-ANN switch of Selective Term Proximity Scoring Via BP-ANN on GOV2 (MQ2007/MQ2008). That paper reports a move from 0.4791 to 0.4855 for 3-term queries when switching from always-on to selective proximity; the file labels this result both as MRR and as MAP. It also reports throughput rising from 352.71 to 424.49 queries per second. We retrain the gate on our splits. Matching or exceeding the gated result with our ungated score, at comparable throughput, counts as success.

The key ablation replaces the per-document chance expectation with a collection-level background, the kind of smoothing that window features in sequential dependence models already receive. A second ablation keeps the expectation but drops the variance normalization. These isolate whether the gain comes specifically from conditioning on each document's own term counts and length.

Why not just…?

Why not just tune the global proximity weight? Tao and Zhai found one $\alpha$ works across collections, so a reviewer may argue no new normalization is needed. But a global weight cannot tell a broad query from a focused one. Yang et al. show that always-on proximity degrades a large share of queries regardless of how well it is tuned on average. Our per-query analysis directly tests whether the chance correction recovers what a global weight cannot.

Why not just use sequential dependence model window features, which are already smoothed against collection statistics? This is the most serious threat, because those features already subtract a kind of background. The difference is that collection smoothing asks how common the pair is across the corpus. It ignores how many chance pairs this document should contain given its own length and term counts. The collection-background ablation settles the question. If it matches our per-document version, the idea reduces to existing practice and we will say so.

Why not let a learning-to-rank model learn the interaction from raw window counts, term frequency and length? A gradient-boosted ranker such as the LambdaMART setup in RUCIR at NTCIR-13 WWW Task could in principle learn the product $n_a n_b / L$. We test this by training LambdaMART on GOV2 with the raw features, with and without our excess feature added. If the explicit feature adds nothing given enough training queries, the contribution narrows to the unsupervised and zero-shot settings, where the closed form still matters, such as Robust04.

Why not just rerank with a cross-encoder, which sees all positions through attention? Cross-encoders truncate long documents and are expensive. Serverless BM25 Search and BERT Reranking reports 11.21 s average reranking latency on Lambda for MS MARCO passages. Our score is a first-stage or cheap second-stage signal, and we treat a cross-encoder as a downstream consumer rather than a competitor. We will report whether better first-stage candidates improve its final ranking.

Proposed Experiments

The first experiment is a set of controlled shuffles that runs before any ranking evaluation. In real documents from FR and Robust04, we randomly permute the positions of one query term while keeping its count. This destroys any genuine association while keeping chance pairings. Under the shuffle, our score should average near zero across documents. MinDist and raw window counts should still favor long, high-frequency documents. If our score does not vanish under shuffling, the chance model is wrong and the rest of the program stops.

Ranking evaluation then covers the five Tao–Zhai collections (MAP), Robust04 (nDCG@10, zero-shot), MS MARCO Document (MRR@10) and GOV2 (MAP and queries per second). We use paired significance tests over topics, and results are broken down by document length and by a measure of query breadth: the summed in-document frequency of the query terms. The prediction that would make the idea valuable is concrete. Gains over MinDist should concentrate in the longest length bins and on FR. In addition, the fraction of queries for which our proximity component changes the top-10 should fall near the roughly 40% boundary Yang et al. found by training a gate. Agreement with that boundary would indicate that the gate was learning chance co-occurrence.

Finally, we compare the analytic and cyclic-shift expectations stratified by how strongly terms cluster on their own. We expect the shifted estimate to matter mainly for terms concentrated in single sections, and we will report its throughput cost so that practitioners can choose between the two.