Skip to content
intermediatetext

Few-NERD Fine-Grained Named Entity Recognition

Label entity spans with all 66 Few-NERD fine-grained types and run a token-classification training loop, on illustrative sample sentences.

Try it live — no install

Boot the real Potato server in your browser (WebAssembly) and annotate with this exact config. Nothing leaves your machine.

Run live in your browser

Get This Design

View on GitHub(opens in a new tab)

Clone or download from the repository

Quick start:

bash
git clone https://github.com/davidjurgens/potato-showcase.git
cd potato-showcase/text/named-entity-recognition/few-nerd-fine-grained-entities
potato start config.yaml

About this dataset

Few-NERD was introduced by Ning Ding, Guangwei Xu, Yulin Chen, and colleagues at ACL-IJCNLP 2021. The dataset consists of 188,238 sentences from Wikipedia, annotated with a hierarchy of 8 coarse-grained and 66 fine-grained entity types. The authors built Few-NERD as a benchmark for few-shot named entity recognition, and the dataset is released under CC BY-SA 4.0.

In the annotation protocol, each paragraph is independently annotated by two annotators, and an experienced expert then reviews the paragraph and makes the final decision. For each batch, 10% of sentences are double-checked, and a batch with sentence-level accuracy below 95% is re-annotated. The paper's example shows why fine types matter. In a sentence about the album London by the band Jesus Jones, London is an art-music entity and not a location-GPE entity.

Potato span labels are flat, so the design encodes the hierarchy in the label names. Each of the 66 labels reads coarse-fine, such as art-music or location-GPE, and carries the color of the coarse type. The sample sentences are illustrative and were written for the design because the dataset's share-alike license applies to the dataset's text. Two annotators per item echo the paper's double annotation, and the expert adjudication pass is not modeled.

The model_training block uses the hf-token-classification trainer, which fine-tunes a Hugging Face transformer to tag spans from the labeled sentences. A finished run writes predicted spans onto unlabeled sentences as pre-labels for the next annotator to confirm or correct. The design does not serve or deploy the trained model.

Coarse entity types
8
Fine-grained entity types
66
Sentences
188,238
Entities
491.7k
Annotators
70 annotators and 10 experienced experts
Licence
CC BY-SA 4.0

Configuration File

This Potato config reproduces the annotation task. Save it as config.yaml and run potato start config.yaml to try it.

yaml
# Few-NERD - Fine-Grained Named Entity Recognition (illustrative sample)
# Few-NERD: A Few-shot Named Entity Recognition Dataset
#
# Citation (ACL Anthology BibTeX):
#   @inproceedings{ding-etal-2021-nerd,
#       title = "Few-{NERD}: A Few-shot Named Entity Recognition Dataset",
#       author = "Ding, Ning and Xu, Guangwei and Chen, Yulin and Wang, Xiaobin and
#         Han, Xu and Xie, Pengjun and Zheng, Haitao and Liu, Zhiyuan",
#       booktitle = "Proceedings of the 59th Annual Meeting of the Association for
#         Computational Linguistics and the 11th International Joint Conference on
#         Natural Language Processing (Volume 1: Long Papers)",
#       month = aug, year = "2021", address = "Online",
#       publisher = "Association for Computational Linguistics",
#       url = "https://aclanthology.org/2021.acl-long.248/",
#       doi = "10.18653/v1/2021.acl-long.248", pages = "3198--3213"
#   }
# DOI: 10.18653/v1/2021.acl-long.248
# Dataset: https://github.com/thunlp/Few-NERD
#          https://huggingface.co/datasets/DFKI-SLT/few-nerd
# Licence: CC BY-SA 4.0 (Hugging Face dataset card). Because of the share-alike
# term, the sample sentences in sample-data.json are ILLUSTRATIVE. They were
# written for this design in the style of Wikipedia text and are not copied
# from Few-NERD.
#
# Protocol (paper, Section 4): "We carefully design an annotation schema of 8
# coarse-grained entity types and 66 fine-grained entity types". Each paragraph
# "is independently annotated by two well-trained annotators. Then, an
# experienced expert goes over the paragraph for possible wrong or omissive
# annotations, and make the final decision." Paper example: in "London is the
# fifth album by the British rock band Jesus Jones", London "should be annotated
# as an entity of Art-Music rather than Location-GPE".
#
# Label set (66 fine types, names as listed in the Hugging Face dataset card):
#   art:          broadcastprogram, film, music, other, painting, writtenart
#   building:     airport, hospital, hotel, library, other, restaurant,
#                 sportsfacility, theater
#   event:        attack/battle/war/militaryconflict, disaster, election, other,
#                 protest, sportsevent
#   location:     GPE, bodiesofwater, island, mountain, other, park,
#                 road/railway/highway/transit
#   organization: company, education, government/governmentagency,
#                 media/newspaper, other, politicalparty, religion,
#                 showorganization, sportsleague, sportsteam
#   other:        astronomything, award, biologything, chemicalthing, currency,
#                 disease, educationaldegree, god, language, law, livingthing,
#                 medical
#   person:       actor, artist/author, athlete, director, other, politician,
#                 scholar, soldier
#   product:      airplane, car, food, game, other, ship, software, train, weapon
#
# Adaptations:
#   - Potato span labels are flat, so the two-level hierarchy is encoded in the
#     label names. Each of the 66 labels is "<coarse>-<fine>" and carries its
#     coarse type's color, so the 8 coarse types stay readable on screen. A
#     separate coarse scheme plus a fine-type select would not tie the fine
#     type to a span, so it was not used.
#   - Labels carry no tooltips because the paper does not give per-type
#     definitions in the text this design quotes.
#   - num_annotators_per_item: 2 echoes the paper's two independent annotators.
#     The expert adjudication pass is not modeled.
#   - Sample items are 10 illustrative sentences, not dataset rows.
#
# Model training: the trainer is hf-token-classification. It fine-tunes a
# Hugging Face transformer to tag text spans from the labeled spans, and the
# run writes predicted spans back as prelabels on unlabeled sentences. Install
# it with: pip install 'potato-annotation[train-text]'. Open /admin/training
# with the admin key below, pick the trainer and the "entity_spans" scheme,
# and click Train now. It does not serve or deploy the model.

