Manuscript Offprint
arXiv:2610.28922Constrained Tagging for Span Labeling
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Generative LLMs can label spans without task-specific training, but their output is not tied to positions in the input: a returned span may be absent from the input or occur several times. We present constrained tagging, a training-free method in which the model reproduces the input and wraps each span in labeled inline markup. A logits processor using a byte-level token trie and a finite-state machine admits only tokens that continue the input verbatim or form a valid tag, so the output reproduces the input exactly with labels from the given set, and spans may begin or end at any character boundary, even inside a token. Two-phase decoding lets reasoning models reason before the constraint engages. On six datasets and six open-weight models, the guarantee holds in all but 0.022% of 255,312 constrained generations, each failure a reasoning model exhausting its token budget or never closing its reasoning, and the constraint adds no measurable cost. Unlike context-based prompting, which loses 8.5% of its spans, constrained tagging locates every span it proposes on every dataset; it is as accurate on two datasets, and on the other four its errors lie in which spans the model chooses, not where they are.
1 Introduction
Classifying text spans is a fundamental problem in NLP, with applications ranging from named entity recognition and extractive question answering to grammatical error correction, toxic language detection, and other information extraction tasks. Traditionally, this problem has been addressed with encoder-only models such as BERT (Devlin et al., 2019), which directly produce token-level predictions. These models need a large annotated dataset for every task, and they must be retrained whenever the label set changes. Generative large language models (LLMs), which have grown far larger and more capable and can now reason before they answer, offer a different paradigm: they can perform

Figure 1: Constrained tagging. At every step, the processor admits only tokens that continue the input verbatim or belong to the tag markup (green) and masks all others (red), so the output reproduces x exactly, and the offsets of each span follow from where its tag was generated.
span labeling in a zero-shot setting through prompting alone, which makes them attractive when labeled data are scarce or the label set changes.
Applying generative LLMs to span labeling, however, introduces a challenge encoders do not face: once the model identifies a span of interest, how do we locate it precisely within the original input text? Generative LLMs operate autoregressively, producing output tokens without any inherent correspondence to positions in the source text. This creates a fundamental localization problem, which is particularly acute when the same surface form appears several times: simply extracting “Charles” from the model output provides no information about which occurrence was identified or where in the text it is located (Fig. 1). Generative models may also fail to copy text faithfully, producing spans that cannot be aligned to the source at all.
In this paper, we use a constrained decoding approach to span labeling. We classify spans with a tagging mechanism: the model reproduces the input text and tags each span inline, wrapping it in markup that assigns it a label (Fig. 1). A logits processor, guided by a byte-level token trie (Fredkin, 1960) and a finite-state machine, restricts the generation at every step to tokens that either continue the input verbatim or form a valid tag with a label from the given label set. Localization is therefore enforced during generation rather than recovered afterwards: the position of every span is determined by construction at the moment it is generated, the output reproduces the input exactly, and a hallucinated span or an invalid label cannot be produced. Nothing is trained: adapting the method to a new task requires only a system prompt and a set of labels (§4).
Our contributions are: (1) a training-free constrained decoding method for span labeling by tagging, which guarantees that the output reproduces the input verbatim with labels only from the given set, and places span boundaries at any character boundary, including inside a token (§4); (2) two-phase decoding, which leaves the reasoning trace of a reasoning model unconstrained and constrains only its answer, so that reasoning models, including those that may skip their reasoning, keep the guarantee (§4.4); and (3) an evaluation on six datasets covering five span-labeling tasks, with six open-weight models from three families, against unconstrained tagging and context-based prompting, showing that the guarantee holds in all but 0.022% of 255,312 constrained generations with no measurable overhead from the constraint, and that the remaining errors lie in which spans the model chooses rather than where they are (§5).
Generative LLMs for span labeling. Ding et al. (2024) view span-oriented tasks as predicting triples of begin, end, and class, which puts one question at the center of every task: how to recover exact positions from the output of a generative model. GPT-NER (Wang et al., 2025) has the model reproduce the input with special tokens surrounding the entities of one type, while Prompt-NER (Ashok and Lipton, 2023), CodeIE (Li et al., 2023), InstructUIE (Wang et al., 2023), and UniversalNER (Zhou et al., 2024) return lists of entities without positions, as free text, code or the output of a fine-tuned model, so the spans must still be matched back to the input. Dukić and Šnajder (2024) instead make decoder-only models competitive with encoders by removing the causal mask in selected layers, which requires task-specific training. Surveys (Keraghel et al., 2024; Xu et al., 2024) consistently find that generative LLMs recognize what to extract but struggle with exact boundaries and alignment to the source: constraining the format of the output does not constrain its content to come verbatim from the input.
Strategies for span labeling. Concurrently, Semin et al. (2026) compare three ways a generative LLM can produce labeled spans: tagging reproduces the input and wraps each span in markers, indexing outputs numeric positions, which requires accurate counting, and matching outputs the span text and aligns it to the source, which is ambiguous when a surface form repeats. On four tasks, three of which we use, they find tagging to be the most robust. Their constrained method, LogitMatch, restricts the span text of a matching output to substrings of the input; constraining tagging the same way ran into tokenization issues at the boundaries between text, tags, and span content, and was abandoned. Our processor handles all of these boundaries with one byte-level prefix search, and its copy cursor fixes the position of every span, including repeated ones that matching cannot tell apart.
Grammar-based constrained decoding. Grammar-constrained decoding represents the valid outputs as a formal language and restricts each step to tokens that keep the output within it. Outlines (Willard and Louf, 2023) compiles regular expressions and context-free grammars into an index of valid next tokens, XGrammar (Dong et al., 2025) compiles a context-free grammar into a byte-level pushdown automaton, and llguidance (Guidance AI, 2024) computes each mask by
Code and evaluation scripts: https://github.com/stulcrad/constrained-tagging walking a byte-level trie of the vocabulary against an Earley parser. A grammar fixed in advance enforces a schema, but it cannot require the output to reproduce the input: the copy language is a textbook example of a language that is not context-free. Geng et al. (2023) show that input-dependent grammars that reproduce the input with inline brackets let off-the-shelf LLMs parse without fine-tuning; they sketch similar grammars for chunking and semantic role labeling, but operate on words and leave tokenization ambiguity to tokenizer-specific workarounds, which our byte-level trie removes.
Trie-based and copy-constrained decoding. A trie (Fredkin, 1960) supports prefix search, finding every stored string that is a prefix of a given string in time proportional to its length, which suits constrained generation, where each step must find the vocabulary tokens that keep the output within a set of valid strings. GENRE (De Cao et al., 2021) decodes entity names from a trie and, for entity linking, constrains a fine-tuned model to copy the input token by token while inserting mention markup; Zhang et al. (2023) also copy the input with inline coreference markers through a copy action and a constrained beam search, and iNERD (Deußer et al., 2023) draws the entity text token by token from the input. All of them fine-tune the model and work at the granularity of tokens. We search a byte-level trie of the vocabulary, the structure of llguidance's toktrie, with the remaining input bytes, which lets an off-the-shelf model place span boundaries anywhere, including inside a token.
3 Datasets
Table 1 summarizes the six datasets and the axes along which they differ. One method is applied to all of them, with only the system prompt changing to describe the task and the label set.
Named Entity Recognition (NER) The goal is to localize the named entities and classify their type. We use two datasets. CoNLL-2003 (Tjong Kim Sang and De Meulder, 2003) is the longstanding benchmark, built from Reuters newswire and annotated with four entity types: Person (PER), Organization (ORG), Location (LOC), and Miscellaneous (MISC); its test split holds 3,453 sentences. UniversalNER (Mayhew et al., 2024) extends the same task to 18 treebanks in 12 languages with three coarse types, PER, ORG, and LOC, for 7,523 examples. NER is the only task whose spans are guaranteed to fall on word boundaries, and the loader represents both datasets as BIO tags over whitespace tokens.
Toxic Span Detection (TOX) Given a social-media post already judged toxic at the comment level, the goal is to find the character spans that carry the toxicity. We use Toxic Spans (Pavlopoulos et al., 2022), part of which formed SemEval-2021 Task 5 (Pavlopoulos et al., 2021): posts from the Civil Comments corpus annotated by three to five crowdworkers, where a character is gold when a majority marked it. We evaluate on the 1,000 posts of its test split as distributed on the Hugging Face Hub. There is a single label, TOXIC. Almost half of the posts (48.6%) are toxic in tone without any majority-agreed span, so their gold is the empty set.
Extractive Question Answering (QA) The goal is to locate the span of a passage that answers a question, so the admissible spans are set by the question rather than by a fixed schema. We use LegalQAEval (Butler, 2025), 1,206 test items whose legal passages were filtered out of SQuAD 2.0, MS MARCO, HotpotQA and Natural Questions. As in TOX, there is a single label, ANSWER. Exactly half of the items are unanswerable from their passage and carry empty gold.
Detecting Errors in Machine Translation (ESA-MT) The goal is to find error spans in a translation given its source. The gold is the human error-span annotation collected at WMT24 (Kocmi et al., 2024a) under the ESA protocol of Kocmi et al. (2024b); we read it from the WMT24 sample released by Kasner et al. (2026), restricted to the examples that contain at least one error. That leaves 867 examples over 24 source-target-domain files, covering translation out of English into eight languages across the news, social, and literary domains. Following the annotation scheme, spans carry a severity, either MINOR or MAJOR. The source is shown to the model as context and is never copied or tagged.
Grammatical Error Correction (GEC) The goal is to identify the spans that require editing to make the text correct. We use the English Write & Improve portion (Nicholls et al., 2024) of Multi-GEC (Masciolini et al., 2025), 504 learner essays whose edits are typed by ERRANT (Bryant et al., 2017) and grouped into three high-level categories:
| Dataset | Task | Lang. | |L| | Span geometry | median chars | N | |||
|---|---|---|---|---|---|---|---|---|---|
| span | input | spans/ex. | % empty | ||||||
| CoNLL-2003 | NER | 1 | 4 | token-aligned | 8 | 41 | 1.6 | 20.2 | 1,152 / 3,453 |
| Toxic Spans | toxicity | 1 | 1 | word-aligned | 6 | 142 | 0.6 | 48.6 | 1,000 |
| LegalQAEval | extractive QA | 1 | 1 | clause-paragraph | 30 | 577 | 0.5 | 50.0 | 1,206 |
| UniversalNER | NER | 12 | 3 | token-aligned | 7 | 104 | 1.9 | 0.0 | 3,702 / 7,523 |
| WMT24 ESA-MT | MT errors | 8 | 2 | sub-word-clause | 9 | 231 | 2.2 | 0.0 | 867 |
| MultiGEC | GEC | 1 | 3 | incl. zero-length | 3 | 869 | 14.1 | 0.0 | 504 |
Table 1: The six span-labeling datasets, and the axes along which they differ.
replacement (R), missing (M), and unnecessary (U). In GEC, the M label marks a position where the text is missing, so the gold spans for M are of zero length. The other two labels, R and U, always have non-zero length.
Subsampling. Two datasets are subsampled to fit our compute budget: CoNLL-2003 to 1,152 of its 3,453 test sentences, and UniversalNER to 250 examples per treebank (3,702 of 7,523; four of the 18 treebanks are smaller than 250 and are used whole). We draw the subsample uniformly at random and re-draw it per seed, so the three seeds vary the evaluation set as well as the decoding; within a seed, every system compared on that dataset sees the same examples. We fully evaluate the remaining four datasets.
Normalization. Inputs are Unicode NFC-normalized in the loader, with gold offsets remapped, and are otherwise left exactly as shipped, since the model must reproduce them.
4 Methodology
4.1 Problem Statement
Given an input text and a label set , span labeling asks for the set of labeled spans , where and are offsets between the characters of , so the span covers . The set may be empty, and a span may have zero length () when it marks a position in the text rather than any text at all.
We solve this task by constrained tagging: the model is prompted to return with every span it identifies written as
with (the prompts are in Appendix D). A valid output must satisfy , where strip removes the markup, and every label in must belong to . The processor advances a cursor through as the model copies it, so the offsets of every span follow from the position of the cursor when its tag opens, and repeated surface forms need no alignment step. After generation, the markup is parsed into labeled spans with character offsets; without the constraint, the share of outputs that fail is the wrong-text rate (§5).
Both conditions are enforced at decoding time by a logits processor that masks every token that would violate them. A byte-level token trie supplies the tokens that continue from the current position (§4.2), a finite-state machine decides where markup may appear and which labels it may carry (§4.3), and a two-phase extension lets reasoning models reason before the constraint engages (§4.4). The pseudocode for building and searching the trie is given in Appendix F.
4.2 Byte-Level Token Trie
Span boundaries belong to the text, not its tokenization, so we allow a span to begin or end at any character boundary of . This matters in practice: in ESA-MT, of error spans begin or end inside a word, typically at an incorrect inflectional ending, and nothing guarantees the tokenizer splits the word there. Copying is therefore not tied to the input's tokenization: a trie over the vocabulary returns every token that is a prefix of the remaining input, including tokens that end inside an input token. The trie is keyed on bytes, because in byte-level vocabularies a token can hold only part of a multi-byte character and has no character string of its own. Markup may still open or close only at a character boundary (guard (i), §4.3); the bytes inside a character are only copied through.
The trie is built once per tokenizer and reused across decoding steps and examples. Each vocabulary token is inserted along the path of its bytes, and the node where the path ends stores its id. The bytes are read directly from the token's vocabulary entry, for both byte-level BPE (Sennrich et al.,

