Just Pass Twice: Efficient Token Classification with LLMs for Zero-Shot NER
Organizations: WitnessAI
Abstract
Large language models encode extensive world knowledge valuable for zero-shot named entity recognition. However, their causal attention mechanism, where tokens attend only to preceding context, prevents effective token classification when disambiguation requires future context. Existing approaches use LLMs generatively, prompting them to list entities or produce structured outputs, but suffer from slow autoregressive decoding, hallucinated entities, and formatting errors. We propose Just Pass Twice (JPT), a simple yet effective method that enables causal LLMs to perform discriminative token classification with full bidirectional context. Our key insight is that concatenating the input to itself lets each token in the second pass attend to the complete sentence, requiring no architectural modifications. We combine these representations with definition-guided entity embeddings for flexible zero-shot generalization. Our approach achieves state-of-the-art results on zero-shot NER benchmarks, surpassing the previous best method by +7.9 F1 on average across CrossNER and MIT benchmarks, being over 20x faster than comparable generative methods. Interactive demo and access to the model are available at https://witness-ai-jpt-ner.hf.space/
Figures & tables
| Model | AI | Lit. | Music | Politics | Science | Movie | Rest. | Avg |
|---|---|---|---|---|---|---|---|---|
| Generative Baselines | ||||||||
| UniNER-7B | 62.9 | 64.9 | 70.6 | 66.9 | 70.8 | 61.2 | 35.2 | 61.8 |
| GoLLIE | 59.1 | 62.7 | 67.8 | 57.2 | 55.5 | 63.0 | 43.4 | 58.4 |
| InstructUIE | 49.0 | 47.2 | 53.2 | 48.2 | 49.3 | 63.0 | 21.0 | 47.8 |
| SaM (MoE) | 60.9 | 66.9 | 73.5 | 74.4 | 62.6 | 72.1 | 52.9 | 66.2 |
| Discriminative Baselines | ||||||||
| Dataset | UniNER-7B | GLiNER-L | JPT-4B |
|---|---|---|---|
| ACE05 | 36.9 | 27.3 | 44.6 |
| AnatEM | 25.1 | 33.3 | 37.2 |
| bc2gm | 46.2 | 47.9 | 54.8 |
| bc4chemd | 47.9 | 43.1 | 53.3 |
| bc5cdr | 68.0 | 66.4 | 70.4 |
| Broad Twitter | 67.9 | 61.2 | 71.2 |
| Method | Cost(\downarrow$ | Time (sec) | F1 |
|---|---|---|---|
| Generative Methods | |||
| UniNER-7B | 2.77 | 1970.2 | 61.8 |
| GNER | 8.21 | 5831.5 | 75.8 |
| GPT-5 † | 0.49 | 579.6 | 67.1 |
| Discriminative Methods | |||
| GLiNER-L | 0.05 | 33.3 | 60.9 |
| Configuration | Avg Micro F1 |
|---|---|
| Input Duplication | |
| Single Pass | 55.7 |
| Entity Definitions | |
| No Definitions | 58.3 |
| Prompt-only definitions | 63.3 |
| Embedding-only definitions | 65.2 |
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
| Component | JPT-4B | JPT-8B |
|---|---|---|
| Base LLM (Frozen) | ||
| Model | Qwen3-4B | Qwen3-8B |
| Hidden dim ( ) | 2560 | 4096 |
| Layers / Attention heads | 36 / 32 | 36 / 32 |
| LoRA Adapters (Trained) | ||
| Rank ( ) / Alpha ( ) | 32 / 64 | 128 / 256 |
| Hyperparameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning rate | |
| LR scheduler | Cosine with warmup |
| Warmup ratio | 10% of total steps |
| Effective batch size | 8 |
| Gradient accumulation | 2 |
| Statistic | Value |
|---|---|
| Total sentences | 17,489 |
| Total tokens | 3,391,899 |
| Total entity mentions | 374,705 |
| Unique entity types | 5,009 |
| Avg. sentence length | 194.9 tokens |
| Entity/non-entity ratio | 1:1.5 |
| Example 1: Sports Domain |
|---|
| “the men’s foil competition in fencing at the 2016 olympic games in rio de janeiro was held on 7 august at the carioca arena 3 . the medals were presented by paul tergat , ioc member, kenya ” |
| Example 2: Natural Disaster Domain |
| “the 2014 mae lao earthquake occurred at 18:08:43 indochina time on may 5 . the epicenter was located 9 km south of mae lao district , 27 km southwest of chiang rai , thailand ” |
| Example 3: Biographical Domain |
| “ helga mühlberg-ulze is an east german sprint canoeist who competed in the early to mid 1960s . she won gold ( k-2 500m : 1966 ) and two bronzes ” |
| Type | Generic Definition | Precise Definition | F1 |
|---|---|---|---|
| Location | “A geographical place” | “Any word indicating WHERE: explicit places (NYC, downtown), relative indicators (nearby, around, close by), directional phrases (east, south side). Tag the location word itself.” | +32.6 |
| Price | “A monetary value” | “Explicit monetary amounts ($50, 100 dollars) AND qualitative price indicators (cheap, expensive, budget-friendly, overpriced, pricey).” | +34.9 |
| Amenity | “An available service” | “A feature, facility, or service offered by a restaurant. Includes: physical features (bar, parking), services (delivery, reservations, takeout), atmosphere descriptors (romantic, casual, family-friendly).” | +14.29 |
| Model | Params | Token F1 |
|---|---|---|
| Qwen3-1.7B | 1.7B | 92.4 |
| Qwen3-4B | 4B | 93.9 |
| Qwen3-8B | 8B | 94.1 |
| Qwen3-14B | 14B | 94.5 |
| LoRA Rank | Token F1 |
|---|---|
| (frozen) | 82.0 |
| 93.5 | |
| (default) | 93.9 |
| 94.2 | |
| 94.5 | |
| 94.7 |
| Model | AI | Lit. | Music | Politics | Science | Avg. |
|---|---|---|---|---|---|---|
| Qwen3-4B | 49.9 | 47.9 | 74.7 | 56.2 | 58.1 | 57.4 |
| JPT-4B | 68.3 | 73.7 | 84.1 | 76.4 | 69.5 | 74.4 |
| Entity at start of sentence | GT Type | Single-input prediction | Why future context matters |
| Type confusion at sentence start | |||
| "Autoencoders are trained to minimise…" | algorithm | product | Need “trained to minimise” to determine that it refers to an algorithm |
| "François Bayrou (…) is a French centrist politician…" | politician | person | Need “politician” later in the sentence to resolve the fine-grained type |
| Completely missed at sentence start | |||
| "The Color Purple is a 1982 epistolary novel…" | book | (missed) | Need “novel” to recognize it as a book title |
| "Young’s work on squid giant axons…" | scientist | (missed) | Need scientific context later in the sentence to identify the mention as a scientist |
| Dataset | Entity Type | Gold Span | Predicted Span |
|---|---|---|---|
| CrossNER-Science | ORGANIZATION | Virgo interferometer | Virgo interferometer collaboration |
| CrossNER-Science | ACADEMIC JOURNAL | the Springer Series Complexity | of the Springer Series Complexity |
| CrossNER-Politics | POLITICAL PARTY | Social Credit Party of Canada | national Social Credit Party of |
| CrossNER-Music | BAND | Collective Consciousness Society | The Collective Consciousness |
| CrossNER-Literature | LITERARY GENRE | Germany Romanticism | Romanticism era |
| MIT-Movie | TITLE | the reflecting skin | reflecting skin movie |
| Error Type | Dataset | Text (excerpt) | Gold | Pred. | Analysis |
|---|---|---|---|---|---|
| Type Confusion | CrossNER-AI | “NIST also differs from Bilingual evaluation understudy in its calculation…” | metrics | conference | Acronym ambiguity |
| Type Confusion | CrossNER-Politics | “The provinces ceded to Augustus for that ten-year period…” | person | politician | Role vs. entity |
| Type Confusion | CrossNER-Music | “…on The Clash ’s London Calling …” | album | location | Title–location ambiguity |
| Missed Entity | CrossNER-AI | “Rethink Robotics introduced Baxter as an industrial robot …” | product | (none) | Descriptive form |
| Missed Entity | CrossNER-Politics | “growth in the Melanesian countries of Solomon Islands…” | location | (none) | Adjectival reference |
| Over-prediction | CrossNER-AI | “A frame language is a technology used for knowledge representation…” | (none) | prog. lang. | Over-generalization |
Named Entity Recognition
Named Entity Recognition identifies and classifies people, places, organizations, and other entities in text, speech, and multimodal data.
See all 106 papers