NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Letting the Memory Choose the Features: Query-by-Query Feature Selection for Nearest-Neighbor Word Sense Disambiguation

A nearest-neighbor classifier answers a question by finding the stored training examples most similar to it and copying their labels. It keeps every example, including rare and irregular ones, which is why memory-based learning has long been used for language, where much of the difficulty sits in exceptions. Its weak point is the notion of "similar." Standard memory-based learners weight each feature once, globally, for all queries. Work on word sense disambiguation (deciding which dictionary meaning of an ambiguous word is intended in a sentence) has shown that which contextual cues matter depends on the word. It very plausibly also depends on the individual sentence. One occurrence of bank is settled by a topical word two clauses away, while another is settled by its grammatical object. A single weighting scheme, whether global or per word, has to average over these cases.

We propose that the memory itself should decide, for each query, which features to look at. The method starts from a query-independent choice. It then reveals the query's features one at a time. At each step it picks the next feature by measuring, among the stored examples that agree with the query on everything revealed so far, which remaining feature best separates their senses. Selection stops when those neighbors agree. Each prediction therefore comes with a short, faithful list of the cues that decided it. Because the selection policy is estimated from labeled memory rather than trained as a separate network, it needs no per-word search and no extra training data. By construction it also cannot leak information from features it never revealed, which is the failure mode that leakage-free local feature selection was designed to rule out.

Core Claim

The claim is that per-word feature optimization for nearest-neighbor learners has so far given small gains because it adapts at the wrong granularity and selects features using the wrong signal. Adapting per query, with relevance estimated from the query's own neighborhood, should give its largest gains on the instances memory-based learning exists to handle: minority senses and idiosyncratic contexts. It should also show a smaller gap between training and test accuracy than wrapper-based per-word selection.

The motivating evidence is weak but consistent. Instance Based Learning with Automatic Feature Selection Applied to Word Sense Disambiguation paired the Tilburg memory-based learner (TiMBL) with greedy forward selection run separately for each target word on SENSEVAL-2. It found large effects on individual words: a 20% precision boost for local, and 78.57% to 85.71% for colorless. Averaged over all words, however, the per-word model beat the best global feature set only 59.8% to 59.6%. TALP system for the English lexical sample task ran forward and backward per-word selection with support vector machines and reached about 76% on training data but 71.6% fine-grained on SENSEVAL-3 test. That gap is a sign that the wrapper overfits the small per-word samples.

UBC-ALM: Combining k-NN with SVD for WSD chose combinations of nearest-neighbor feature subspaces word by word. It did well on the SemEval-2007 lexical sample (86.9%) but scored 54.4% on all-words text. On a different all-words benchmark (SENSEVAL-3), the global memory-based SenseLearner, which does no per-word tuning, reached 64.6%. The two all-words numbers come from different benchmarks, so they are only suggestive. Together these papers show that feature relevance is idiosyncratic. The linguistic studies make the same point from the other side. Aligning Features with Sense Distinction Dimensions found that semantic-role features help verbs whose senses split on the patient role and hurt auxiliaries. Tailored Feature Extraction ... Corpus Pattern Analysis found that verb-specific features beat universal ones. What none of this work does is condition the choice on the sentence at hand.

The method's structure comes from Local Feature Selection without Label or Feature Leakage. That paper (SUWR) showed that jointly trained per-instance selectors such as L2X, INVASE, REAL-X and TabNet encode label information in the mask itself. It fixed this with sequential unmasking, a blind first choice, and no reversal of earlier choices, trained with a policy-gradient method (REINFORCE, which updates the selector from sampled choices and their rewards). We keep SUWR's constraints but replace its learned policy with a nonparametric estimate read off the exemplar memory. This matters because SUWR was only shown on parametric predictors and synthetic or image data. A learned policy per ambiguous word, trained from a few hundred examples, is exactly the data-sparse setting where the per-word wrappers above already overfit.

Research Program