Figure 2: The finite-state machine of the processor. Every edge is a set of admissible tokens; the machine accepts only after all of the input has been copied.
- and SentencePiece (Kudo and Richardson, 2018) with byte fallback (Alg. 1). They are never obtained by decoding the token to text and encoding it again, because a token that holds only part of a multi-byte character does not decode to valid text on its own.
The copy source is built the same way: x is tokenized, and the bytes of its tokens are concatenated. The processor checks that the result equals the UTF-8 encoding of x, since a tokenizer that normalizes its input would otherwise make the copy target differ from the text being labeled; this is why inputs are NFC-normalized in the loader (§3). The positions in x are byte offsets into this encoding. The processor precomputes which of them are character boundaries and allows markup only at those. A prefix search walks the remaining input bytes from the root and collects the ids stored at every node it passes, stopping at the first byte with no child (Alg. 2). Its cost is bounded by the length of the longest vocabulary token and does not depend on the length of x.
4.3 Constrained Logits Processor
The processor is a finite-state machine with four states (Fig. 2). At every step, it advances the machine by the just-generated token, computes the next admissible tokens, and sets the logits of all other tokens to , so that sampling renormalizes over the admissible set. In the copying states, OUTSIDE and SPAN, the admissible set is the trie's tokens for the remaining input, plus the first token of an opening block, or of </SPAN> once the span holds text; end-of-sequence becomes admissible only after all of x has been copied. In TAG, a label remains admissible only while its pre-tokenized opening block agrees with every token emitted since the tag opened, so the label that completes is always one of L.
Tags are written the way the model’s own tokenizer writes them. BPE tokenizers merge the space before a word into that word’s first token, so after a space, a model emits the space and the < of a tag as one token, not two. Each opening block is therefore pre-tokenized with and without a leading space, and when the next input byte is a space, the spaced variant is offered: the tag absorbs the space, the cursor moves past it, and the space is kept in the stripped output.
Three guards close failure modes that each produced plausible but wrong output rather than an error. (i) Markup may open or close only at a codepoint boundary. Without this rule, a span can close between the bytes of a single character, leaving two invalid fragments. (ii) The tags are plain text rather than special tokens, so a literal < in the input is the same token as the start of a tag. Where the input continues with <, no tag may open, and the bracket is copied rather than read as markup; this keeps a span from starting exactly at a literal bracket, which 2 of the roughly 19,200 gold spans in our data do. (iii) Zero-length spans are opt-in per label. A span whose label is in may close before any text is copied, and one whose label is in must; in MultiGEC, M is forced and every other label needs at least one character. So that empty spans cannot repeat without end, no two may close at the same position, and a forced span opened where an empty span has just closed copies text instead.
The copy cursor tracks the current input token and the byte offset inside it, and the trie is searched only with the rest of that token. A copied token can therefore end inside an input token, so every boundary stays reachable, but it never crosses into the next one: the copy keeps to the segmentation of the input that the model saw in its prompt.
Every answer token is admissible, so the answer is always a well-formed tagging of a prefix of x whose labels belong to L, and end-of-sequence becomes admissible only once all of x has been copied. The output therefore reproduces x exactly, unless the generation is cut off first by the token budget or by the dead-end fallback (Appendix E).
4.4 Two-Phase Reasoning-Aware Decoding
A processor that masks every step also masks the reasoning trace. As in Nguyen et al. (2026), who apply structured decoding only after a trigger to-ken, and CRANE (Banerjee et al., 2025), which switches a grammar constraint on and off at delimiters, we therefore decode in two phases: the model first reasons without constraint, and the constraint governs the answer from the family-specific marker that closes the reasoning block. One case needs attention. If the chat template leaves the reasoning opener to the model, the model may answer directly, and a processor waiting for the closing marker would leave the whole answer unconstrained; for such models, the first step admits the opener together with the constrained answer tokens.
The guarantee is therefore conditional: x is reproduced exactly whenever the model closes its reasoning. A model that exhausts the token budget or ends its turn while still reasoning leaves an empty answer, which is credited with no spans and counts toward the wrong-text rate; Table 7 in the appendix lists every such case.
4.5 Complexity
Building the trie is linear in the total byte length of the vocabulary and happens once per tokenizer. At each step, the prefix search is bounded by the length of the longest token, and the remaining checks take constant time or time linear in , so masking the vocabulary, , dominates. Over generated tokens, constrained decoding therefore costs , the same order as unconstrained decoding, and it does not depend on the length of the input.
5 Experiments and Results
Setup. We evaluate six open-weight models from three families: gemma-4-E2B-it and gemma-4-31B-it (Gemma Team, 2026), Qwen3-8B (Qwen Team, 2025) and Qwen3.8-27B (Qwen Team, 2026), and gpt-oss-20b and gpt-oss-120b (OpenAI, 2025), each with reasoning off where it can be switched off and four of them also with more reasoning. We sample with each vendor's recommended parameters and a budget of 18,000 new tokens, at batch size 1 and, on the two NER datasets, also at batch size 64, and report the mean over three seeds (Appendix A). Batch size 64 simulates a long document with many spans to find: unlike the usual sense of the term, the batch is not decoded in parallel, but its 64 sentences are concatenated into one input, with over a hundred entities on average, which the model copies and tags in a single generation.
Baselines. We compare constrained tagging ( ) against three baselines. Unconstrained tagging uses the same prompt and markup with the processor switched off; an output whose stripped text differs from the input cannot be located and is credited with no spans. Context-based prompting asks the model for a JSON list of spans, each with its label and a short context copied from the input, and locates each span by exact matching of its context. XGrammar (Dong et al., 2025) also enforces the JSON format and the set of labels using a grammar. Due to limited computational resources, context-based prompting was run for one model per family and XGrammar only with reasoning off (Appendix A).
Metrics. Our headline metric is the character-overlap F1 of Semin et al. (2026), computed with their implementation: hard F1 requires the predicted label to match, and soft F1 credits a span in the right place whatever its label. Overlap counts are pooled over all examples, so an example with empty gold and an empty prediction carries no weight, while spans predicted where the gold is empty still lower precision. This keeps the metric informative on Toxic Spans and LegalQAE-val, where half of the gold is empty, and the per-example character F1 of Pavlopoulos et al. (2021) reaches 50% for a model that never returns a usable span. UniversalNER and ESA-MT are macro-averaged over their subsets. The wrong-text rate is the share of generations whose stripped output is not the input.
5.1 Main Results
Table 2 gives the results on the six datasets. Constrained tagging is ahead of unconstrained tagging, with the same prompts, on five of the six datasets, and behind only on Toxic Spans (Table 6 in the appendix). The gain is largest where a model fails to copy its input: gemma-4-E2B-it rises from 11.3 to 56.4 hard F1 on CoNLL-2003, and gemma-4-31B-it from 36.3 to 50.7 on MultiGEC.
Against context-based prompting, the strongest baseline, constrained tagging is on par on average on LegalQAEval (+1.0) and ESA-MT (+0.1) and behind on the other four datasets. The gap is largest for the smallest model, gemma-4-E2B-it; without it, constrained tagging is ahead on every LegalQAEval arm, by up to 24.4 points for Qwen3.8-27B, and on three of four ESA-MT arms, and at medium effort gpt-oss-20b is ahead on four of the six datasets,
| CoNLL | Toxic Spans | LegalQAEval | UNER | ESA-MT | MultiGEC | |
|---|---|---|---|---|---|---|
| Constrained tagging (ours) | ||||||
| gamma-4-E2B-it (off) | 56.4 (76.7) | 13.2 | 11.2 | 58.6 (66.3) | 4.6 (9.8) | 8.2 (12.8) |
| gamma-4-31B-it (off) | 84.7 (94.6) | 25.3 | 55.5 | 88.7 (92.2) | 14.0 (34.0) | 50.7 (54.0) |
| Qwen3.8-27B (off) | 72.8 (81.5) | 17.4 | 41.8 | 59.8 (63.2) | 9.2 (22.8) | 24.5 (31.1) |
| Qwen3.8-27B (low) | 80.4 (88.5) | 20.0 | 51.8 | 54.4 (56.7) | 9.5 (25.9) | 49.9 (52.7) |
| gpt-oss-20b (low) | 69.9 (81.9) | 20.5 | 42.9 | 75.7 (80.4) | 12.9 (25.7) | 24.5 (28.1) |
| gpt-oss-120b (low) | 78.6 (89.6) | 20.6 | 47.9 | 79.5 (83.1) | 11.8 (28.2) | 31.8 (36.4) |
| Unconstrained tagging (same prompt, constraint off) | ||||||
| gamma-4-E2B-it (off) | 11.3 (14.1) | 28.7 | 2.1 | 22.2 (24.9) | 2.0 (5.0) | 0.7 (0.8) |
| gamma-4-31B-it (off) | 72.4 (81.7) | 24.9 | 56.0 | 84.5 (87.9) | 13.9 (34.1) | 36.3 (38.5) |
| Qwen3.8-27B (off) | 69.9 (78.6) | 23.3 | 46.4 | 60.7 (64.2) | 9.1 (22.3) | 31.1 (32.7) |
| Qwen3.8-27B (low) | 83.0 (90.9) | 21.2 | 52.9 | 70.6 (73.2) | 10.0 (25.1) | 46.2 (48.3) |
| gpt-oss-20b (low) | 59.8 (72.0) | 23.7 | 40.0 | 70.0 (73.4) | 10.2 (20.7) | 14.2 (15.3) |
| gpt-oss-120b (low) | 72.9 (83.9) | 21.9 | 46.8 | 77.9 (81.4) | 10.4 (24.3) | 17.6 (18.5) |
| Context-based prompting | ||||||
| gamma-4-E2B-it (off) | 71.5 (85.9) | 32.5 | 38.6 | 78.0 (82.9) | 6.5 (17.2) | 27.0 (29.0) |
| gamma-4-E2B-it (on) | 73.1 (85.9) | 29.5 | 40.3 | 83.9 (88.0) | 9.0 (20.1) | 33.9 (35.8) |
| Qwen3.8-27B (off) | 84.1 (92.5) | 20.4 | 17.4 | 86.9 (90.3) | 8.8 (20.7) | 40.1 (43.0) |
| Qwen3.8-27B (low) | 87.4 (95.7) | 28.4 | 33.5 | 89.4 (92.5) | 10.1 (26.4) | 51.6 (53.8) |
| gpt-oss-20b (low) | 73.3 (84.4) | 30.0 | 32.1 | 80.9 (85.0) | 11.1 (24.5) | 32.7 (34.9) |
Table 2: Hard F1 (soft F1 in parentheses) on the six datasets, mean over three seeds, batch size 1. Macro average over the 18 treebanks and the 24 files. The parenthesized arm is the reasoning setting. The best hard F1 per dataset is in bold, the second best in italics.
| UNER | MultiGEC | ESA-MT | |
|---|---|---|---|
| gamma-4-31B-it | |||
| Published tagging | 88.9 | 52.9 | 14.2 |
| Published LogitMatch | 89.2 | 41.7 | 13.1 |
| Ours, unconstrained | 84.7 | 36.3 | 13.9 |
| Ours, constrained | 88.8 | 50.7 | 14.0 |
| Qwen3-8B | |||
| Published tagging | 73.3 | 27.2 | 10.2 |
| Published LogitMatch | 73.3 | 17.4 | 11.2 |
| Ours, unconstrained | 62.2 | 13.8 | 13.3 |
| Ours, constrained | 70.2 | 15.7 | 13.6 |
Table 3: Hard F1 against the published tagging and LogitMatch results of Semin et al. (2026), reasoning off, recomputed from their released runs; ours over three seeds, theirs over five, UNER on the full test set. Per model, the best is in bold, the second best in italics.
including CoNLL-2003 and UniversalNER. Where constrained tagging stays behind, §5.3 traces the gap to which spans the model chooses, not to where they are. XGrammar changes the context-based results by at most 1.8 points in either direction: constraining the form of the output does not change what the model extracts. Standard deviations over seeds are at most 2.7 points for any constrained arm (Table 6 in the appendix).
Published results. Table 3 compares against Semin et al. (2026) on the two models evaluated by both works. With gemma-4-31B-it, constrained tagging matches their tagging results within 0.2 points on UniversalNER and ESA-MT, although our scoring of outputs that do not reproduce the input is stricter; on MultiGEC it is 2.2 points below their tagging but 9.0 points ahead of their constrained matching method, LogitMatch. With Qwen3-8B, it is ahead of both on ESA-MT and behind on the other two datasets.
| % | Context | XGr. | Unconstr. | Ours |
|---|---|---|---|---|
| Span not in input | 8.53 | 9.22 | — | 0 |
| Label not in set | 0.01 | 0.00 | — | 0 |
| Wrong text | — | — | 34.61 | 0.01 |
| Unusable output | 0.54 | 0.01 | 34.61 | 0.01 |
| No answer | 0.02 | — | 0.01 | 0.01 |
Table 4: Failure modes, averaged over the six datasets, on the arms run for every method. XGr.: XGrammar; Unconstr.: unconstrained tagging. Span and label rows are in % of proposed spans, the others in % of generations; No answer means the reasoning never closed.
5.2 The Verbatim Guarantee
Table 4 lists how each method fails. Under the constraint, a span that does not occur in the input and a label outside the label set cannot be produced, and a generation can fail only by not finishing its answer, either because it reaches the budget of 18,000 new tokens or because the model ends its turn while still reasoning. Of the 255,312 constrained generations, 56 (0.022%) failed: in the ten at batch size 1, the reasoning never closed, and of the 46 at batch size 64, 28 ran out of budget during the answer (Table 7 in the appendix). Without the constraint, the same prompts produce wrong text in 34.6% of generations, which then lose all of their spans, and context-based prompting returns 8.5% of its spans with a context that cannot be found in the input, 22.4% on LegalQAEval.
5.3 Where Accuracy Is Lost
The guarantee fixes span location, not span selection or classification, and these are where the remaining errors lie (Tables 8 and 9 in the appendix). Reproducing the whole input takes the model past every candidate, and at each one it must decide whether to open a span. It errs toward opening one: of the three methods, constrained tagging misses the fewest gold spans on every dataset, but it proposes more spans than context-based prompting on five of the six and longer ones on all six, 138 characters on LegalQAEval against 63 in the gold. The recall is paid for in precision, since fewer of its spans are exact on five datasets and more are spurious or misdelimited: on CoNLL-2003, 12.8% of its spans have the right label but wrong boundaries, compared to 3.7% for context-based prompting. The constraint thus removes errors in reproducing the input but leaves errors in judging which text is a span, and no constraint on the output can remove those. The same holds for labels: 31.7% of the correctly delimited ORG spans of CoNLL-2003 are labeled LOC, and on ESA-MT 71.8% of the MINOR errors are labeled MAJOR, which is why hard F1 there is a fraction of soft F1 (14.0 against 34.0 for gemma-4-31B-it).
5.4 Effect of Reasoning
More reasoning improves the hard F1 averaged over the six datasets for every model, by 2.6 to 6.7 points, but not on every dataset (Table 10 in the appendix): the largest gain of each model is on MultiGEC for Qwen3.8-27B (+25.4), on CoNLL-2003 for gemma-4-E2B-it (+11.6) and on UniversalNER for gpt-oss-20b and gpt-oss-120b (+10.5 and +9.8), while gpt-oss loses on Toxic Spans (-3.5 and -1.7) and Qwen3.8-27B on UniversalNER (-5.4). The cost is high: gpt-oss-20b spends 1,290 reasoning tokens per generation at medium effort against 207 at low (Fig. 6 in the appendix). Under the two-phase processor, reasoning fails to close in at most 0.13% of an arm's generations at batch size 1, but in up to 5.5% at batch size 64.
5.5 Cost and Batch Size
The constraint itself costs nothing measurable: constrained and unconstrained tagging, run in the same jobs, generate 19.5 and 19.4 tokens per second averaged over all models and datasets. Tagging pays instead for reproducing the whole input. Without reasoning, it is therefore slower than context-based prompting where a long input holds few spans, as in Toxic Spans and LegalQAEval with 0.6 and 0.5 spans per example (Table 1), and faster on MultiGEC, where 14 spans per essay make the list of spans the longer output (Appendix B.1). Batch size 64 strains both methods (Tables 11 and 12 in the appendix): most models propose fewer spans, and recall falls. With gemma-4-E2B-it and gpt-oss-20b, constrained tagging keeps more of the gold spans on UniversalNER than context-based prompting, which recovers as little as 17.6% of them, and for gpt-oss-20b this makes it the more accurate method at batch size 64 (43.2 against 23.5 hard F1 at low effort, 53.7 against 44.5 at medium). For gemma-4-E2B-it the extra spans are mostly wrong, and on CoNLL-2003 its hard F1 drops from 56.4 to 8.5, against 50.5 for context-based prompting.
6 Conclusion
We presented constrained tagging, a training-free decoding method that guarantees by construction that every span a generative LLM returns is a verbatim part of the input with a label from the given set. The guarantee held in all but 0.022% of 255,312 generations and pays off where text-based localization breaks down: with the same prompts, it raises hard F1 over unconstrained tagging by up to 45 points, it never loses a span it proposes, whereas context-based prompting loses up to 22% on long passages, and it matches context-based prompting on legal question answering and translation error detection. Because tagging marks spans in place, it suits densely annotated text: on MultiGEC, with 14 spans per essay, its output is shorter than a list of spans, and with gemma-4-31B-it it is 9.0 points ahead of a published constrained matching method. Of the three methods, it also misses the fewest gold spans on every dataset, which is what matters when a model proposes spans for a human annotator to accept or reject. Its remaining errors concern which spans the model chooses, which better prompts or light fine-tuning may reduce without touching the guarantee.
Limitations
The guarantee is conditional. Constrained tagging reproduces the input exactly only if the model closes its reasoning and finishes its answer within the token budget. Reasoning effort and batch size therefore have to be chosen with the budget in mind, and a failed generation yields no spans at all.
The guarantee does not choose better spans. Constrained tagging removes spans that cannot be located, but on four of the six datasets context-based prompting with the same models is more accurate ( ). The verbatim guarantee concerns where the predicted spans are, not whether they are the right spans with the right labels; the errors that remain are analyzed in .
Logit access is required. The processor masks the logits at every decoding step, so it needs a model whose decoding loop can be modified. It cannot be applied through a chat API that returns only text, whereas the context-based baseline can.
The cost grows with the input. Tagging regenerates the whole input, so the length of its answer grows with the input rather than with the number of spans. Without reasoning, it therefore generates 3.6 times as many tokens as context-based prompting on LegalQAEval, whose long passages hold few answer spans. With reasoning, both methods also generate a reasoning trace, which narrows the ratio to 1.3. The constraint itself adds no measurable decoding cost ( ).
Sampling and statistical power. CoNLL-2003 and UniversalNER are subsampled to 1,152 sentences and 250 examples per treebank, drawn uniformly at random and re-drawn per seed, so their standard deviations include subsampling variance. All results are means over three seeds. This is enough to separate the large differences we report, but no significance tests were run, and differences of a point or two between two arms should not be read as established.
Not every configuration was run. Due to computation, the prompting baselines were run for one model per family and XGrammar only with reasoning off; gemma-4-31B-it and Qwen3-8B were run with reasoning off only; and gpt-oss cannot switch reasoning off at all, so its reasoning comparison is between two efforts. The Whole-Sequence processor was evaluated only in earlier experiments with smaller models, and no fine-tuned model was trained; that light fine-tuning could close the gap to task-specific encoders is a hypothesis we did not test.
Inherited data conventions. Gold spans, label sets, and averaging follow the released benchmarks, including the subset-level macro averages of UniversalNER and ESA-MT, the empty gold of half of Toxic Spans and LegalQAEval, and 19 zero-length MultiGEC spans that lie one character past the end of their text and cannot be reached by any method. We kept them so that our results stay comparable with published ones. Inputs are NFC-normalized, so the verbatim guarantee holds relative to that normal form.
Prompts and coverage. Each dataset uses one English system prompt, the same for every model, written once and not tuned per model, and the results may change with other prompts. The evaluation covers five tasks and 18 languages in five scripts, which shows breadth, not universality.
Contamination. All six datasets are public, and the models were pre-trained on web text after their release, so we cannot exclude that test data was seen during pre-training. This affects all methods compared here alike, but it may inflate the absolute scores.
Ethics Statement
Data and licences. All six datasets are public and were used only for research evaluation; no model was trained on them, and no new annotation was collected. CoNLL-2003 annotates Reuters news stories, which are copyrighted and distributed for research under the Reuters Corpus agreement; we used the copy on the Hugging Face Hub. Toxic Spans is released under CC0. LegalQAEval is released under CC BY-SA 4.0 and inherits the terms of its sources, including the non-commercial terms of MS MARCO. The UniversalNER treebanks are licensed individually: twelve under CC BY-SA 4.0, the five PUD treebanks under CC BY-SA 3.0, and Tagalog-Ugnayan under CC BY-NC-SA 4.0. The WMT24 data are released for research use, and we read the error-span sample from the repository of Kasner et al. (2026), released under the MIT license. The English Write & Improve 2024 corpus behind MultiGEC is provided by Cambridge University Press & Assessment under a license for non-commercial research and education that forbids redistribution; we acknowledge the licensor here, and our released code does not include the corpus: users obtain it from the licensor, and our scripts convert it. The character-overlap metric of Semin et al. (2026) is imported from their public repository at a pinned commit and not redistributed, because that repository does not carry a license. All six models are released under the Apache 2.0 license, subject to their providers' usage policies, and our use is consistent with these terms.
Offensive and personal content. Toxic Spans consists, by construction, of toxic user comments, and its system prompts, released with our code, quote two short examples of such language, one of them an insult aimed at a public figure. We did not process personal data beyond what the published datasets contain.
Intended use and risks. We propose constrained tagging as an assistant to human annotators, not as an autonomous labeler. It guarantees that every predicted span is a verbatim part of the input with a valid label; it is not a guarantee that the spans or labels are correct. A user who reads the verbatim guarantee as a correctness guarantee would trust wrong labels and boundaries, which remain common ( ), so outputs used for consequential decisions, for example, in legal question answering, should be reviewed by a person.
Compute. The experiments used about 4,300 GPU-hours, including pilot runs and failed jobs (Appendix A).
Acknowledgments
The access to the computational infrastructure of the OP VVV funded project CZ.02.1.01/0.0/0.0/16_019/0000765 “Research Center for Informatics” is gratefully acknowledged. We used an AI assistant (Claude) to write analysis and plotting code, to adapt the authors’ own earlier write-up into paper sections, to draft some passages that the authors then revised, for language editing, and to verify citations; the authors checked all content and take full responsibility for it.
References
Dhananjay Ashok and Zachary C. Lipton. 2023. PromptNER: Prompting for named entity recognition. Computing Research Repository, arXiv:2305.15444.
Debangshu Banerjee, Tarun Suresh, Shubham Ugare, Sasa Misailovic, and Gagandeep Singh. 2025. CRANE: Reasoning with constrained LLM generation. In Proceedings of the 42nd International Conference on Machine Learning.
Christopher Bryant, Mariano Felice, and Ted Briscoe. 2017. Automatic annotation and evaluation of error types for grammatical error correction. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 793–805, Vancouver, Canada. Association for Computational Linguistics.
Umar Butler. 2025. LegalQAEval.
Nicola De Cao, Gautier Izacard, Sebastian Riedel, and Fabio Petroni. 2021. Autoregressive entity retrieval. In International Conference on Learning Representations.
Tobias Deußer, Lars Hillebrand, Christian Bauckhage, and Rafet Sifa. 2023. Informed named entity recognition decoding for generative language models. Computing Research Repository, arXiv:2308.07791.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics.
Yifan Ding, Michael Yankoski, and Tim Weninger. 2024. Span-oriented information extraction – a unifying perspective on information extraction. Computing Research Repository, arXiv:2403.15453.
Yixin Dong, Charlie F. Ruan, Yaxing Cai, Ruihang Lai, Ziyi Xu, Yilong Zhao, and Tianqi Chen. 2025. XGrammar: Flexible and efficient structured generation engine for large language models. In Proceedings of the 8th Conference on Machine Learning and Systems (MLSys).
David Dukić and Jan Šnajder. 2024. Looking right is sometimes right: Investigating the capabilities of decoder-only LLMs for sequence labeling. In Findings of the Association for Computational Linguistics: ACL 2024, pages 14168–14181, Bangkok, Thailand. Association for Computational Linguistics.
Edward Fredkin. 1960. Trie memory. Commun. ACM, 3(9):490–499.
Gemma Team. 2026. Gemma 4 technical report. Preprint, arXiv:2607.02770.
Saibo Geng, Martin Josifoski, Maxime Peyrard, and Robert West. 2023. Grammar-constrained decoding for structured NLP tasks without finetuning. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 10932–10952, Singapore. Association for Computational Linguistics.
Guidance AI. 2024. llguidance: Super-fast structured outputs. https://github.com/guidance-ai/llguidance.
Zdeněk Kasner, Vilém Zouhar, Patrícia Schmidtová, Ivan Kartáč, Kristýna Onderková, Ondrej Platek, Dimitra Gkatzia, Saad Mahamood, Ondrej Dusek, and Simone Balloccu. 2026. LLMs as span annotators: A comparative study of LLMs and humans. In Proceedings of the First Workshop on Multilingual Multicultural Evaluation, pages 1–22, Rabat, Morocco. Association for Computational Linguistics.
Imed Keraghel, Stanislas Morbieu, and Mohamed Nadif. 2024. Recent advances in named entity recognition: A comprehensive survey and comparative study. Computing Research Repository, arXiv:2401.10825.
Tom Kocmi, Eleftherios Avramidis, Rachel Bawden, Ondřej Bojar, Anton Dvorkovich, Christian Federmann, Mark Fishel, Markus Freitag, Thamme Gowda, Roman Grundkiewicz, Barry Haddow, Marzena Karpinska, Philipp Koehn, Benjamin Marie, Christof Monz, Kenton Murray, Masaaki Nagata, Martin Popel, Maja Popović, and 3 others. 2024a. Findings of the WMT24 general machine translation shared task: The LLM era is here but MT is not solved yet. In Proceedings of the Ninth Conference on Machine Translation, pages 1–46, Miami, Florida, USA. Association for Computational Linguistics.
Tom Kocmi, Vilém Zouhar, Eleftherios Avramidis, Roman Grundkiewicz, Marzena Karpinska, Maja Popović, Mrinmaya Sachan, and Mariya Shmatova. 2024b. Error span annotation: A balanced approach for human evaluation of machine translation. In Proceedings of the Ninth Conference on Machine Translation, pages 1440–1453, Miami, Florida, USA. Association for Computational Linguistics.
Taku Kudo and John Richardson. 2018. SentencePiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 66–71, Brussels, Belgium. Association for Computational Linguistics.
Peng Li, Tianxiang Sun, Qiong Tang, Hang Yan, Yuanbin Wu, Xuanjing Huang, and Xipeng Qiu. 2023. CodeIE: Large code generation models are better few-shot information extractors. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 15339–15353, Toronto, Canada. Association for Computational Linguistics.
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis,
Luke Zettlemoyer, and Veselin Stoyanov. 2019. RoBERTa: A robustly optimized BERT pretraining approach. Computing Research Repository, arXiv:1907.11692.
Arianna Masciolini, Andrew Caines, Orphée De Clercq, Joni Kruijsbergen, Murathan Kurfali, Ricardo Muñoz Sánchez, Elena Volodina, and Robert Östling. 2025. The MultiGEC-2025 shared task on multilingual grammatical error correction at NLP4CALL. In Proceedings of the 14th Workshop on Natural Language Processing for Computer Assisted Language Learning, pages 1–33, Tallinn, Estonia. University of Tartu Library.
Stephen Mayhew, Terra Blevins, Shuheng Liu, Marek Šuppa, Hila Gonen, Joseph Marvin Imperial, Börje F. Karlsson, Peiqin Lin, Nikola Ljubešić, LJ Miranda, Barbara Plank, Arij Riabi, and Yuval Pinter. 2024. Universal NER: A gold-standard multilingual named entity recognition benchmark. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pages 4322–4337, Mexico City, Mexico. Association for Computational Linguistics.
Ngoc Trinh Hung Nguyen, Alonso Silva, Laith Zumot, Liubov Tupikina, Armen Aghasaryan, and Mehwish Alam. 2026. Thinking before constraining: A unified decoding framework for large language models. Computing Research Repository, arXiv:2601.07525.
Diane Nicholls, Andrew Caines, and Paula Buttery. 2024. The Write & Improve Corpus 2024: Error-annotated and CEFR-labelled essays by learners of English. Cambridge University Press & Assessment.
OpenAI. 2025. gpt-oss-120b & gpt-oss-20b model card. Computing Research Repository, arXiv:2508.10925.
John Pavlopoulos, Leo Laugier, Alexandros Xenos, Jeffrey Sorensen, and Ion Androutsopoulos. 2022. From the detection of toxic spans in online discussions to the analysis of toxic-to-civil transfer. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3721–3734, Dublin, Ireland. Association for Computational Linguistics.
John Pavlopoulos, Jeffrey Sorensen, Léo Laugier, and Ion Androutsopoulos. 2021. SemEval-2021 task 5: Toxic spans detection. In Proceedings of the 15th International Workshop on Semantic Evaluation (SemEval-2021), pages 59–69, Online. Association for Computational Linguistics.
Qwen Team. 2025. Qwen3 technical report. Computing Research Repository, arXiv:2505.09388.
Qwen Team. 2026. Qwen3.8-Max: A new bar for coding and cowork.
Danil Semin, Ondřej Dušek, and Zdeněk Kasner. 2026. Strategies for span labeling with large language models. Computing Research Repository, arXiv:2601.16946.
Rico Sennrich, Barry Haddow, and Alexandra Birch. 2016. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1715–1725, Berlin, Germany. Association for Computational Linguistics.
Erik F. Tjong Kim Sang and Fien De Meulder. 2003. Introduction to the CoNLL-2003 shared task: Language-independent named entity recognition. In Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pages 142–147.
Shuhe Wang, Xiaofei Sun, Xiaoya Li, Rongbin Ouyang, Fei Wu, Tianwei Zhang, Jiwei Li, Guoyin Wang, and Chen Guo. 2025. GPT-NER: Named entity recognition via large language models. In Findings of the Association for Computational Linguistics: NAACL 2025, pages 4257–4275, Albuquerque, New Mexico. Association for Computational Linguistics.
Xiao Wang, Weikang Zhou, Can Zu, Han Xia, Tianze Chen, Yuansen Zhang, Rui Zheng, Junjie Ye, Qi Zhang, Tao Gui, Jihua Kang, Jingsheng Yang, Siyuan Li, and Chunsai Du. 2023. InstructUIE: Multi-task instruction tuning for unified information extraction. Computing Research Repository, arXiv:2304.08085.
Brandon T. Willard and Rémi Louf. 2023. Efficient guided generation for large language models. Computing Research Repository, arXiv:2307.09702.
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, and 3 others. 2020. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45, Online. Association for Computational Linguistics.
Derong Xu, Wei Chen, Wenjun Peng, Chao Zhang, Tong Xu, Xiangyu Zhao, Xian Wu, Yefeng Zheng, Yang Wang, and Enhong Chen. 2024. Large language models for generative information extraction: A survey. Frontiers of Computer Science.
Wenzheng Zhang, Sam Wiseman, and Karl Stratos. 2023. Seq2seq is all you need for coreference resolution. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 11493–11504, Singapore. Association for Computational Linguistics.
Wenxuan Zhou, Sheng Zhang, Yu Gu, Muhao Chen, and Hoifung Poon. 2024. UniversalNER: Targeted distillation from large language models for open named entity recognition. In International Conference on Learning Representations.
| Model | Parameters | Reasoning arms |
|---|---|---|
| gamma-4-E2B-it | 4.6B (2.3B eff.) | off, on |
| gamma-4-31B-it | 30.7B | off |
| Qwen3-8B | 8.2B | off |
| Qwen3.8-27B | 27B | off, low |
| gpt-oss-20b | 20.9B (3.6B act.) | low, medium |
| gpt-oss-120b | 116.8B (5.1B act.) | low, medium |
Table 5: Evaluated models, with the parameters of the language model only, without vision or audio encoders. The Gemma and Qwen models are dense; gpt-oss is a mixture of experts. eff.: effective parameters (per-layer embeddings excluded); act.: parameters active per token. gpt-oss cannot switch reasoning off, so its arms are reasoning efforts.
A Experimental Setup
Models. Table 5 gives the sizes of the six models of §5 and their reasoning settings. gemma-4-E2B-it is additionally run with reasoning on, and Qwen3.8-27B with low reasoning effort; gpt-oss cannot switch reasoning off and is run at low and medium effort. gemma-4-31B-it and Qwen3-8B are run with reasoning off only, the setting of the published numbers we compare against.
Decoding. All runs sample with the parameters each vendor recommends: temperature 1.0, top-p 0.95 and top-k 64 for Gemma; temperature 0.6, top-p 0.95 and top-k 20 for Qwen with reasoning, and 0.7, 0.8 and 20 without it; temperature 1.0 and no truncation for gpt-oss. No repetition penalty is applied. The budget is 18,000 new tokens per generation. Every dataset is evaluated at batch size 1, and the two NER datasets also at batch size 64, where the 64 sentences of a batch are tagged in one generation. Constrained and unconstrained tagging use the same system prompt and differ only in whether the processor is attached; both decoding modes of an arm run in the same job on the same hardware.
Seeds. Every configuration is run with seeds 42, 43, and 44, and every reported number is the mean over the three, with the standard deviation over seeds as the error. The seed fixes both the decoding and, on CoNLL-2003 and UniversalNER, the evaluation subsample ( ).
Baselines. The context-based prompt asks for a JSON list of spans, each with its label and a short surrounding context copied from the input (four to eight words; three to eight on Toxic Spans), using the same task description as the tagging prompt; a deterministic algorithm locates each span by exact matching of its context in the input. The XGrammar (Dong et al., 2025) variant enforces the same JSON schema and the label set with a grammar. Context-based prompting was run for one model per family (gamma-4-E2B-it, Qwen3.8-27B, and gpt-oss-20b), and XGrammar with reasoning off only, for gamma-4-E2B-it and Qwen3.8-27B.
Evaluation. Hard and soft F1 are computed with the metrics.py of Semin et al. (2026), imported unmodified from their public repository at a pinned commit rather than reimplemented. UniversalNER and ESA-MT are scored per treebank and per file, and the subset scores are macro-averaged.
Infrastructure. The models run with Hugging Face Transformers 5.14 (Wolf et al., 2020) and PyTorch 2.10 in bfloat16; gpt-oss uses its native MXFP4 quantization. Constrained and unconstrained tagging and context-based baselines were run on NVIDIA H200 GPUs (141 GB), with several copies of a model sharing one GPU to increase throughput; XGrammar 0.2.8 ran on NVIDIA A100 GPUs (40 GB), except for Qwen3.8-27B on UniversalNER, which ran on H200 GPUs. Including pilot runs and failed jobs, the experiments used about 4,300 GPU-hours between August and October 2026, 58% of them on H200 GPUs and the rest on A100 GPUs; the constrained-tagging results reported here all come from the H200 runs.
B Additional Analysis
B.1 Runtime
Because constrained and unconstrained tagging generate tokens at the same rate ( ), their times differ only where their outputs differ in length. The largest relative gap, gemma-4-E2B-it without reasoning on LegalQAEval (15.6 against 2.7 seconds), comes from the unconstrained outputs, which stop after 32 tokens on average, and 99% of which do not reproduce the passage.
Across models, the time is set less by model size than by how long the model reasons (Fig. 5). Without reasoning, gemma-4-31B-it is the fastest at 5.0 seconds per generation averaged over the datasets, ahead of Qwen3.8-27B (7.1), Qwen3-8B (8.2) and gemma-4-E2B-it (9.9). Throughput per process depends on how many copies of a model share a GPU: the small models ran many copies per GPU, each slower, so gemma-4-E2B-it generates 12.0 tokens per second against 25.7 for gemma-4-31B-it. Reasoning multiplies the time per generation by 7.6 for gemma-4-E2B-it (75.7 seconds with reasoning on) and by 5.5 for Qwen3.8-27B at low effort (38.6 seconds), and medium effort multiplies the time of low effort by 3.8 for gpt-oss-20b (73.7 seconds) and by 2.7 for gpt-oss-120b (42.1 seconds). Multi-GEC, whose essays are the longest inputs, is the slowest dataset for every arm except Qwen3-8B, up to 266 seconds per generation for gpt-oss-20b at medium effort. With reasoning, a single generation can take from under a second to more than 2,000 seconds, when the reasoning runs toward the token budget.
Against the context-based baseline (Fig. 3), constrained tagging is slower without reasoning on Toxic Spans, LegalQAEval, and ESA-MT, where it copies a long input to mark a few spans, and faster on MultiGEC, where the list of spans is longer than the essay; on the two NER datasets, the two are close. With reasoning, the reasoning dominates both, and neither method is consistently faster. Both ran on H200 GPUs, but as separate jobs with a different number of copies per GPU, so the comparison is indicative; the number of generated tokens does not depend on the hardware (Fig. 4). More time does not buy accuracy uniformly (Fig. 5): gemma-4-31B-it without reasoning has both the lowest time and the highest hard F1 averaged over the datasets.
B.2 Reasoning
Table 10 breaks the effect of reasoning down by dataset. Under constrained tagging, the gain is uneven: it is largest on MultiGEC for Qwen3.8-27B and on UniversalNER for gpt-oss, and it turns negative on Toxic Spans for gpt-oss and on UniversalNER for Qwen3.8-27B. Fig. 6 shows where the generated tokens go: the answer is nearly constant within a dataset, and everything above it is reasoning.
B.3 Failures
Table 7 accounts for every constrained generation whose output differs from its input. None is a copying error: either the model never closed its reasoning, so there was no answer for the constraint to govern, or, at batch size 64, the token budget ran out while the answer was being copied, which leaves a correct but incomplete copy.
Constrained tagging
Context-based

