intermediate extraction-knowledge-graphs 35 min read

Named Entity Recognition

A tagger that learns names by their spelling cannot find a name it never saw. What generalizes is context, provided training removes the name the way test-time novelty does.

Overview & Motivation

A filing says “Northgate Energy guided to 7 percent growth in fiscal 2026.” An information-extraction system has to return three typed spans: Northgate Energy, an organization; 7 percent, a percentage; fiscal 2026, a date. The sequence labeling topic turned that into one BIO tag per token and tagged the corpus’s entities with a linear-chain CRF. Its finance case study ended on a warning: almost every error it had left was a name the tagger had never seen in training.

This page takes that warning as its subject. We split the corpus’s companies in two. The taggers train on 3030 documents about 1818 companies and are tested on documents about those 1818 and on documents about 66 others, whose organizations, people, and products never appear in training. On the held-out documents, the sequence labeling topic’s CRF does not find a single organization. Read the lab’s sentence, from the held-out test: “northgate energy guided to percent growth in fiscal”. The word-feature CRF finds the percentage and the date and tags northgate energy as outside every entity.

Why that happens, and what fixes it, needs four pieces of mathematics first:

  1. Encodings. Tags are one way to write a set of spans. We prove which tag sequences are valid, and when BIOES is more expressive than BIO.
  2. Constrained decoding. Decoding only valid sequences is exactly conditioning the model on validity.
  3. A CRF on a contextual encoder. The masked-LM topic’s encoder supplies the features, and the CRF’s gradient tells the encoder what to change.
  4. Span evaluation and F1-optimal decoding. What span F1 averages, and how to decode the span set that maximizes it.

Then the held-out names. The fix that works is old, word dropout, but only in one of its two forms, and we prove why the other fails.


Spans and their encodings

A sentence has tokens x1,…,xTx_1, \dots, x_T, and EE is the set of entity types: here ORG, PERSON, GPE (places), PRODUCT, SECTOR, DATE, MONEY, and PERCENT.

Definition 1 (Span set).

A span (s,e,τ)(s, e, \tau) covers the tokens s,s+1,…,e−1s, s+1, \dots, e-1 and has type τ∈E\tau \in E. A span set is a set of pairwise disjoint spans. A recognizer maps a sentence to a span set.

A tagger cannot output a set directly, so we encode the set as one tag per token.

Definition 2 (BIO and BIOES).

BIO tags the first token of a span B-τ\tau, its other tokens I-τ\tau, and every other token O: 2∣E∣+12|E| + 1 tags. BIOES tags a one-token span S-τ\tau and a longer span B-τ\tau, I-τ\tau, …\dots, I-τ\tau, E-τ\tau, with O elsewhere: 4∣E∣+14|E| + 1 tags.

The lab’s sentence is northgate/B-ORG energy/I-ORG guided/O to/O percent/B-PERCENT growth/O in/O fiscal/B-DATE in BIO. In BIOES the organization ends on E-ORG, and the one-word percentage and date become S-PERCENT and S-DATE. (The tokenizer keeps letters only, so “7” and “2026” are gone.)

Not every tag sequence encodes a span set. “O I-ORG” continues a span that never began, and in BIOES so does “B-ORG O”: a span that opens and never closes. Picture all KTK^T sequences as paths through a K×TK \times T trellis. The valid ones are the paths that avoid certain starts, certain steps, and certain ends.

Proposition 1 (Encodings are bijections onto first-order languages).

For each scheme, the encoding is a bijection from the span sets on TT tokens onto the valid tag sequences, and a sequence is valid exactly when its first tag passes a start mask, each adjacent pair passes a transition mask, and its last tag passes an end mask:

  • BIO: I-τ\tau may follow only B-τ\tau or I-τ\tau, so it may not start a sentence; every tag may end one.
  • BIOES: after B-τ\tau or I-τ\tau only I-τ\tau or E-τ\tau may follow; after O, E, or S only O, B, or S may follow; a sentence starts on O, B, or S and ends on O, E, or S.

With MM the 0–1 transition matrix and a,ba, b the start and end masks, the number of valid sequences is a⊤MT−1b=N(T)a^\top M^{T-1} b = N(T), where N(0)=1N(0) = 1 and N(T)=N(T−1)+∣E∣∑l=1TN(T−l)N(T) = N(T-1) + |E| \sum_{l=1}^{T} N(T - l). Reading tags left to right, opening a span at any tag that does not continue an open span of its type (the CoNLL scorer’s convention), maps all KTK^T sequences onto the span sets, many to one.