annotation_task_name: "Few-NERD - Fine-Grained Named Entity Recognition"
task_dir: "."

data_files:
  - sample-data.json

item_properties:
  id_key: "id"
  text_key: "text"

output_annotation_dir: "annotation_output/"
export_annotation_format: "jsonl"

port: 8000
require_password: false
admin_api_key: "demo-admin-key"

annotation_schemes:
  - annotation_type: span
    name: entity_spans
    description: "Highlight each named entity and choose its coarse-fine type"
    labels:
      # art
      - name: "art-broadcastprogram"
        color: "#8b5cf6"
      - name: "art-film"
        color: "#8b5cf6"
      - name: "art-music"
        color: "#8b5cf6"
      - name: "art-other"
        color: "#8b5cf6"
      - name: "art-painting"
        color: "#8b5cf6"
      - name: "art-writtenart"
        color: "#8b5cf6"
      # building
      - name: "building-airport"
        color: "#78716c"
      - name: "building-hospital"
        color: "#78716c"
      - name: "building-hotel"
        color: "#78716c"
      - name: "building-library"
        color: "#78716c"
      - name: "building-other"
        color: "#78716c"
      - name: "building-restaurant"
        color: "#78716c"
      - name: "building-sportsfacility"
        color: "#78716c"
      - name: "building-theater"
        color: "#78716c"
      # event
      - name: "event-attack/battle/war/militaryconflict"
        color: "#ef4444"
      - name: "event-disaster"
        color: "#ef4444"
      - name: "event-election"
        color: "#ef4444"
      - name: "event-other"
        color: "#ef4444"
      - name: "event-protest"
        color: "#ef4444"
      - name: "event-sportsevent"
        color: "#ef4444"
      # location
      - name: "location-GPE"
        color: "#22c55e"
      - name: "location-bodiesofwater"
        color: "#22c55e"
      - name: "location-island"
        color: "#22c55e"
      - name: "location-mountain"
        color: "#22c55e"
      - name: "location-other"
        color: "#22c55e"
      - name: "location-park"
        color: "#22c55e"
      - name: "location-road/railway/highway/transit"
        color: "#22c55e"
      # organization
      - name: "organization-company"
        color: "#f59e0b"
      - name: "organization-education"
        color: "#f59e0b"
      - name: "organization-government/governmentagency"
        color: "#f59e0b"
      - name: "organization-media/newspaper"
        color: "#f59e0b"
      - name: "organization-other"
        color: "#f59e0b"
      - name: "organization-politicalparty"
        color: "#f59e0b"
      - name: "organization-religion"
        color: "#f59e0b"
      - name: "organization-showorganization"
        color: "#f59e0b"
      - name: "organization-sportsleague"
        color: "#f59e0b"
      - name: "organization-sportsteam"
        color: "#f59e0b"
      # other
      - name: "other-astronomything"
        color: "#06b6d4"
      - name: "other-award"
        color: "#06b6d4"
      - name: "other-biologything"
        color: "#06b6d4"
      - name: "other-chemicalthing"
        color: "#06b6d4"
      - name: "other-currency"
        color: "#06b6d4"
      - name: "other-disease"
        color: "#06b6d4"
      - name: "other-educationaldegree"
        color: "#06b6d4"
      - name: "other-god"
        color: "#06b6d4"
      - name: "other-language"
        color: "#06b6d4"
      - name: "other-law"
        color: "#06b6d4"
      - name: "other-livingthing"
        color: "#06b6d4"
      - name: "other-medical"
        color: "#06b6d4"
      # person
      - name: "person-actor"
        color: "#3b82f6"
      - name: "person-artist/author"
        color: "#3b82f6"
      - name: "person-athlete"
        color: "#3b82f6"
      - name: "person-director"
        color: "#3b82f6"
      - name: "person-other"
        color: "#3b82f6"
      - name: "person-politician"
        color: "#3b82f6"
      - name: "person-scholar"
        color: "#3b82f6"
      - name: "person-soldier"
        color: "#3b82f6"
      # product
      - name: "product-airplane"
        color: "#ec4899"
      - name: "product-car"
        color: "#ec4899"
      - name: "product-food"
        color: "#ec4899"
      - name: "product-game"
        color: "#ec4899"
      - name: "product-other"
        color: "#ec4899"
      - name: "product-ship"
        color: "#ec4899"
      - name: "product-software"
        color: "#ec4899"
      - name: "product-train"
        color: "#ec4899"
      - name: "product-weapon"
        color: "#ec4899"