Qwen3.8-27B, off
Qwen3.8-27B, low
gpt-oss-20b, low
gpt-oss-20b, medium
Figure 3: Seconds per generation of constrained tagging and the context-based baseline on the arms run for the baseline, mean over three seeds at batch size 1, all on H200 GPUs.
C Additional Tables
Table 6 gives every arm of every method with its standard deviation over seeds, and the averages over the arms run with all three methods that §5.1 quotes. Table 7 lists the failed constrained generations by cause, and Tables 8 and 9 decompose the span and label errors discussed in §5.3. Table 10 compares the reasoning settings, and Tables 11 and 12 compare batch sizes 1 and 64.
D System Prompts
Every prompt follows one structure: a task description, the label set with a definition of each label, the output format, a list of rules, and one or two worked examples. Listing 1 gives the complete tagging prompt for CoNLL-2003, used for both constrained and unconstrained tagging, and Table 13 lists what changes for the other datasets. Each context-based prompt keeps the task description, labels and examples of the tagging prompt for the same dataset, with the examples written as JSON, and replaces its output format and rules with those of Listing 2; the context is four to eight words long, three to eight on Toxic Spans. All twelve prompts are released verbatim with our code. Placeholders in braces are filled per example.
Listing 1: Tagging prompt for CoNLL-2003.
You are an expert at named entity recognition. Given an input text, identify all named entities and return the SAME text with inline entity markup.
Do not extract nested entities, only the outermost ones.
IMPORTANT: If an entity appears multiple times, tag each occurrence.
The possible labels for named entities are:
PER: names of people (different languages, nicknames, usernames, fictional characters, titles with names, etc.)
LOC: names of cities, countries, landmarks, geographical features, addresses, etc.
ORG: names of companies, institutions, agencies, sport teams, etc.
Constrained tagging Context-based