Proof.

Decoding a valid sequence reads each span back: a B or S tag opens a span, I continues it, and in BIO the next tag that does not continue it closes it, while in BIOES an E or S closes it. So decoding inverts encoding on valid sequences, and encoding is injective. Conversely, every pattern the masks forbid is one that no encoding produces (an I or E with nothing open, a B or I followed by something other than I or E, a span still open at the end), so the valid sequences are exactly the images. The mask conditions involve only one tag or two adjacent tags, which is what first-order means, and a⊤MT−1ba^\top M^{T-1} b counts the paths of length TT through the 0–1 graph of allowed steps. For the recursion, look at token TT: either it lies outside every span, leaving a span set on T−1T - 1 tokens, or it ends a span of length l∈{1,…,T}l \in \{1, \dots, T\} and one of ∣E∣|E| types, leaving a span set on T−lT - l tokens. The repair reads some span set off every sequence, and it reads the same set off, for example, “O I-ORG” and “O B-ORG”.

∎

With all eight types, T=4T = 4 tokens have 8,7218{,}721 span sets, against 83,52183{,}521 BIO sequences and 1,185,9211{,}185{,}921 BIOES sequences. The harness checks the bijection, the mask characterization, and the count by enumerating every sequence for one and two types up to T=5T = 5.

BIOES carries more information per tag: whether a span ends here. Does that make it a richer model?

Proposition 2 (BIO against BIOES).

(a) For every BIO chain with potentials (U,P)(U, P), the BIOES chain Ut′(y)=Ut(c(y))U'_t(y) = U_t(c(y)), P′(y,y′)=P(c(y),c(y′))P'(y, y') = P(c(y), c(y')), where cc maps S-τ\tau to B-τ\tau and E-τ\tau to I-τ\tau, gives every span set the same probability, both chains constrained to valid sequences.

(b) With token-local features, where UtU_t depends on the sentence only through xtx_t, the inclusion is strict. Take two training sentences, “a d” with gold span set {(0,1,ORG)}\{(0, 1, \mathrm{ORG})\} and “c d” with {(0,2,ORG)}\{(0, 2, \mathrm{ORG})\}. Every BIO chain gives the two gold span sets total probability at most 11, while BIOES chains give each one probability as close to 11 as we like.

(c) If each token’s features include the word to its left, BIO chains also approach probability 11 on both.

Proof.

(a) The map cc sends each valid BIOES sequence to the valid BIO sequence of the same span set, so it is a bijection between the two valid sets (Proposition 1), and by construction the score of yy is the score of c(y)c(y). Equal scores over sets in bijection give equal probabilities after normalizing.

(b) Both gold span sets need z1=Bz_1 = \mathrm B. Given z1=Bz_1 = \mathrm B, the chain’s conditional law of z2z_2 is proportional to eP(B,z2)+U2(z2)β2(z2)e^{P(\mathrm B, z_2) + U_2(z_2)}\beta_2(z_2), which depends on the sentence only through x2x_2, and both sentences have x2=dx_2 = d. Call that law qq. The first gold set needs z2=Oz_2 = \mathrm O and the second needs z2=Iz_2 = \mathrm I, so their probabilities are at most q(O)q(\mathrm O) and q(I)q(\mathrm I), which sum to at most 11. In BIOES the two sentences need different first tags, S for “a” and B for “c”, which token-local weights can separate, and after B the masks force E.

(c) A feature “the left word is cc” on token 22 lets U2(I)U_2(\mathrm I) differ between the sentences, which breaks the argument in (b).

∎

Fit by penalized maximum likelihood, the token-local BIO chain gives the two gold sets 0.4990.499 and 0.4990.499; BIOES gives 0.9940.994 and 0.9950.995; BIO with the left word gives 0.9940.994 and 0.9940.994. Ratinov and Roth (2009) found BILOU, their name for BIOES, better than BIO in practice. Proposition 2 says what such a finding can and cannot mean: once the features see a token’s neighbors, as every tagger below does, the two schemes describe the same span distributions, and any difference is estimation, with twice the tags to estimate.