Let $q$ be a query occurrence of target word $w$, with $D$ candidate feature slots. The slots follow Mihalcea's inventory at the level of individual slots: current word and part of speech, each collocation position, nearest verbs and nouns, adjectives, and sense-specific keywords. Let $S_t$ be the set of slots revealed after $t$ steps. Let $M_t$ be the stored training examples of $w$ that match $q$ on $S_t$ under the overlap metric, relaxed to the nearest examples if exact matches are too few.

At step 0 the method reveals the slot with the highest word-level information gain. This is the blind start: the first choice uses no value of $q$. At step $t$ it reveals the unrevealed slot $j$ with the largest shrunk local gain,

$$ g_t(j) = \frac{|M_t|\,\mathrm{IG}_{M_t}(j) + \lambda\,\mathrm{IG}_{w}(j)}{|M_t| + \lambda}, $$

where $\mathrm{IG}_{M_t}(j)$ is the information gain of slot $j$ about the sense labels within the current neighborhood, $\mathrm{IG}_w(j)$ is the same quantity over all training examples of $w$, and $\lambda$ controls how strongly small neighborhoods are pulled toward the word-level estimate. The shrinkage exists because local gain from a handful of neighbors is noisy. When $\lambda\to\infty$ the method reduces to a fixed per-word ordering, which is close to Mihalcea's setting. Selection stops when the neighbors' sense distribution falls below an entropy threshold or the best remaining gain falls below a small margin. The prediction is then a distance-weighted vote over the $k$ nearest examples, computed on the revealed slots only.

Only $\lambda$, the threshold, and $k$ are tuned, by cross-validation pooled across words rather than per word. This choice is deliberate, since per-word search is the overfitting source we are trying to remove. Every choice depends only on already-revealed query values plus training labels, never on the query's own label, so the returned slot list is a faithful explanation in SUWR's sense.

The program has three parts. The first part tests accuracy on the standard lexical sample tasks. The second part is a leakage and faithfulness audit that transfers SUWR's synthetic tests to the nearest-neighbor setting. The third part is an analysis of where the gains fall: by part of speech, by sense frequency, and by how many slots each query needs, compared with the per-part-of-speech averages Mihalcea reports (3.7 for nouns, 4.5 for verbs, 4.4 for adjectives, fixed per word).

A secondary regime replaces symbolic slots with blocks of dimensions from a frozen contextual encoder. This asks whether the same neighborhood-driven selection helps dense retrieval of the kind used in Generalization through Memorization: Nearest Neighbor Language Models, which uses unweighted squared L2 distance over all hidden dimensions. We treat this regime as exploratory and not as the main claim.

Baselines

The naive reference points are the most-frequent-sense baseline and TiMBL with global information-gain weighting over all slots. The file reports most-frequent-sense at 55.2% fine-grained and 64.5% coarse-grained on SENSEVAL-3 lexical sample, in The Senseval-3 English lexical sample task. Both baselines are run on identical feature extraction.

The closest method is Mihalcea's per-word greedy forward selection with TiMBL. It reports 63.8% fine-grained and 71.2% coarse-grained on SENSEVAL-2. We reimplement it on our slot inventory with its 10-fold wrapper and give it the same total compute as our tuning. Beating it means higher fine-grained accuracy on SENSEVAL-2 and SENSEVAL-3 with paired significance tests over test instances. It also means a smaller train–test gap.

The strongest competitor is an eager linear support vector machine over all slots, with no selection. An Empirical Evaluation of Knowledge Sources and Learning Algorithms for WSD reports this reaching 65.4% on SENSEVAL-2 and 79.2% on SENSEVAL-1, above the official competition bests. On SENSEVAL-3 the reference points are TALP's per-word-tuned SVM at 71.6% fine-grained and the top official system, htsa3, at 72.9% fine-grained and 79.3% coarse-grained. We train the SVM on our exact features with a pooled regularization search of the same size as ours.

Matching the SVM on overall accuracy while clearly beating it on minority-sense instances would support the claim that memory with per-query selection keeps exceptions that the eager model smooths away. Falling short of the SVM overall while also failing to win on minority senses would refute the claim. For SemEval-2007 Task 17 the reference is UBC-ALM's reported 86.9%. The 89.5% figure reported for its word-by-word optimization is cited as reported, because the file does not make clear whether it was tuned on test data.

