Align the Context, Harden the Types: Adversarial Transfer for Fine-Grained Low-Resource NER

Named entity recognition (NER) means finding names in text and labeling each one with a type such as person, place, or disease. When a model trained on news is moved to a new domain, like music or AI papers, with only a hundred labeled sentences, it fails in a specific way. It usually finds the right spans. What it gets wrong is the type: it confuses a fine-grained target category with the broad category it learned in the source domain. The CrossNER benchmark reports that in the music domain, "84.81% of 'person' entities were misclassified as 'artist'" even by its best model (CrossNER). The standard adversarial transfer recipe makes source and target features indistinguishable to a domain classifier. That recipe is built to erase exactly the distinction this failure depends on. The domain adaptation literature calls this the invariance–discriminability trade-off: forcing domains to overlap tends to merge nearby classes (Chen et al., Lu et al.).

We propose to split the two adversarial tools by token role. Domain-adversarial alignment is applied only to background tokens, the non-entity context words whose style differs between domains but whose meaning should not. Adversarial perturbation, meaning small worst-case nudges to input embeddings during training, is applied only to target entity tokens. Each nudge is aimed at the specific wrong type the model is most tempted to predict, and the model is trained to resist it. Put plainly, we make the context domain-invariant and make the entity types harder to confuse. The question is whether this beats both uniform adversarial training and the strongest non-adversarial alternatives in the 10 to 200 labeled-sentence regime.

Core Claim

In cross-domain NER on pretrained Transformers, the invariance pressure of a domain adversary is harmless, and probably helpful, on context tokens. On entity tokens it is harmful, because it pulls target subtypes onto source parent types. A perturbation that targets each entity's most confusable type restores the margin that alignment would otherwise erode.

We expect a measurable reduction in parent–child type confusion, such as person versus artist, writer, politician, or scientist in CrossNER, together with an F1 gain over the same encoder trained with plain fine-tuning or uniform adversarial training. If uniform perturbation or a simple margin loss on the output scores does equally well, the claim is wrong.

How This Relates to Prior Work

Three prior systems combine pieces of this idea, and each makes a different choice about where adversarial pressure goes.

DATNet is the closest ancestor. It pairs a resource-adversarial domain discriminator with gradient-based perturbations of word and character embeddings, on a Bi-LSTM-CNN-CRF. Its domain invariance covers all shared features, and its perturbations are uniform across every token, entity or not. We reuse its two ingredients but assign each to a different token role, and we move to a pretrained encoder, which DATNet itself names as future work.

The Entity-Aware Adversarial Domain Adaptation Network makes the opposite choice from ours. It observes "false alignment" of background tokens and uses attention to focus the domain discriminator on entity spans. That paper motivates our proposal because it shows token role matters for alignment. It also appears to contradict our proposal, because it concludes that alignment should target entities. We think the conflict comes from its setting. On CoNLL→Twitter the two domains share the same four entity types, so aligning entities is safe. On CrossNER the label sets differ, and aligning entities is exactly what produces the subcategory trap. Our experiments run both directions on both settings to settle this.

PDALN aligns sentence-level and word-level distributions with maximum mean discrepancy, a non-adversarial statistical distance, and adds progressive distillation on BERT. It uses no worst-case perturbations. It also reports trouble with long entity chunks and with over-labeling.

On the perturbation side, FreeLB supplies the method. It shows that multi-step embedding perturbation acts as a regularizer that improves clean accuracy, raising BERT-base on GLUE "from 78.3 to 79.4". FreeLB maximizes the total loss over all tokens without aiming at a particular wrong answer, and it was never tested on sequence labeling or domain transfer. Our targeted, entity-only variant differs on both counts.

The object-detection work Det-AdvProp is a constraint more than a method. It shows that adversarial training across two prediction heads needs separate handling, which it provides through per-head attacks and separate normalization for clean and perturbed inputs. That warns us against letting one perturbation serve both span boundaries and types.

Research Program

The model is a pretrained encoder (BERT-base, to match CrossNER; RoBERTa-base as a second check) with a token classifier. It is trained on labeled source data (CoNLL-2003), a small labeled target set, and unlabeled target-domain text. Training combines three losses.

The first is the ordinary tagging loss on labeled data from both domains.

The second is a context-only domain adversary. A small discriminator sees token representations and tries to tell source from target. A gradient reversal layer passes features through unchanged on the forward pass and flips the sign of their gradients on the backward pass, so the encoder learns to fool the discriminator. On source tokens and labeled target tokens, the discriminator sees only tokens with gold label O ("outside any entity"). On unlabeled target text, it sees only tokens the current model tags as O with confidence above a threshold. Entity tokens never reach the discriminator.

The third is a confusion-directed perturbation, applied to each labeled target entity token $i$ with gold type $t$. Let $c$ be the wrong type with the highest score for that token. The perturbation is

$$\delta_i^* = \arg\max_{\|\delta\| \le \epsilon} \big[ z_c(x_i + \delta) - z_t(x_i + \delta) \big],$$

where $x_i$ is the token's input embedding, $z_k$ is the model's output score for type $k$, and $\epsilon$ bounds the perturbation size. We approximate $\delta_i^*$ with $K$ steps of projected gradient ascent in FreeLB style. We then add the tagging loss on the perturbed input.