Constrained decoding

A CRF trained on valid sequences still gives invalid ones positive probability, and its Viterbi path can be invalid. The fix is to forbid them, and the next theorem says what forbidding computes.

Theorem 1 (Constrained decoding is conditioning).

Let CC be the valid sequences of Proposition 1, and modify a chain’s log-potentials by setting U1(k)=−∞U_1(k) = -\infty for every tag kk the start mask forbids, UT(k)=−∞U_T(k) = -\infty for every tag the end mask forbids, and P(j,k)=−∞P(j, k) = -\infty for every forbidden step. Then the sequence recursions of the sequence labeling topic, run on the modified chain, return

(a) the Viterbi path arg⁡max⁡z∈Cp(z∣x)\arg\max_{z \in C} p(z \mid x);

(b) the node marginals p(zt=k∣x,Z∈C)p(z_t = k \mid x, Z \in C);

(c) log⁡ZC−log⁡Z=log⁡p(Z∈C∣x)\log Z_C - \log Z = \log p(Z \in C \mid x), where ZCZ_C is the modified chain’s partition function.

Proof.

The modification multiplies each path’s potential escore⁡(z)e^{\operatorname{score}(z)} by

1[z1 allowed] ∏t1[(zt,zt+1) allowed]  1[zT allowed]=1[z∈C],\mathbf 1[z_1 \text{ allowed}]\,\prod_t \mathbf 1[(z_t, z_{t+1}) \text{ allowed}]\;\mathbf 1[z_T \text{ allowed}] = \mathbf 1[z \in C],

a product of factors on single nodes and adjacent pairs. So the modified potentials are again a chain, and the sequence labeling topic’s Theorem 1 applies to it unchanged: its max pass returns the best path with nonzero potential, which is the best valid path; its sum pass returns ZC=∑z∈Cescore⁡(z)Z_C = \sum_{z \in C} e^{\operatorname{score}(z)} and marginals of the distribution proportional to escore⁡(z)1[z∈C]e^{\operatorname{score}(z)}\mathbf 1[z \in C], which is p(z∣x,Z∈C)p(z \mid x, Z \in C). Finally ZC/Z=∑z∈Cp(z∣x)Z_C / Z = \sum_{z \in C} p(z \mid x).

∎

Two things follow. Constrained Viterbi is not a heuristic repair; it is the exact mode of the model conditioned on producing a span set. And the cost is nothing: the same O(TK2)O(TK^2) passes with some entries set to −∞-\infty. The harness checks all three parts against enumeration on random chains in both schemes. Every CRF tagger below decodes an invalid sequence in fewer than 0.7%0.7\% of test sentences without the constraint, so for CRFs the constraint rarely binds. For the independent softmax head of the next section it binds constantly.


A CRF on a contextual encoder

The sequence labeling topic scored each token with hand-built features: the word, its prefix and suffix, its neighbors. The masked-LM topic trained an encoder whose final state at each position summarizes the whole sentence around that token. We put the CRF on top of it.

Definition 3 (A CRF on encoder states).

Let ht∈Rdh_t \in \mathbb R^d be an encoder’s final state at token tt. The encoder CRF has unary potentials Ut(k)=(Wht+b)kU_t(k) = (W h_t + b)_k, transition weights P(j,k)P(j, k), and start and end weights, and p(z∣x)∝exp⁡(∑tUt(zt)+∑tP(zt,zt+1))p(z \mid x) \propto \exp\big(\sum_t U_t(z_t) + \sum_t P(z_t, z_{t+1})\big) with the start and end weights folded into U1U_1 and UTU_T. The softmax head is the case P=0P = 0 with no start or end weights: an independent classifier at each token.

Theorem 2 (The gradient at the potentials).

Write γt(k)=p(zt=k∣x)\gamma_t(k) = p(z_t = k \mid x) and ξt(j,k)=p(zt=j,zt+1=k∣x)\xi_t(j, k) = p(z_t = j, z_{t+1} = k \mid x). Then