Qwen3.8-27B, off
Qwen3.8-27B, low
gpt-oss-20b, low
gpt-oss-20b, medium
Figure 4: Tokens per generation, reasoning included, of constrained tagging and the context-based baseline on the same arms as Fig. 3; mean over three seeds at batch size 1. Unlike time, the token count does not depend on the hardware.
MISC: everything else that can be considered a named entity (events, works of art, nationalities, religions, languages, etc.)
The order of labeling is PER, LOC, ORG, MISC.
Output format:
Return ONLY the input text with each entity wrapped exactly like this:
<SPAN><LABEL>LABEL</LABEL>ENTITY_TEXT</SPAN>
Rules:
-
Do not add, remove, or reorder any characters from the original input text, except for inserting the tags.
-
ENTITY_TEXT must exactly match the original substring from the input text.
-
Do not output explanations, or any additional text!!
-
Do not tag anything that is not one of the labels above.
-
Do not create overlapping spans; when ambiguous, choose the outermost entity.
Examples:
Input text:
Barack Obama was born in Hawaii. Barack was american.
Output text:
<SPAN><LABEL>PER</LABEL>Barack Obama</SPAN> was born in <SPAN><LABEL>LOC</LABEL>Hawaii</SPAN>. <SPAN><LABEL>PER</LABEL>Barack</SPAN> was american.
Input text:
He ended the World Cup on the wrong note, Coste said.
Output text:
He ended the <SPAN><LABEL>MISC</LABEL>World Cup</SPAN> on the wrong note, <SPAN><LABEL>PER</LABEL>Coste</SPAN> said.
Listing 2: Output format and rules of the context-based prompt for CoNLL-2003.
Output format:
Return ONLY a JSON array of objects, each exactly like this:
[
{ "entity": "ENTITY_TEXT", "label": "LABEL", "context": "SURROUNDING_CONTEXT" }
]
Rules:
-
"entity" must exactly match the original substring from the input text.
-
"label" must be one of the labels above.
-
"context" must be a short snippet (4-8 words) copied exactly from the input text that contains the entity and a few neighbouring words.
-
The entity must be contained in the context snippet.
-
If the entity is at the beginning or end of the text, use only the available neighbouring words.
-
Do not output explanations, or any additional text!!
-
Do not tag anything that is not one of the labels above.
-
Do not create overlapping spans; when ambiguous, choose
reasoning off low / model default medium