The perturbation acts only on type decisions. Following the Det-AdvProp lesson, we do not let it disturb span decisions. We factor the tag into a span part (B/I/O) and a type part, and perturb against the type part only.

Beyond F1, the analysis measures three things. The first is a type-confusion rate on parent–child pairs in each CrossNER domain. The second is how well a linear probe separates fine-grained types in the representation space. The third is the singular-value spectrum of entity-token features, the collapse diagnostic used by Chen et al.. These make the mechanism visible rather than leaving it inferred from F1.

Baselines

Naive reference. The encoder is fine-tuned on CoNLL-2003 and then on the target samples, with no alignment and no perturbation. Every gain is reported relative to this model.

DAPT with span masking. This is the strongest fine-tuned competitor, the domain-adaptive pretraining with span-level masking from CrossNER. It continues self-supervised training on target-domain text and reports "average F1 score improvement of 2.16%" across the five domains. The file does not provide absolute per-domain F1 values for it (no reported result found on Lacuna for per-domain absolute CrossNER F1). We therefore rerun it with the same encoder, the same unlabeled corpus, and the same target splits.

Our method is also applied on top of the DAPT checkpoint. Beating DAPT means a gain that exceeds the seed-to-seed spread over five seeds in at least four of five domains, when both systems start from the same DAPT checkpoint. We use that stacked comparison because DAPT uses unlabeled target text and our method also does.

PromptNER. PromptNER is the strongest reported CrossNER system in the file. It reports "an average F1 gain of 3%" and wins on 3 of 5 domains. We compare against its published numbers where they are available and report inference cost alongside. We do not claim to beat it in absolute F1 unless our results show it.

Transformer re-implementations of the two adversarial ancestors. We port DATNet (DATNet) as a whole-sequence discriminator plus uniform embedding perturbation. We port the entity-attention discriminator of Peng et al.. On CoNLL→Twitter, the original entity-aware system reports "F1 score of 54.69 for C → T", which serves as a sanity anchor for our ports. We also include MELM augmentation (MELM), which reports a 6.3-point average gain at 100 samples on CoNLL.

Tuning protocol. Every system gets the same grid budget over learning rate, $\epsilon$, $K$, and the adversary weight. Every system is tuned on the same target development split.

Ablations isolating the key ingredients. Four ablations test the parts of the proposal. Uniform FreeLB over all tokens tests whether perturbation targeting matters at all. Untargeted perturbation restricted to entity tokens tests whether aiming at the most confusable type matters, beyond restricting to entities. A random-direction perturbation of equal norm tests whether we are only adding noise. A domain adversary applied to all tokens, and one applied to entity tokens only, test the context-only choice.

Why not just…?

Why not just do DAPT and fine-tune? DAPT is cheap and gives real gains. Yet CrossNER's best DAPT model still shows the 84.81% person/artist confusion, so continued pretraining alone does not fix type collapse. DAPT and our losses are also not mutually exclusive. The stacked comparison above measures whether our losses add anything on top of DAPT. If they add nothing there, the proposal fails on its most practical test.

Why not just add a margin loss on the output scores for confusable pairs? This is the most serious threat. A hinge loss pushing $z_t$ above $z_c$ on clean inputs targets the same confusion with no inner maximization. It costs one forward pass instead of $K$. If it matches the targeted perturbation, then the adversarial part is unnecessary, and we will report that. The perturbation should win only if the confusion comes from sensitivity to small shifts in the input neighbourhood rather than from clean-point scores alone. The probe and spectrum diagnostics should separate these two explanations. For that reason, this loss is a headline baseline rather than a footnote.

Why not just prompt an LLM? PromptNER is strong on CrossNER. It also has known problems: span-recovery errors, incomplete entity lists, and high inference cost. Our target is a small fine-tuned tagger that emits exact spans cheaply, and we report both accuracy and cost. If PromptNER leads in F1, the useful contribution is narrower: how far a cheap encoder can close the gap.

Why not just augment with MELM? Augmentation adds entity diversity. It does not directly separate parent from child types, and generated data has a noise ceiling beyond 3–4x (CLDG). We run MELM alone and combined with our losses. If MELM alone removes the type confusion, the proposal loses its motivation.

Proposed Experiments and Decisive Checks

The main testbed is CoNLL-2003 → each of the five CrossNER domains, at 10, 25, 100, and 200 target sentences, with five seeds. The metric is span-level micro-F1 plus the parent–child confusion rate. A control setting is CoNLL→Twitter, where source and target share entity types. There, our hypothesis predicts the entity-aware discriminator does as well as or better than context-only alignment. On CrossNER, it predicts the reverse. Observing this crossover would be the decisive evidence that type overlap, not alignment per se, decides where invariance belongs.

The second decisive check concerns mechanism. Entity-token alignment should lower the probe separability of fine types and flatten the feature spectrum, and targeted perturbation should restore both. If F1 improves without these representation changes, the proposed mechanism is not what is happening.

The third check is the margin-loss comparison. If the margin loss matches the targeted perturbation, we will report the simpler method as the finding.

A secondary transfer test on SciTech checks the results outside CrossNER. There we compare with PDALN's reported "78.23%" semi-supervised F1 against its BERT+CRF baseline of "75.29%".