∂log⁡p(z∣x)∂Ut(k)=1[zt=k]−γt(k),∂log⁡p(z∣x)∂P(j,k)=∑t=1T−1(1[zt=j, zt+1=k]−ξt(j,k)).\frac{\partial \log p(z \mid x)}{\partial U_t(k)} = \mathbf 1[z_t = k] - \gamma_t(k), \qquad \frac{\partial \log p(z \mid x)}{\partial P(j, k)} = \sum_{t=1}^{T-1}\big(\mathbf 1[z_t = j,\, z_{t+1} = k] - \xi_t(j, k)\big).

So the loss L=−log⁡p(z∣x)L = -\log p(z \mid x) sends the encoder ∂L/∂ht=(γt−ezt)⊤W\partial L / \partial h_t = (\gamma_t - e_{z_t})^\top W, where ezte_{z_t} is the indicator vector of the gold tag. For the softmax head, γt\gamma_t is the per-token softmax and this is the cross-entropy gradient.

Proof.

log⁡p(z∣x)=score⁡(z)−log⁡Z\log p(z \mid x) = \operatorname{score}(z) - \log Z. The score is linear in the potentials, with derivative 1[zt=k]\mathbf 1[z_t = k] in Ut(k)U_t(k) and the count of j→kj \to k steps in P(j,k)P(j, k). For log⁡Z=log⁡∑z′escore⁡(z′)\log Z = \log \sum_{z'} e^{\operatorname{score}(z')}, the derivative in Ut(k)U_t(k) is ∑z′p(z′∣x)1[zt′=k]=γt(k)\sum_{z'} p(z' \mid x)\mathbf 1[z'_t = k] = \gamma_t(k), and in P(j,k)P(j, k) it is the expected number of j→kj \to k steps, ∑tξt(j,k)\sum_t \xi_t(j, k). This is the sequence labeling topic’s Theorem 2 with the potentials themselves as the parameters. The chain rule through Ut=Wht+bU_t = W h_t + b gives the encoder’s gradient. With P=0P = 0 and no start or end weights the chain factorizes over tokens, so γt\gamma_t is the softmax of UtU_t.

∎

The vector γt−ezt\gamma_t - e_{z_t} is “what the model believes minus what is true,” position by position, and Collobert et al. (2011) trained taggers end to end on exactly this sentence-level objective. The harness checks Theorem 2 by complex-step differentiation on random chains and checks its chain rule through the masked-LM encoder, fed into the fine-tuning topic’s backward pass, by central differences on its weights. On this page we keep the encoder frozen: its states are fixed features, and only the CRF is trained.

Corollary 1 (Frozen states keep the objective strictly concave).

With the encoder fixed, the penalized conditional log-likelihood of an encoder CRF, in (W,b,P)(W, b, P) and the start and end weights, is strictly concave for every λ>0\lambda \gt 0 and has exactly one maximizer.

Proof.

Fixed states make every feature hth_t a constant, so the encoder CRF is the sequence labeling topic’s linear-chain CRF with dense real-valued features. Its Theorem 2 gives a negative semidefinite Hessian, and the penalty subtracts λI\lambda I (formalML convex-analysis, Theorem 3, for the second-order condition). The objective grows to −∞-\infty in every direction, so its maximum is attained, at one point.

∎

Fine-tuning gives this up: the score becomes a non-convex function of the encoder’s weights. Devlin et al. (2019) fine-tune BERT for the same task with a softmax head and no CRF, so whether a CRF still helps a fine-tuned encoder is a fair question, and one this page leaves open. On frozen states the answer is clear (the Heads & constraints tab). The softmax head decodes an invalid BIO sequence in 9.9%9.9\% of the seen-roster test sentences and 14.9%14.9\% of the held-out ones. Theorem 1’s constraint removes those and raises its span F1 from 0.7630.763 to 0.8090.809 (seen) and from 0.6990.699 to 0.7100.710 (held out). The CRF head on the same states scores 0.9020.902 and 0.8230.823. The frozen states know a token is part of a name; they were never trained to know where the name ends, and the transition weights supply that.


Span evaluation in depth

The sequence labeling topic scored taggers by exact-match span F1, the CoNLL-2003 convention (Tjong Kim Sang and De Meulder 2003). That is one point in a small space of choices.

Definition 4 (Match criteria and span F1).

Fix a match relation between a gold span gg and a predicted span pp of the same sentence:

  • strict: the same boundaries and type;
  • boundary: the same boundaries, any type;
  • type: overlapping, with the same type;
  • partial: overlapping.

Precision is the share of predicted spans that match some gold span, recall the share of gold spans that some predicted span matches, and F1 their harmonic mean, 2PR/(P+R)2PR/(P + R). Under strict matching both shares count the same pairs, so F1=2 TP/(∣G∣+∣P^∣)F_1 = 2\,\mathrm{TP}/(|G| + |\hat P|), with GG and P^\hat P the gold and predicted spans. Per-type F1 restricts both sets to one type.

These are the four criteria of the SemEval-2013 drug-interaction task (Segura-Bedmar, Martínez, and Herrero-Zazo 2013, §3.1), which defers the crediting of partial matches to the MUC scoring conventions; we count any overlap as a match. Two facts about them are worth stating precisely.

Proposition 3 (What span F1 averages, and relaxing the match).

(a) Under strict matching, the micro F1 over all types is a mixture of the per-type F1s,

F1=∑τ∈Ewτ F1,τ,wτ=∣Gτ∣+∣P^τ∣∑σ∈E(∣Gσ∣+∣P^σ∣),F_1 = \sum_{\tau \in E} w_\tau\, F_{1,\tau}, \qquad w_\tau = \frac{|G_\tau| + |\hat P_\tau|}{\sum_{\sigma \in E} \big(|G_\sigma| + |\hat P_\sigma|\big)},

with weights that depend on the predictions. Macro F1 is the mixture with equal weights.

(b) If every pair that matches under one relation matches under a second, then precision, recall, and F1 under the second are at least their values under the first. So strict ≤\le boundary ≤\le partial and strict ≤\le type ≤\le partial, in all three measures.

Proof.

(a) F1,τ=2 TPτ/(∣Gτ∣+∣P^τ∣)F_{1,\tau} = 2\,\mathrm{TP}_\tau / (|G_\tau| + |\hat P_\tau|), so wτF1,τ=2 TPτ/∑σ(∣Gσ∣+∣P^σ∣)w_\tau F_{1,\tau} = 2\,\mathrm{TP}_\tau / \sum_\sigma (|G_\sigma| + |\hat P_\sigma|); summing over τ\tau gives 2 TP/(∣G∣+∣P^∣)2\,\mathrm{TP} / (|G| + |\hat P|), because the types partition both sets. (b) A predicted span matched under the first relation is matched under the second, so precision can only rise, and likewise recall. F1 increases in each of PP and RR.

∎

Part (a) is a warning about reading micro F1. A tagger that predicts many spans of an easy type raises that type’s weight, and with it the micro score, even if its F1 on the hard types stays put. Here MONEY and PERCENT are read off one word each (million, percent), so every tagger scores near 11 on them, and organizations are the hard type: per-type F1 is the number to watch. Part (b) makes the gaps between criteria diagnostic. The encoder CRF on the held-out test scores 0.8230.823 strict but 0.9150.915 under type matching: it finds the organizations and misplaces their boundaries, an error a strict score alone cannot separate from missing them. The Held-out names tab switches between the four criteria.


F1-optimal span decoding

Viterbi decoding maximizes the probability of the whole tag sequence (the sequence labeling topic’s Theorem 4), and span F1 is not that. Can we decode for F1 directly? The first ingredient is the probability of each span.

Proposition 4 (Span marginals).

Let α\alpha and β\beta be the forward and backward messages of a constrained chain (Theorem 1), and write ψt(k)=eUt(k)\psi_t(k) = e^{U_t(k)} and ψ(j,k)=eP(j,k)\psi(j, k) = e^{P(j, k)}. In BIO, the probability that the span set contains (s,e,τ)(s, e, \tau) is

q(s,e,τ)=1Z αs(Bτ)∏t=s+1e−1ψ(⋅,Iτ) ψt(Iτ)  ∑k≠Iτψ(⋅,k) ψe(k) βe(k),q_{(s, e, \tau)} = \frac{1}{Z}\, \alpha_s(\mathrm B_\tau) \prod_{t=s+1}^{e-1} \psi(\cdot, \mathrm I_\tau)\, \psi_t(\mathrm I_\tau) \; \sum_{k \ne \mathrm I_\tau} \psi(\cdot, k)\, \psi_e(k)\, \beta_e(k),

where each ψ(⋅,⋅)\psi(\cdot, \cdot) links the tag before it to the next, and the last factor is βT(⋅)=1\beta_{T}(\cdot) = 1 when e−1e - 1 is the last token. In BIOES the span is S-τ\tau at ss, or B-τ\tau, I-τ\tau, …\dots, E-τ\tau, closed by βe−1\beta_{e-1}. The marginals sum to the expected number of spans, m=E∣S∣=∑tp(zt∈B∪S∣x)m = \mathbb E|S| = \sum_t p(z_t \in \mathrm B \cup \mathrm S \mid x).

Proof.

In BIO a valid sequence contains the span exactly when zs=Bτz_s = \mathrm B_\tau, zs+1,…,ze−1=Iτz_{s+1}, \dots, z_{e-1} = \mathrm I_\tau, and ze≠Iτz_e \ne \mathrm I_\tau (or the sentence ends). Summing the potentials of all such paths factorizes as in the sequence labeling topic’s Theorem 1: prefixes ending in B-τ\tau at ss give αs(Bτ)\alpha_s(\mathrm B_\tau), the pinned middle contributes its product, and suffixes starting with any k≠Iτk \ne \mathrm I_\tau at ee give the last sum. BIOES is the same with its own pinned pattern. Each span begins with exactly one B or S tag, so the number of spans is the number of such tags, and expectations add.

∎

Now the objective. With marginals qq over a whole test corpus and m=∑qm = \sum q, a predicted span set S^\hat S has expected true positives ∑s∈S^qs\sum_{s \in \hat S} q_s and the gold set has expected size mm, so the F1 of expected counts is Φ(S^)=2∑s∈S^qs / (∣S^∣+m)\Phi(\hat S) = 2\sum_{s \in \hat S} q_s \,/\, (|\hat S| + m).

Theorem 3 (F1-optimal span decoding).

Maximize Φ(S^)\Phi(\hat S) over span sets, one per sentence.

(a) F∗=max⁡ΦF^* = \max \Phi if and only if max⁡S^∑s∈S^(2qs−F∗)=F∗m\max_{\hat S} \sum_{s \in \hat S}(2q_s - F^*) = F^* m.

(b) Starting from F0=0F_0 = 0, the iteration S^k=arg⁡max⁡S^∑s∈S^(2qs−Fk)\hat S_k = \arg\max_{\hat S} \sum_{s \in \hat S}(2q_s - F_k), Fk+1=Φ(S^k)F_{k+1} = \Phi(\hat S_k) increases strictly until it stops, after finitely many steps, at F∗F^*, and S^k\hat S_k is then optimal.

(c) The inner maximization chooses disjoint spans to maximize ∑(qs−F/2)\sum (q_s - F/2), a weighted interval scheduling problem solved per sentence by a dynamic program over token positions. So the optimal span set thresholds the marginals at F∗/2F^*/2, subject to disjointness. When the candidate spans are pairwise disjoint it is exactly {s:qs>F∗/2}\{s : q_s \gt F^*/2\}.

Proof.

(a) For every S^\hat S, Φ(S^)≤F\Phi(\hat S) \le F is equivalent to ∑S^2qs−F(∣S^∣+m)≤0\sum_{\hat S} 2q_s - F(|\hat S| + m) \le 0, since the denominator is positive, and ∑S^2qs−F∣S^∣=∑S^(2qs−F)\sum_{\hat S} 2q_s - F|\hat S| = \sum_{\hat S}(2q_s - F). So F≥max⁡ΦF \ge \max\Phi exactly when g(F)=max⁡S^∑S^(2qs−F)−Fm≤0g(F) = \max_{\hat S}\sum_{\hat S}(2q_s - F) - Fm \le 0, with equality at F=max⁡ΦF = \max \Phi because the maximizing set attains it. This is the characterization of a ratio’s maximum that Dinkelbach (1967) restates from Jagannathan and turns into an algorithm.

(b) g(Fk)≥∑S^k−1(2qs−Fk)−Fkm=0g(F_k) \ge \sum_{\hat S_{k-1}}(2q_s - F_k) - F_k m = 0, using Φ(S^k−1)=Fk\Phi(\hat S_{k-1}) = F_k. If g(Fk)>0g(F_k) \gt 0, the set S^k\hat S_k has ∑S^k2qs−Fk(∣S^k∣+m)>0\sum_{\hat S_k} 2q_s - F_k(|\hat S_k| + m) \gt 0, which says Φ(S^k)>Fk\Phi(\hat S_k) \gt F_k: a strict increase. If g(Fk)=0g(F_k) = 0, then Fk=F∗F_k = F^* by (a). There are finitely many span sets, so the values cannot rise forever.

(c) For fixed FF the objective adds one weight 2qs−F2q_s - F per chosen span, and the only constraint is that spans in one sentence be disjoint. Let V(t)V(t) be the best total over spans inside the first tt tokens. Then V(t)=max⁡(V(t−1),max⁡(s,t,τ)V(s)+2q(s,t,τ)−F)V(t) = \max\big(V(t-1), \max_{(s, t, \tau)} V(s) + 2q_{(s,t,\tau)} - F\big), and V(T)V(T) with its back-pointers is the optimum. A span with weight at most 00 never helps, so only spans with qs>F/2q_s \gt F/2 are chosen. With disjoint candidates there is no conflict, and the set is all of them.

∎

Lipton, Elkan, and Naryanaswamy (2014, Corollary 1) proved the threshold F∗/2F^*/2 for binary decisions with calibrated probabilities, F1 taken as a ratio of population rates; spans add the disjointness constraint, which the interval program handles. One more fact makes the program cheap.

Remark (Above one half, no conflicts).

Two overlapping spans cannot both belong to one span set, so they are disjoint events and qa+qb≤1q_a + q_b \le 1. Two candidates above a threshold τ≥1/2\tau \ge 1/2 therefore never overlap, and thresholding at τ≥1/2\tau \ge 1/2 needs no dynamic program at all.

Two caveats belong next to the theorem. Φ\Phi is the F1 of expected counts, not the expected F1, and the two agree only asymptotically, on large test sets (Ye et al. 2012, Theorem 8). And the theorem optimizes the model’s own beliefs. If the marginals are calibrated, in formalML’s sense of uncertainty-quantification (its Definition 3), F∗F^* is a forecast of the realized F1 and F∗/2F^*/2 the right threshold; if not, neither is. The calibration topic is about measuring exactly that gap, and the held-out names below open one. The harness checks Theorem 3 against brute force over every combination of disjoint span subsets on random multi-sentence instances, and the threshold form against all 2102^{10} subsets of ten disjoint candidates.


Holding names out by design

Who finds a name the tagger never saw
tagger
testencoder reads unseen words
match
span F1 (strict)
0.642
strict precision / recall
1.000 / 0.472
strict F1, seen / unseen mentions
0.967 / 0.203
00.250.50.751ORG0.000PERSON0.310GPE0.720PRODUCT0.788SECTOR0.860DATE1.000MONEY1.000PERCENT1.000
held-out example — gold
northgateenergy ORGguidedtopercent PERCENTgrowthinfiscal DATE
this tagger
northgateenergyguidedtopercent PERCENTgrowthinfiscal DATE

Strict F1 per type (bars). The word CRF predicts no organization anywhere in the held-out test. Relax the match to see boundary errors: a tagger that finds a name but misplaces its edges gains under “type” and “partial” (Proposition 3). 35 of the 49 held-out name words were in the encoder’s pretraining vocabulary.


Where this sits

The sequence labeling topic built the chain; this page fixed its output language (Proposition 1, Theorem 1), its features (a frozen contextual encoder), its metric (Proposition 3, Theorem 3), and its training data (name dropout, Proposition 5). The spans it returns are the input of the next topic, relation extraction, which asks which pairs of recognized entities a sentence relates. Its distant supervision reads labels off the corpus’s knowledge base, so its errors start where this page’s end: a missed organization is a relation that can never be found.


Honest caveats


Implementation

The companion notebook (notebookPath) imports named_entity_recognition.py, which owns every number on this page. It imports the sequence labeling topic’s module for the chain recursions, the CRF objective and its L-BFGS fit, the finance BIO sentences, and the word features, and the fine-tuning topic’s module for the masked-LM encoder, its fast forward pass, and its backward pass. Its harness checks:

  • Proposition 1’s bijection, masks, and count, and Proposition 2’s relabeling and counterexample, by enumeration;
  • Theorem 1’s three parts and Proposition 4’s span marginals against brute force on random chains in both schemes;
  • Theorem 2 by complex step on chains and by central differences through the encoder, and Corollary 1’s unique optimum from two starts;
  • Theorem 3 against every combination of disjoint span subsets, and the F∗/2F^*/2 threshold on disjoint candidates;
  • Proposition 3 on random span sets and on every tagger, and Proposition 5 on a toy fit and on the substitution-trained tagger;
  • every comparison this page states, on both test sets and both encoder readings.

The laboratory reads its data from a JSON file that one of the harness’s tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.

Connections

  • Theorem 3's F1-optimal decoder is optimal only for calibrated span marginals; the held-out names miscalibrate them, and the calibration topic's reliability analysis is how one would measure that. language-model-calibration
  • Its encoder backward pass is the one Theorem 2 feeds with gold indicators minus marginals; this page keeps the encoder frozen, and fine-tuning it through the CRF is the experiment it leaves open. fine-tuning-low-rank-adaptation

References & Further Reading

  • paper Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity Recognition — Erik F. Tjong Kim Sang and Fien De Meulder (2003) Proceedings of CoNLL-2003, 142–47. The benchmark and its scoring: a phrase counts only if it matches a gold phrase exactly (strict span F1)
  • paper Design Challenges and Misconceptions in Named Entity Recognition — Lev Ratinov and Dan Roth (2009) Proceedings of CoNLL-2009, 147–55. Section 4 and Table 2 compare BIO with BILOU (BIOES): BILOU wins on three of four evaluation sets
  • paper Neural Architectures for Named Entity Recognition — Guillaume Lample, Miguel Ballesteros, Sandeep Subramanian, Kazuya Kawakami, and Chris Dyer (2016) Proceedings of NAACL-HLT 2016, 260–70. A BiLSTM with a CRF output layer; §4.1 replaces singletons with an unknown-word embedding with probability 0.5 in training; §2.4 finds IOBES no significant improvement over IOB
  • paper Natural Language Processing (Almost) from Scratch — Ronan Collobert, Jason Weston, Léon Bottou, Michael Karlen, Koray Kavukcuoglu, and Pavel Kuksa (2011) Journal of Machine Learning Research 12: 2493–537. Section 3.4.2, the sentence-level log-likelihood: transition scores added to a network's per-token scores, normalized over all tag paths, trained end to end
  • paper BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding — Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova (2019) Proceedings of NAACL-HLT 2019, 4171–86. Section 5.3: CoNLL-2003 NER as tagging, the first sub-token's representation fed to a token-level classifier with no CRF layer
  • paper Generalisation in Named Entity Recognition: A Quantitative Analysis — Isabelle Augenstein, Leon Derczynski, and Kalina Bontcheva (2017) Computer Speech & Language 44: 61–83. Leading recognizers rely on surface forms seen in training, and score markedly lower on unseen entities, mostly through recall
  • paper SemEval-2013 Task 9: Extraction of Drug-Drug Interactions from Biomedical Texts (DDIExtraction 2013) — Isabel Segura-Bedmar, Paloma Martínez, and María Herrero-Zazo (2013) Proceedings of SemEval 2013, 341–50. Section 3.1: the four entity-matching criteria, strict, exact boundary, partial boundary, and type
  • paper On Nonlinear Fractional Programming — Werner Dinkelbach (1967) Management Science 13, no. 7: 492–98. Restates and proves Jagannathan's (1966) theorem relating fractional and parametric programs, and gives the iteration; cited from the abstract (the full text was not accessible)
  • paper Optimal Thresholding of Classifiers to Maximize F1 Measure — Zachary C. Lipton, Charles Elkan, and Balakrishnan Naryanaswamy (2014) Machine Learning and Knowledge Discovery in Databases: ECML PKDD 2014, Part II, Lecture Notes in Computer Science 8725, 225–39. Corollary 1: with calibrated probabilities, the F1-optimal threshold is half the optimal F1 (population F1, a ratio of rates)
  • paper Optimizing F-Measures: A Tale of Two Approaches — Nan Ye, Kian Ming A. Chai, Wee Sun Lee, and Hai Leong Chieu (2012) Proceedings of the 29th ICML. Theorem 8: empirical utility maximization and the decision-theoretic approach to F-measures are asymptotically equivalent on large i.i.d. test sets