Learning When to Trust a Dictionary: Two-Sided Gating for Few-Shot Biomedical Tagging

Specialized fields such as medicine and chemistry have large curated term lists, like MeSH or DrugBank, but very few sentences where experts have marked which spans are diseases or drugs. The usual way to use such a list is to turn it into automatic labels, often called silver annotations, and train a tagger on them. This works well when the list is complete. When it is not, the tagger learns that every term missing from the list is ordinary background text. That is the same error that already dominates few-shot entity tagging: models confuse new entity types with the "Outside" class, the label for tokens that are not part of any entity.

We propose a different use of the dictionary. It becomes an input the tagger reads at test time, not a source of training labels. A small gate decides whether to trust each dictionary match, using the context on both sides of it: the left context judges whether a span should start there, and the right context judges whether it should end there. The gate never sees word identities, only match evidence and context states. It should therefore learn a domain-general skill, "when is a dictionary hit a real entity boundary," that can be trained on one biomedical dataset and moved to another with only a handful of labeled sentences.

Core Claim

In the few-shot regime, a domain dictionary helps more as a gated test-time feature than as a silver-label training signal. The gap should widen as dictionary coverage falls, because silver labels teach the model that uncovered entities are "Outside," while a gated feature simply abstains when it has nothing to say. We also claim two narrower things. The gate works better when it is split by direction, with a left-context gate for span entry and a right-context gate for span exit, than when it is a single gate over pooled context. And because the gate operates on match evidence, not vocabulary, it transfers across entity types and dictionaries.

Relation to Prior Work

The work that motivates this proposal found that external features help only when filtered, and that naive fusion can hurt. A Graph Attention Model for Dictionary-Guided Named Entity Recognition turns MeSH/CTD dictionaries into a word-mention graph, uses graph attention to suppress false matches, and feeds the result into a bidirectional LSTM with a conditional random field (CRF) decoder. It reaches 89.95 F1 on BC5CDR-Disease against 86.56 for BioBERT. Its dictionary enters training through silver annotations on full-size splits, and it never evaluates few-shot targets or incomplete dictionaries. Those are exactly the conditions we study. Better Feature Integration for Named Entity Recognition supplies the mechanism we reuse. Its Syn-LSTM adds a fourth "structure gate" inside the LSTM cell to filter noisy dependency-tree inputs, gaining 4.64 F1 over a stacked graph baseline on Catalan. It gates only syntax, uses one gate per cell, and is tested on resource-rich corpora. We gate dictionary evidence, split the gate by direction, and test with a few dozen labeled sentences.

Two further results constrain the design. Adverse Drug Effect and Personalized Health Mentions, CLaC at SMM4H 2019 found that adding lexicon features to Word2Vec embeddings lowered F1 while adding them to GloVe raised it. The benefit of a symbolic feature therefore depends on the embedding it is fused with, and an honest study must vary the embedding. Efficient Biomedical Entity Linking reports that naively added sentence context hurt candidate disambiguation. We read this as a warning that context must decide whether evidence is admitted, rather than being mixed into it.

On the few-shot side, SwitchPrompt gates domain keywords into a frozen language model's soft prompts, the small set of trainable vectors placed in front of the input, and beats ClinicalBERT with 2 to 64 examples per class. It shows that small gates over domain signals are learnable from very few examples, but it handles only sentence classification. Lexicon Learning for Few Shot Sequence Modeling shows that separating word meaning from structure makes extreme few-shot sequence learning possible. It does this with discrete lexicons in unidirectional decoders on synthetic tasks. Our gate plays the analogous role for tagging: the dictionary carries meaning, and the network learns only the structure of trust. Few-NERD documents the Outside-class collapse. Its best 5-way 1–2-shot INTRA model reaches only 23.95 F1.

Research Program

The tagger is a bidirectional LSTM over frozen token embeddings, followed by a CRF. At each position $t$ the dictionary contributes a small evidence vector $d_t$. It encodes whether a longest match covers $t$, the position of $t$ within that match (begin, inside, end, single), the matched entity type, and match quality (exact versus normalized). Following the direction-split idea, the forward LSTM admits evidence through an entry gate and the backward LSTM through an exit gate:

$$a_t = \sigma(W_a[h^{f}_{t-1}; d_t]), \qquad b_t = \sigma(W_b[h^{b}_{t+1}; d_t]), \qquad e_t = (a_t \odot b_t)\, \phi(d_t).$$

Here $h^{f}_{t-1}$ is the forward state summarizing the left context, and $h^{b}_{t+1}$ is the backward state summarizing the right context. $\sigma$ is the logistic function and $\phi$ is a learned projection of the evidence. The gated evidence $e_t$ enters the CRF emission scores alongside the two LSTM states. Because the product $a_t \odot b_t$ admits a match only when both sides agree, the gate is designed to reject dictionary hits whose boundaries the surrounding text contradicts. We deliberately keep word embeddings out of the gate inputs. As a result, $W_a$, $W_b$, and $\phi$ total a few thousand parameters and carry no vocabulary.

