Views
No views yet
!pip install -U zshot==0.0.11 gliner datasets1import spacy
2import datasets
3
4from zshot import PipelineConfig, displacy
5from zshot.linker import LinkerSMXM
6from zshot.utils.data_models import Entity
7
8
9entities = [
10 Entity(name='FAC', description='Names of man-made structures: infrastructure (streets, bridges), buildings, monuments, etc. belong to this type. Buildings that are referred to using the name of the company or organization that uses them should be marked as FAC when they refer to the physical structure of the building itself, usually in a locative way: "I\'m reporting live from right outside [Massachusetts General Hospital]"', vocabulary=None),
11 Entity(name='LOC', description='Names of geographical locations other than GPEs. These include mountain ranges, coasts, borders, planets, geo-coordinates, bodies of water. Also included in this category are named regions such as the Middle East, areas, neighborhoods, continents and regions of continents. Do NOT mark deictics or other non-proper nouns: here, there, everywhere, etc. As with GPEs, directional modifiers such as "southern" are only marked when they are part of the location name itself.', vocabulary=None),
12 Entity(name='WORK_OF_ART', description='Titles of books, songs, television programs and other creations. Also includes awards. These are usually surrounded by quotation marks in the article (though the quotations are not included in the annotation). Newspaper headlines should only be marked if they are referential. In other words the headline of the article being annotated should not be marked but if in the body of the text here is a reference to an article, then it is markable as a work of art.', vocabulary=None)
13]
14
15nlp = spacy.blank("en")
16nlp_config = PipelineConfig(
17 linker=LinkerSMXM(model_name="disi-unibo-nlp/zeroner-base"),
18 entities=entities,
19 device='cuda'
20)
21
22nlp.add_pipe("zshot", config=nlp_config, last=True)
23
24text = """
25I remember the SMS was written like this at that time , saying that , ah , there was a sewage pipe leakage accident on the side road at the southeast corner of Jingguang Bridge at East Third Ring Road , and , well , traffic supervision was implemented near Chaoyang Road , Jingguang Bridge , and East Third Ring Road , and requesting cars to make a detour .
26"""
27
28doc = nlp(text)
29displacy.serve(doc, style="ent")1@inproceedings{cocchieri-etal-2025-zeroner,
2 title = "{Z}ero{NER}: Fueling Zero-Shot Named Entity Recognition via Entity Type Descriptions",
3 author = "Cocchieri, Alessio and
4 Mart{\'i}nez Galindo, Marcos and
5 Frisoni, Giacomo and
6 Moro, Gianluca and
7 Sartori, Claudio and
8 Tagliavini, Giuseppe",
9 editor = "Che, Wanxiang and
10 Nabende, Joyce and
11 Shutova, Ekaterina and
12 Pilehvar, Mohammad Taher",
13 booktitle = "Findings of the Association for Computational Linguistics: ACL 2025",
14 month = jul,
15 year = "2025",
16 address = "Vienna, Austria",
17 publisher = "Association for Computational Linguistics",
18 url = "https://aclanthology.org/2025.findings-acl.805/",
19 doi = "10.18653/v1/2025.findings-acl.805",
20 pages = "15594--15616",
21 ISBN = "979-8-89176-256-5",
22 abstract = "What happens when a named entity recognition (NER) system encounters entities it has never seen before? In practical applications, models must generalize to unseen entity types where labeled training data is either unavailable or severely limited{---}a challenge that demands zero-shot learning capabilities. While large language models (LLMs) offer extensive parametric knowledge, they fall short in cost-effectiveness compared to specialized small encoders. Existing zero-shot methods predominantly adopt a relaxed definition of the term with potential leakage issues and rely on entity type names for generalization, overlooking the value of richer descriptions for disambiguation. In this work, we introduce ZeroNER, a description-driven framework that enhances hard zero-shot NER in low-resource settings. By leveraging general-domain annotations and entity type descriptions with LLM supervision, ZeroNER enables a BERT-based student model to successfully identify unseen entity types. Evaluated on three real-world benchmarks, ZeroNER consistently outperforms LLMs by up to 16{\%} in F1 score, and surpasses lightweight baselines that use type names alone. Our analysis further reveals that LLMs derive significant benefits from incorporating type descriptions in the prompts."
23}