LegalQAEval
seconds per generation (log)
UNER
seconds per generation (log)
ESA-MT
seconds per generation (log)
GEC
seconds per generation (log)
Figure 5: Hard F1 against seconds per generation under constrained tagging, one point per model and reasoning setting (batch size 1, log scale); the error bars are the standard deviation over seeds.
the outermost entity.
- If there are no named entities, output an empty JSON array [].
E Processor Details
Two implementation details complete the processor of §4.3. The end-of-sequence set is the union of the tokenizer's and the model's end tokens and the family's end-of-turn tokens, because admitting one while generation stops only on another runs every example to the token budget. If the admissible set is ever empty, the processor admits end-of-sequence rather than sampling from a row of .
We implemented two variants of the processor, which differ only in how the copy cursor moves. Token-Aware, used in all experiments, tracks the current input token and the byte offset inside it and searches the trie only with the rest of that token, so a copied token never crosses from one input token into the next. Whole-Sequence keeps a single byte pointer into x and searches the trie with all of the remaining input, so a copied token may cover the end of one input token together with the start of the next. Both reach every boundary, including those inside a token. In earlier experiments with three smaller instruction-tuned models, Token-Aware was ahead on CoNLL-2003 for every model at every batch size, and the gap widened with the batch size; on Toxic Spans and LegalQAEval the two were within the seed spread of each other (Fig. 7). We therefore use Token-Aware throughout.
F Algorithms
Pseudocode for building the byte-level token trie and searching it ( ), taken from the implementation; each caption names the function it describes.
Algorithm 1: Byte-level token trie construction (build_toktrie_from_tokenizer)
Input: tokenizer with vocabulary V and decoder D Output: trie T, whose nodes map a byte to a child node and store the ids of the tokens ending there; map token_bytes: token id → bytes
1 // Decide the vocabulary family ONCE, from the decoder. 2 byte_level ← (D is, or contains, a ByteLevel decoder); 3 inverse of bytes_to_unicode(); // printable character → the raw byte it stands for 4 a trie holding only its root node; 5 foreach token id do 6 s ← convert_ids_to_tokens; 7 if byte_level then 8 , or UTF8(s) if some ; // added special tokens are plain strings 9 else if s has the form <0xNN> then 10 the single byte NN; // SentencePiece byte fallback 11 else 12 UTF8(s with the word-boundary marker U+2581 replaced by a space); 13 end 14 token_bytes[u] ← b; 15 i ← root; 16 for to |b| do 17 if i has no child for byte then create a node j and add the edge ; 18 child(i, ); 19 end 20 append u to token_ids(i); 21 end 22 return , token_bytes;
Algorithm 2: Trie prefix search (prefix_search)
Input: remaining input bytes , trie T Output: set A of the ids of every token whose bytes are a prefix of
1 root; ; 2 for to m do 3 if i has no child for byte then break; 4 child( ); 5 token_ids( ); 6 end 7 return A;
answer reasoning