Training runs in two stages. The gate and the CRF transition matrix are first trained on a source biomedical dataset paired with its own dictionary. Then the whole tagger is adapted to a target entity type and a different dictionary using $K$ labeled sentences, with the gate either frozen or lightly tuned. Embeddings are treated as a controlled variable, not a contribution. We run general GloVe, biomedical Word2Vec, and frozen Bioformer contextual vectors, following Exploring the effects of drug, disease, and protein dependencies on biomedical named entity recognition. This tests whether the gate removes the embedding sensitivity seen in the CLaC result. The analysis measures gate activations on true versus false matches, and F1 split by whether the gold entity is covered by the dictionary.

Baselines

The naive reference points are exact dictionary string matching used as a tagger, and the same bidirectional LSTM-CRF with no dictionary input trained on the $K$ gold sentences. Together they bound what the dictionary and the few labels each contribute alone.

The strongest competitor on this question is the dictionary-guided graph attention BiLSTM-CRF of Lou et al.. It is trained on the dictionary's silver labels and then fine-tuned on the same $K$ gold sentences. It embodies the "dictionary as training signal" view we are arguing against, and it already filters false matches. The published full-data figure is 89.95 F1 on BC5CDR-Disease. For few-shot splits of NCBI-disease or BC5CDR we found no reported result on Lacuna, so we will rerun it ourselves.

The second strong competitor is a fine-tuned domain transformer, Bioformer. It is run both on $K$ gold sentences alone and with dictionary indicators concatenated to its inputs. Its full-data NCBI-disease figure is 89.36 F1, rising to 91.61 when MKGAT adds knowledge-graph features, per Han et al.. We also run the concatenation design ("TNN ⊕ PLM" plus lexicon features) from YATO.

Two ablations isolate our ingredients. One replaces the two directional gates with a single Syn-LSTM-style gate conditioned on $[h^f_t; h^b_t]$. The other removes source-domain gate pretraining.

Every system sees identical gold sentences, the same five random $K$-shot draws, the same dictionary, and the same hyperparameter search budget, tuned on a held-out $K$-sized development split. We count the proposal as beating a competitor only if it wins in mean F1 across draws by more than the across-draw standard deviation. The win must hold at $K \le 50$ sentences and at reduced dictionary coverage. A tie at full coverage with a win at partial coverage would still support the core claim.

Why not just…?

Why not just train on silver labels from the dictionary and fine-tune on the few gold sentences? This is the real threat. With a complete dictionary it may match or beat us, since Lou et al. show silver training plus filtering is strong at full scale. Our argument is specific to incomplete coverage. Silver labels mark every uncovered entity as "Outside," which should drive recall on those entities toward zero. The coverage-ablation experiment below settles this directly. If silver training holds up on uncovered entities as coverage drops, our core claim is wrong.

Why not just fine-tune BioBERT or Bioformer on the few gold sentences? Few-NERD's 23.95 F1 at 1–2 shots shows that large taggers without external knowledge collapse in this regime. SwitchPrompt found that gated domain keywords beat a domain-pretrained ClinicalBERT with few examples. Still, a frozen-encoder biomedical transformer is a strong prior, so we include it both as a competitor and as an embedding inside our model. If it wins without any dictionary at every $K$, the dictionary adds nothing and we would say so.

Why not just concatenate dictionary indicators to the inputs? Syn-LSTM's gain over stacking, and CLaC's finding that features hurt Word2Vec, suggest ungated fusion is fragile. That evidence comes from full-data or classification settings, though. With few labels, a plain concatenation has fewer parameters than a gate and might simply work. The concatenation baseline, run across all three embeddings, tests exactly this. We expect it to show high variance across embeddings, where the gated model should not.

Decisive Experiments

The main testbed is NCBI-disease and BC5CDR-Disease with MeSH/CTD as in Lou et al. The source domain for gate pretraining is BC5CDR-Chem with a chemical dictionary, and SemEval 2013 DDI drug mentions with DrugBank/ChEBI serve as a second target. Each target is subsampled to $K \in \{5, 20, 50, 200\}$ gold sentences, and we report entity-level F1.

The first decisive check is the coverage ablation. We randomly delete 0, 25, 50, and 75 percent of dictionary entries, making sure deleted entries include gold test entities. We then report F1 separately on covered and uncovered test entities. The prediction is that on uncovered entities, silver training degrades well below the no-dictionary tagger, while the gated model stays at or above it.

The second check is gate transfer. A gate pretrained on chemicals and frozen should, at $K=5$ and $K=20$ on diseases, beat a gate trained from scratch. If it does not, "trust" is not domain-general.

The third check is the direction split. The two-gate model should beat the single pooled gate mainly on boundary errors, measured as partial-overlap matches, not on type errors.

The fourth check repeats all comparisons across GloVe, biomedical Word2Vec, and Bioformer. The spread of the dictionary's benefit across embeddings should be smaller for the gated model than for concatenation. A positive result on the first check with failures on the others would still establish the central point, that dictionaries should be read, not copied into labels, when labels are scarce.