Three ablations isolate the key ingredient. The first is SUWR itself: a REINFORCE-trained policy per word that feeds the same nearest-neighbor predictor. This tests whether estimating the policy from memory beats learning it. The second is a non-sequential "two-pass" variant: retrieve neighbors with all slots, compute local gain, then re-weight and re-retrieve. This version can leak information from all slots into the weighting. The third fixes $\lambda\to\infty$, which gives a per-word fixed ordering and tests whether per-query conditioning, rather than the stopping rule, is what helps.

Why not just…?

Why not just train one linear SVM on all features? This is the real threat. The SVM result of 65.4% on SENSEVAL-2 already beats the per-word memory-based system's 63.8%. The prior evidence therefore favors eager learning on overall accuracy, and we do not assume otherwise. Our claim is narrower and testable. It is that the gains appear on instances whose sense is the minority sense for their lemma and on words whose relevant cue varies across sentences. We report accuracy stratified by sense frequency. If the SVM matches us on minority senses too, the per-query idea adds nothing to accuracy, and its remaining value is the faithful per-prediction explanation, which the SVM does not give.

Why not just select features per word, as before? The file's own numbers argue against expecting much: a 0.2-point average gain in Mihalcea's study, and a drop from about 76% on training data to 71.6% on test data for TALP. UBC-ALM's word-by-word system also scored only 54.4% on SemEval-2007 all-words. The $\lambda\to\infty$ ablation and the reimplemented wrapper let us measure directly whether per-query conditioning adds accuracy beyond a per-word ordering, and whether dropping the wrapper narrows the train–test gap.

Why not just re-weight features by local information gain in a second retrieval pass? It is simpler and may be as accurate. If it is, we will say so. It does not keep the guarantee that the explanation reflects only the inspected cues, because the first pass already used every slot. We run it as an ablation and apply the leakage audit below to it. The expected result is equal or slightly higher accuracy, together with measurable feature leakage. The case for the sequential version then rests on faithfulness, not accuracy.

Why not just train SUWR's learned selector? With a few hundred labeled examples per word, a policy-gradient selector is likely to be starved of data, and a single selector shared across words throws away the word-specific structure that the linguistic studies document. The direct comparison, run with the same predictor and data, settles this question.

Proposed Experiments

The main experiments use SENSEVAL-2 and SENSEVAL-3 English lexical sample with their official splits, reporting fine-grained and coarse-grained accuracy, plus the SemEval-2007 Task 17 lexical sample. The analyses include per-part-of-speech accuracy, accuracy on minority-sense test instances, the train–test gap, the distribution of revealed slots per query, and query latency relative to plain TiMBL.

The leakage audit reproduces SUWR's logic in two ways. First, on synthetic lexical tasks built so that the best leakage-free accuracy for a given number of revealed features is computable, we check whether any method exceeds that ceiling; exceeding it is the signature of leakage. Second, on real data we permute the values of unrevealed slots across test instances and measure whether the selected slot lists or predictions change. For the sequential method they cannot change, by construction. The size of the change in the two-pass variant gives the extent of its leakage.

A secondary test uses SemCor as memory and evaluates on SENSEVAL-3 all-words, against SenseLearner's reported 64.6% and the 60.9% most-frequent-sense baseline. This tests the prediction that a method with no per-word training loop avoids the all-words collapse seen for UBC-ALM.

The decisive checks come down to three outcomes. The method should beat the reimplemented Mihalcea wrapper at equal compute. It should beat the linear SVM on minority-sense accuracy while staying within a point overall. And it should stay at or below the synthetic leakage-free ceiling while the two-pass variant rises above it. If the first two checks fail, the claim that per-query selection helps memory-based learning is wrong for this task. If only the third holds, the contribution reduces to faithful explanation for nearest-neighbor classifiers, and we would present it as that.