annotation_instructions: |
  Highlight every named entity in the sentence and choose the most specific
  type, written as coarse-fine (for example art-music or location-GPE).
  The eight coarse types are art, building, event, location, organization,
  other, person, and product. Each has fine types, and every coarse type
  except "other" has an "other" fine type (such as person-other) for
  entities that fit no listed fine type.
  Choose the type that fits the entity in context. In the paper's example,
  the album title "London" is art-music, not location-GPE.

user_config:
  allow_all_users: true
max_annotations_per_user: 50
num_annotators_per_item: 2

model_training:
  enabled: true
  writeback:
    schemas: ["entity_spans"]
    include_unlabeled: true
    min_confidence: 0.6

Sample Data

json
[
  {
    "id": "fewnerd_001",
    "text": "Marta Oliveira, a Portuguese sprinter, won the 200 metres at the Baltic Games in Riga."
  },
  {
    "id": "fewnerd_002",
    "text": "The Calder Valley Gazette reported that the Harlow Party had lost the election in Brenton."
  }
]

// ... and 8 more items

Dataset & paper

Ding et al., ACL 2021

Paper DOI
10.18653/v1/2021.acl-long.248

Citation (BibTeX)

bibtex
@inproceedings{ding-etal-2021-nerd,
    title = "Few-{NERD}: A Few-shot Named Entity Recognition Dataset",
    author = "Ding, Ning  and
      Xu, Guangwei  and
      Chen, Yulin  and
      Wang, Xiaobin  and
      Han, Xu  and
      Xie, Pengjun  and
      Zheng, Haitao  and
      Liu, Zhiyuan",
    editor = "Zong, Chengqing  and
      Xia, Fei  and
      Li, Wenjie  and
      Navigli, Roberto",
    booktitle = "Proceedings of the 59th Annual Meeting of the {A}ssociation for {C}omputational {L}inguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)",
    month = aug,
    year = "2021",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2021.acl-long.248/",
    doi = "10.18653/v1/2021.acl-long.248",
    pages = "3198--3213"
}

Details

Annotation Types

span

Domain

NLPEncyclopedic Text

Use Cases

Named Entity RecognitionFine-Grained Entity TypingFew-Shot Learning

Tags

few-nerdnerfine-grainedwikipediatoken-classificationfew-shot

Found an issue or want to improve this design?

Open an Issue(opens in a new tab)