Qwen3-8B, off
Qwen3.8-27B, off
Qwen3.8-27B, low
gpt-oss-20b, low
gpt-oss-20b, medium
gpt-oss-120b, low
gpt-oss-120b, medium
Figure 6: Generated tokens per generation under constrained tagging, split into reasoning and answer, for every model and reasoning setting (batch size 1). The answer is a copy of the input plus tags and is nearly constant within a dataset; everything above it is reasoning.
| Model | Reasoning | CoNLL | Toxic Spans | LegalQAEval | UNER | ESA-MT | MultiGEC |
|---|---|---|---|---|---|---|---|
| Constrained tagging (ours) | |||||||
| gamma-4-E2B-it | off | 56.39 ±0.64 | 13.24 ±0.57 | 11.25 ±0.35 | 58.58 ±0.59 | 4.60 ±0.95 | 8.25 ±0.73 |
| on | 68.00 ±0.79 | 13.39 ±1.03 | 10.91 ±0.42 | 64.29 ±0.52 | 7.80 ±1.41 | 8.89 ±0.67 | |
| gamma-4-31B-it | off | 84.69 ±0.13 | 25.30 ±0.19 | 55.55 ±0.34 | 88.68 ±0.14 | 13.96 ±0.16 | 50.65 ±1.41 |
| Qwen3-8B | off | 63.44 ±0.31 | 28.74 ±0.33 | 19.64 ±0.74 | 70.30 ±0.35 | 13.62 ±0.07 | 15.71 ±0.35 |
| Qwen3.8-27B | off | 72.76 ±0.09 | 17.41 ±0.68 | 41.81 ±2.19 | 59.78 ±0.89 | 9.19 ±1.04 | 24.54 ±0.89 |
| low | 80.39 ±0.57 | 20.02 ±0.51 | 51.75 ±0.88 | 54.36 ±0.62 | 9.46 ±0.36 | 49.92 ±0.18 | |
| gpt-oss-20b | low | 69.90 ±1.04 | 20.51 ±1.01 | 42.94 ±1.29 | 75.72 ±1.36 | 12.87 ±0.12 | 24.54 ±0.82 |
| medium | 74.73 ±0.49 | 17.02 ±0.25 | 47.89 ±1.25 | 86.20 ±0.20 | 13.45 ±0.41 | 32.17 ±1.10 | |
| gpt-oss-120b | low | 78.55 ±0.46 | 20.57 ±0.79 | 47.92 ±2.00 | 79.52 ±0.79 | 11.82 ±0.80 | 31.76 ±2.71 |
| medium | 79.69 ±0.73 | 18.91 ±0.61 | 52.81 ±1.83 | 89.27 ±0.30 | 12.31 ±0.72 | 32.94 ±1.17 | |
| Unconstrained tagging | |||||||
| gamma-4-E2B-it | off | 11.31 ±3.07 | 28.66 ±0.53 | 2.05 ±1.11 | 22.18 ±0.63 | 2.00 ±0.39 | 0.70 ±0.27 |
| on | 47.64 ±0.40 | 27.62 ±0.80 | 2.33 ±1.32 | 69.41 ±0.19 | 4.89 ±1.13 | 10.32 ±1.22 | |
| gamma-4-31B-it | off | 72.39 ±0.18 | 24.89 ±0.77 | 55.96 ±0.45 | 84.54 ±0.25 | 13.89 ±0.40 | 36.25 ±0.86 |
| Qwen3-8B | off | 59.07 ±1.37 | 32.62 ±0.38 | 17.93 ±0.76 | 62.54 ±0.13 | 13.35 ±0.77 | 13.77 ±0.25 |
| Qwen3.8-27B | off | 69.89 ±0.15 | 23.31 ±1.06 | 46.40 ±0.76 | 60.69 ±0.42 | 9.15 ±0.52 | 31.14 ±0.74 |
| low | 83.01 ±0.59 | 21.25 ±0.27 | 52.94 ±0.91 | 70.63 ±0.90 | 9.99 ±0.39 | 46.17 ±1.25 | |
| gpt-oss-20b | low | 59.79 ±2.97 | 23.74 ±0.96 | 40.01 ±0.89 | 70.03 ±0.35 | 10.16 ±0.63 | 14.17 ±0.96 |
| medium | 70.98 ±0.56 | 20.34 ±0.28 | 50.35 ±0.96 | 83.18 ±0.56 | 10.79 ±0.46 | 26.61 ±2.26 | |
| gpt-oss-120b | low | 72.91 ±1.00 | 21.93 ±0.80 | 46.81 ±1.81 | 77.88 ±0.53 | 10.35 ±1.51 | 17.56 ±0.91 |
| medium | 78.69 ±0.54 | 19.18 ±0.44 | 54.21 ±0.52 | 87.81 ±0.15 | 9.88 ±0.19 | 31.31 ±1.28 | |
| Context-based prompting | |||||||
| gamma-4-E2B-it | off | 71.47 ±0.30 | 32.54 ±0.92 | 38.56 ±0.44 | 78.03 ±0.26 | 6.46 ±0.55 | 26.98 ±0.52 |
| on | 73.06 ±0.44 | 29.53 ±0.67 | 40.30 ±1.52 | 83.93 ±0.48 | 8.97 ±1.10 | 33.93 ±0.18 | |
| Qwen3.8-27B | off | 84.12 ±0.47 | 20.38 ±0.97 | 17.40 ±0.36 | 86.95 ±0.15 | 8.77 ±0.60 | 40.15 ±0.55 |
| low | 87.37 ±0.16 | 28.41 ±0.58 | 33.46 ±0.52 | 89.43 ±0.41 | 10.14 ±0.57 | 51.58 ±0.22 | |
| gpt-oss-20b | low | 73.25 ±0.52 | 30.05 ±0.36 | 32.15 ±0.72 | 80.94 ±0.23 | 11.09 ±1.14 | 32.66 ±0.18 |
| medium | 73.13 ±0.29 | 26.43 ±0.33 | 38.69 ±0.62 | 84.46 ±0.27 | 11.24 ±1.25 | 40.49 ±0.99 | |
| Context-based prompting with XGrammar | |||||||
| gamma-4-E2B-it | off | 71.19 ±1.16 | 32.39 ±0.70 | 38.50 ±0.57 | 78.31 ±0.25 | 6.24 ±0.12 | 27.33 ±0.59 |
| Qwen3.8-27B | off | 83.96 ±0.18 | 22.18 ±0.35 | 17.11 ±0.55 | 86.91 ±0.20 | 8.09 ±0.16 | 40.51 ±0.88 |
| Mean over the six arms run with all three methods | |||||||
| Constrained tagging (ours) | 70.36 | 16.93 | 34.42 | 66.49 | 9.56 | 24.72 | |
| Unconstrained tagging | 57.10 | 24.15 | 32.35 | 62.69 | 7.83 | 21.52 | |
| Context-based prompting | 77.07 | 27.89 | 33.43 | 83.96 | 9.45 | 37.63 | |
| Ours – unconstrained | +13.26 | -7.22 | +2.08 | +3.80 | +1.73 | +3.20 | |
| Ours – context-based | -6.71 | -10.96 | +1.00 | -17.47 | +0.12 | -12.91 | |
Table 6: Hard F1 for every model, reasoning setting and method, mean ± standard deviation over three seeds, batch size 1, at the precision of the analysis (the main-text tables round to one decimal). Macro average over treebanks or files. On CoNLL-2003 and UniversalNER the standard deviation also includes the variance of the per-seed evaluation subsample. The last block averages the six arms that were run with all three methods (gamma-4-E2B-it off and on, Qwen3.8-27B off and low, gpt-oss-20b low and medium). The best result per dataset is in bold and the second best in italics, and likewise among the three averages of the last block.
| Dataset | Generations | Wrong text | reasoning never closed | Cap in answer | Scored 1.0 | |
|---|---|---|---|---|---|---|
| token cap | model stopped | |||||
| CoNLL-2003 | 34,560 | 0 | 0 | 0 | 0 | — |
| Toxic Spans | 30,000 | 2 | 0 | 2 | 0 | 1 |
| LegalQAEval | 36,180 | 3 | 2 | 1 | 0 | 1 |
| UniversalNER | 111,060 | 2 | 0 | 2 | 0 | — |
| WMT24 ESA-MT | 26,010 | 1 | 0 | 1 | 0 | 0 |
| MultiGEC | 15,120 | 2 | 2 | 0 | 0 | 0 |
Table 7: Every constrained generation that did not reproduce its input, by cause, pooled over models, reasoning settings and seeds at batch size 1. The answer itself never ran out of budget. Reasoning failed to close in ten generations: four reached the cap of 18,000 new tokens, and in six the model ended its turn while still reasoning. Scored 1.0 counts the failures that per-example character F1 nevertheless scores as perfect because the gold is empty; it does not apply to the NER datasets. At batch size 64, 46 further generations on UniversalNER failed in the same ways, 28 of them by exhausting the budget during the answer.
| Spans/ex. | Length | % of predicted spans | % of gold | |||||
|---|---|---|---|---|---|---|---|---|
| Exact | Label | Boundary | Both | Spurious | Missed | |||
| CoNLL-2003 | ||||||||
| Gold | 1.64 | 9.5 | ||||||
| Ours | 1.86 | 10.9 | 58.9 | 10.2 | 12.8 | 3.4 | 14.7 | 2.9 |
| Unconstrained | 1.24 | 9.8 | 67.7 | 10.6 | 4.5 | 2.4 | 14.8 | 35.6 |
| Context-based | 1.79 | 9.9 | 70.1 | 9.8 | 3.7 | 2.6 | 13.7 | 6.1 |
| Toxic Spans | ||||||||
| Gold | 0.58 | 6.9 | ||||||
| Ours | 1.23 | 22.4 | 14.8 | — | 16.4 | — | 68.8 | 30.9 |
| Unconstrained | 0.81 | 17.1 | 18.8 | — | 17.8 | — | 63.4 | 47.2 |
| Context-based | 1.07 | 12.1 | 20.7 | — | 12.5 | — | 66.8 | 37.4 |
| LegalQAEval | ||||||||
| Gold | 0.54 | 62.8 | ||||||
| Ours | 1.13 | 138.2 | 7.2 | — | 25.9 | — | 66.9 | 31.5 |
| Unconstrained | 0.42 | 57.1 | 27.3 | — | 31.1 | — | 41.6 | 55.6 |
| Context-based | 0.61 | 34.6 | 24.0 | — | 31.4 | — | 44.6 | 39.1 |
| UniversalNER | ||||||||
| Gold | 1.92 | 8.6 | ||||||
| Ours | 2.00 | 12.6 | 60.5 | 3.1 | 19.1 | 2.0 | 15.3 | 10.9 |
| Unconstrained | 1.29 | 8.9 | 76.9 | 3.4 | 9.0 | 1.6 | 9.1 | 39.3 |
| Context-based | 1.88 | 8.7 | 79.2 | 3.2 | 7.6 | 1.7 | 8.4 | 11.4 |
| ESA-MT | ||||||||
| Gold | 2.21 | 13.7 | ||||||
| Ours | 1.88 | 20.5 | 2.9 | 3.8 | 13.1 | 16.1 | 64.2 | 66.8 |
| Unconstrained | 0.98 | 17.1 | 4.6 | 5.8 | 14.2 | 17.2 | 58.2 | 80.6 |
| Context-based | 1.36 | 14.9 | 4.5 | 6.3 | 13.0 | 17.3 | 59.0 | 73.7 |
| MultiGEC | ||||||||
| Gold | 14.09 | 4.2 | ||||||
| Ours | 6.85 | 18.5 | 36.1 | 1.9 | 11.4 | 9.6 | 41.1 | 60.7 |
| Unconstrained | 3.75 | 4.4 | 41.6 | 2.0 | 9.0 | 7.8 | 39.5 | 83.7 |
| Context-based | 8.25 | 5.6 | 34.6 | 1.8 | 11.7 | 8.2 | 43.7 | 66.6 |
Table 8: Where the predicted spans go wrong, on the six arms run with all three methods (batch size 1, pooled over arms and seeds). Spans/ex.: spans per example; Length: mean span length in characters. Every predicted span is exact (boundaries and label right), has the right boundaries but the wrong label, the right label but the wrong boundary, both wrong, or is spurious (overlaps no gold span); missed gold spans overlap no prediction. Toxic Spans and LegalQAEval have a single label. An unconstrained output that does not reproduce its input contributes no spans.
| CoNLL-2003 | ||||
|---|---|---|---|---|
| LOC | MISC | ORG | PER | |
| LOC | 96.4 | 1.3 | 2.2 | 0.2 |
| MISC | 11.5 | 79.5 | 6.7 | 2.2 |
| ORG | 31.7 | 2.9 | 64.5 | 0.9 |
| PER | 0.7 | 1.4 | 0.6 | 97.2 |
| UniversalNER | |||
|---|---|---|---|
| LOC | ORG | PER | |
| LOC | 97.2 | 2.2 | 0.6 |
| ORG | 10.6 | 87.5 | 1.9 |
| PER | 1.2 | 1.2 | 97.6 |
| ESA-MT | ||
|---|---|---|
| MAJOR | MINOR | |
| MAJOR | 56.7 | 43.3 |
| MINOR | 71.8 | 28.2 |
| MultiGEC | |||
|---|---|---|---|
| M | R | U | |
| M | 100.0 | 0.0 | 0.0 |
| R | 0.0 | 93.7 | 6.3 |
| U | 0.0 | 20.5 | 79.5 |
Table 9: Label confusion of constrained tagging on the spans whose boundaries are exactly right, pooled over all models, reasoning settings and seeds at batch size 1: rows are gold labels, columns predicted labels, in % of the gold label. Toxic Spans and LegalQAEval have a single label.
| Model | Reasoning | CoNLL | Toxic Spans | LegalQAEval | UNER | ESA-MT | MultiGEC |
|---|---|---|---|---|---|---|---|
| Constrained tagging (ours) | |||||||
| gamma-4-E2B-it | off | 56.4 | 13.2 | 11.2 | 58.6 | 4.6 | 8.2 |
| on | 68.0 | 13.4 | 10.9 | 64.3 | 7.8 | 8.9 | |
| Δ | +11.6 | +0.2 | -0.3 | +5.7 | +3.2 | +0.6 | |
| Qwen3.8-27B | off | 72.8 | 17.4 | 41.8 | 59.8 | 9.2 | 24.5 |
| low | 80.4 | 20.0 | 51.8 | 54.4 | 9.5 | 49.9 | |
| Δ | +7.6 | +2.6 | +9.9 | -5.4 | +0.3 | +25.4 | |
| gpt-oss-20b | low | 69.9 | 20.5 | 42.9 | 75.7 | 12.9 | 24.5 |
| medium | 74.7 | 17.0 | 47.9 | 86.2 | 13.5 | 32.2 | |
| Δ | +4.8 | -3.5 | +5.0 | +10.5 | +0.6 | +7.6 | |
| gpt-oss-120b | low | 78.6 | 20.6 | 47.9 | 79.5 | 11.8 | 31.8 |
| medium | 79.7 | 18.9 | 52.8 | 89.3 | 12.3 | 32.9 | |
| Δ | +1.1 | -1.7 | +4.9 | +9.8 | +0.5 | +1.2 | |
| Context-based prompting | |||||||
| gamma-4-E2B-it | off | 71.5 | 32.5 | 38.6 | 78.0 | 6.5 | 27.0 |
| on | 73.1 | 29.5 | 40.3 | 83.9 | 9.0 | 33.9 | |
| Δ | +1.6 | -3.0 | +1.7 | +5.9 | +2.5 | +6.9 | |
| Qwen3.8-27B | off | 84.1 | 20.4 | 17.4 | 86.9 | 8.8 | 40.1 |
| low | 87.4 | 28.4 | 33.5 | 89.4 | 10.1 | 51.6 | |
| Δ | +3.2 | +8.0 | +16.1 | +2.5 | +1.4 | +11.4 | |
| gpt-oss-20b | low | 73.3 | 30.0 | 32.1 | 80.9 | 11.1 | 32.7 |
| medium | 73.1 | 26.4 | 38.7 | 84.5 | 11.2 | 40.5 | |
| Δ | -0.1 | -3.6 | +6.5 | +3.5 | +0.1 | +7.8 | |
Table 10: Hard F1 per dataset for every model run with two reasoning settings, and the gain from more reasoning ( ), mean over three seeds at batch size 1. gpt-oss cannot switch reasoning off, so its two settings are low and medium effort. Macro average over treebanks or files. The context-based baseline was not run with gpt-oss-120b. For each model and method, the better reasoning setting is in bold.
| Model | Reasoning | Constrained tagging (ours) | Context-based prompting | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CoNLL | UNER | CoNLL | UNER | ||||||
| 1 | 64 | 1 | 64 | 1 | 64 | 1 | 64 | ||
| gamma-4-E2B-it | off | 56.4 | 8.5 | 58.6 | 29.0 | 71.5 | 50.5 | 78.0 | 44.9 |
| on | 68.0 | 12.2 | 64.3 | 33.7 | 73.1 | 58.6 | 83.9 | 59.9 | |
| gamma-4-31B-it | off | 84.7 | 86.6 | 88.7 | 86.9 | — | — | — | — |
| Qwen3-8B | off | 63.4 | 63.7 | 70.3 | 69.3 | — | — | — | — |
| Qwen3.8-27B | off | 72.8 | 69.2 | 59.8 | 63.4 | 84.1 | 86.6 | 86.9 | 85.9 |
| low | 80.4 | 66.7 | 54.4 | 63.3 | 87.4 | 87.6 | 89.4 | 68.0 | |
| gpt-oss-20b | low | 69.9 | 23.0 | 75.7 | 43.2 | 73.3 | 26.0 | 80.9 | 23.5 |
| medium | 74.7 | 64.7 | 86.2 | 53.7 | 73.1 | 59.9 | 84.5 | 44.5 | |
| gpt-oss-120b | low | 78.6 | 57.6 | 79.5 | 71.8 | — | — | — | — |
| medium | 79.7 | 78.5 | 89.3 | 80.3 | — | — | — | — | |
Table 11: Hard F1 at batch size 1 and 64 on the two NER datasets, mean over three seeds. Macro average over the 18 treebanks. Marks a model for which the context-based baseline was not run. Copying 64 sentences also strains the token budget: with reasoning, 13.7% of the batched UNER generations of Qwen3.8-27B (low) and 9.8% of gpt-oss-20b (medium) did not complete (Table 7). For each model, reasoning setting, dataset and batch size, the better of the two methods is in bold.
| Constrained tagging (ours) | Context-based prompting | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CoNLL | UNER | CoNLL | UNER | ||||||||||
| R1 | R64 | P64 | R1 | R64 | P64 | R1 | R64 | P64 | R1 | R64 | P64 | ||
| gemma-4-E2B-it | off | 69.9 | 20.2 | 5.3 | 77.0 | 46.3 | 26.3 | 73.5 | 36.8 | 81.0 | 74.3 | 32.6 | 81.7 |
| on | 80.1 | 28.9 | 7.7 | 83.7 | 51.2 | 30.8 | 79.3 | 45.3 | 82.9 | 84.6 | 46.9 | 88.6 | |
| gemma-4-31B-it | off | 88.5 | 88.1 | 85.2 | 89.6 | 85.2 | 89.8 | — | — | — | — | — | — |
| Qwen3-8B | off | 64.8 | 59.0 | 69.6 | 78.3 | 65.6 | 77.6 | — | — | — | — | — | — |
| Qwen3.8-27B | off | 84.8 | 63.0 | 77.1 | 79.1 | 55.6 | 83.5 | 86.5 | 85.2 | 88.1 | 87.5 | 83.9 | 88.5 |
| low | 84.1 | 57.7 | 80.2 | 80.5 | 55.0 | 84.3 | 89.4 | 85.3 | 90.1 | 89.1 | 60.1 | 90.0 | |
| gpt-oss-20b | low | 82.0 | 21.5 | 25.7 | 88.3 | 46.9 | 49.5 | 79.9 | 15.6 | 79.1 | 81.0 | 17.6 | 59.3 |
| medium | 83.5 | 65.6 | 63.9 | 91.1 | 57.9 | 58.4 | 83.1 | 48.0 | 79.8 | 86.3 | 34.7 | 78.8 | |
| gpt-oss-120b | low | 84.2 | 48.8 | 70.8 | 89.3 | 68.5 | 79.2 | — | — | — | — | — | — |
| medium | 84.4 | 75.5 | 81.8 | 90.8 | 78.1 | 84.0 | — | — | — | — | — | — | |
Table 12: Recall at batch size 1 and 64 ( , ) and precision at batch size 64 ( ) behind Table 11: the hard character-overlap metric, mean over three seeds. Macro average over the 18 treebanks. — marks a model the context-based baseline was not run with. For each model, reasoning setting, dataset and column, the better of the two methods is in bold.
| Dataset | Task description | Labels | Additional rules | Examples |
|---|---|---|---|---|
| CoNLL-2003 | named entity recognition | PER, LOC, ORG, MISC | outermost entities only; tag every occurrence | 2 |
| UniversalNER | named entity recognition in any language and script, without translating the input | PER, ORG, LOC; no MISC | as for CoNLL-2003 | 2 |
| Toxic Spans | toxic spans in a social-media post | TOXIC: insults, slurs, threats, hate speech, identity attacks and profanity aimed at a person | return the post unchanged if nothing is toxic | 2 |
| LegalQAEval | the span of a legal passage that answers {question} | ANSWER | return the passage unchanged if it has no answer; of identical answers, tag only the first | 1 |
| ESA-MT | errors in a translation, given the {source_text} in {source_language} as context that is never copied | MAJOR, MINOR (error severity) | return the translation unchanged if it has no errors | 1 |
| MultiGEC | grammatical errors in learner English | R (replace), U (unnecessary), M (missing) | an M tag is empty and marks where a word is missing; never write the correction; no two M tags at one position | 1 |
Table 13: What the system prompt of each dataset changes relative to Listing 1. The output format and the general rules, such as reproducing the input exactly and not creating overlapping spans, are shared by all datasets.

Figure 7: Token-Aware against Whole-Sequence on CoNLL-2003, from earlier experiments with three smaller instruction-tuned models, averaged over greedy and sampling decoding.