SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.07464 · ACL · 2021

FEW-NERD: A Few-shot Named Entity Recognition Dataset

Zhiyuan Liu, Ning Ding, Xiaobin Wang, Guangwei Xu, Pengjun Xie, Hai-Tao Zheng, Xu Han, Yulin Chen

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2105.07464.json · badge: /api/ran/2105.07464.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
thunlp/Few-NERD canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
thunlp/Few-NERD/util/supervised_util.py
code served (permissive licence) · get_code("485fe5494e1efa6c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import logging
from unittest.mock import MagicMock

logging.basicConfig(level=logging.INFO)

class MockTokenizer:
    """Mock tokenizer that simulates HuggingFace tokenizer behavior."""
    def tokenize(self, word):
        # Split word into subword tokens (simulating BPE)
        if word.lower() == "hello":
            return ["hello"]
        elif word.lower() == "world":
            return ["world"]
        elif word.lower() == "test":
            return ["test"]
        else:
            return [word]
    
    def convert_tokens_to_ids(self, tokens):
        # Simple mapping: each token gets a unique id
        token_to_id = {
            "[CLS]": 101,
            "[SEP]": 102,
            "[PAD]": 0,
            "hello": 1000,
            "world": 1001,
            "test": 1002,
        }
        return [token_to_id.get(token, 1003) for token in tokens]

class Example:
    """Mock example object with words, labels, and guid."""
    def __init__(self, guid, words, labels):
        self.guid = guid
        self.words = words
        self.labels = labels

# Create mock examples
examples = [
    Example(guid="ex_0", words=["hello", "world"], labels=["O", "O"]),
    Example(guid="ex_1", words=["test", "world"], labels=["B-PER", "O"]),
]

# Create label list
label_list = ["O", "B-PER", "I-PER", "B-LOC"]

# Create tokenizer
tokenizer = MockTokenizer()

# Set up arguments
ARGS = {
    "examples": examples,
    "label_list": label_list,
    "max_seq_length": 16,
    "tokenizer": tokenizer,
    "cls_token_at_end": False,
    "cls_token": "[CLS]",
    "cls_token_segment_id": 0,
    "sep_token": "[SEP]",
    "sep_token_extra": False,
    "pad_on_left": False,
    "pad_token": 0,
    "pad_token_segment_id": 0,
    "pad_token_label_id": -1,
    "sequence_a_segment_id": 0,
    "mask_padding_with_zero": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_class_name Ran
ran; our contract draft was wrong, not the code
thunlp/Few-NERD/util/data_loader.py
code served (permissive licence) · get_code("65f10f78803a1085")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

# The function get_class_name takes a rawtag parameter (a string)
# and processes it by removing 'B-' or 'I-' prefixes if present

# Create valid test inputs
rawtag_with_b_prefix = "B-PER"
rawtag_with_i_prefix = "I-ORG"
rawtag_without_prefix = "O"

# The function is simple and only needs a string parameter
ARGS = {
    "rawtag": rawtag_with_b_prefix
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_labels Ran
ran; our contract draft was wrong, not the code
thunlp/Few-NERD/util/supervised_util.py
code served (permissive licence) · get_code("9288afdf0d017d87")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os

# Create a temporary file with sample labels
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("B-MISC\nI-MISC\nB-PER\nI-PER\nB-ORG\nI-ORG\nB-LOC\nI-LOC")
temp_file.close()
temp_path = temp_file.name

try:
    # Test case 1: with a valid path to labels file
    ARGS = {
        'path': temp_path
    }
finally:
    # Clean up
    os.unlink(temp_path)

# For testing without file I/O, use None which triggers the default labels
ARGS = {
    'path': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_examples_from_file Ran
ran; our contract draft was wrong, not the code
thunlp/Few-NERD/util/supervised_util.py
code served (permissive licence) · get_code("f4626cb5d2ad80ca")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
from io import open

class InputExample(object):
    """A single training/test example for token classification."""

    def __init__(self, guid, words, labels):
        self.guid = guid
        self.words = words
        self.labels = labels

# Create a temporary directory with test data
temp_dir = tempfile.mkdtemp()

# Create a sample train.txt file
train_file_path = os.path.join(temp_dir, 'train.txt')
with open(train_file_path, 'w', encoding='utf-8') as f:
    f.write('-DOCSTART- -X- -X- O\n\n')
    f.write('John\tB-PER\n')
    f.write('Smith\tI-PER\n')
    f.write('works\tO\n')
    f.write('at\tO\n')
    f.write('Google\tB-ORG\n\n')
    f.write('He\tO\n')
    f.write('lives\tO\n')
    f.write('in\tO\n')
    f.write('New\tB-LOC\n')
    f.write('York\tI-LOC\n\n')

# Create a sample dev.txt file
dev_file_path = os.path.join(temp_dir, 'dev.txt')
with open(dev_file_path, 'w', encoding='utf-8') as f:
    f.write('-DOCSTART- -X- -X- O\n\n')
    f.write('Alice\tB-PER\n')
    f.write('works\tO\n')
    f.write('at\tB-ORG\n')
    f.write('Microsoft\tI-ORG\n\n')

ARGS = {
    'data_dir': temp_dir,
    'mode': 'train'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
warmup_linear Ran
ran, honoured the contract we drafted
thunlp/Few-NERD/util/framework.py
code served (permissive licence) · get_code("8570f28ccf82469e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function warmup_linear takes two parameters:
# - global_step: an integer representing current step number
# - warmup_step: an integer representing the warmup threshold step
# 
# The function uses only basic integer comparison and division,
# so we just need integer values.

ARGS = {
    "global_step": 5,
    "warmup_step": 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
collate_fn Not yet run
unverified (harvested, no recorded run)
thunlp/Few-NERD/util/data_loader.py
code served (permissive licence) · get_code("1905bc80075cf1fb")
How it ran

no invocation recorded.

get_abstract_transitions Not yet run
unverified (harvested, no recorded run)
thunlp/Few-NERD/util/framework.py
code served (permissive licence) · get_code("e10ae768920721ff")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
warmup_linear 2 other papers
2 dated earlier
1910.07124 (2019-10)
FewRel 2.0: Towards More Challenging Few-Shot Relation Classification
2007.02387 (2020-07)
Few-shot Relation Extraction via Bayesian Meta-learning on Relation Graphs

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recently, considerable literature has grown up around the theme of few-shot named entity recognition (NER), but little published benchmark data specifically focused on the practical and challenging task. Current approaches collect existing supervised NER datasets and reorganize them into the few-shot setting for empirical study. These strategies conventionally aim to recognize coarse-grained entity types with few examples, while in practice, most unseen entity types are fine-grained. In this paper, we present FEW-NERD, a large-scale human-annotated few-shot NER dataset with a hierarchy of 8 coarse-grained and 66 finegrained entity types. FEW-NERD consists of 188,238 sentences from Wikipedia, 4,601,160 words are included and each is annotated as context or a part of a two-level entity type. To the best of our knowledge, this is the first few-shot NER dataset and the largest humancrafted NER dataset. We construct benchmark tasks with different emphases to comprehensively assess the generalization capability of models. Extensive empirical results and analysis show that FEW-NERD is challenging and the problem requires further research. We make FEW-NERD public at https:// ningding97.github.io/fewnerd/.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2105.07464")
get_code_for_paper("2105.07464")
have("2105.07464")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2105.07464.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2105.07464.svg)](https://syntology.ai/paper/2105.07464)

Connect an agent — have() is free.