SLIMER: Show Less Instruct More Entity Recognition

GitHub repository: https://github.com/andrewzamai/SLIMER

Improved (+12.5 %) LLaMA-3 implementation https://huggingface.co./expertai/SLIMER-LLaMA3

SLIMER for Italian language can be found at: https://huggingface.co./expertai/LLaMAntino-3-SLIMER-IT

SLIMER is an LLM specifically instructed for zero-shot NER on English language.

Instructed on a reduced number of samples, it is designed to tackle never-seen-before Named Entity tags by leveraging a prompt enriched with a DEFINITION and GUIDELINES for the NE to be extracted.

Instruction Tuning Prompt
Instruction Tuning Prompt

[INST]

You are given a text chunk (delimited by triple quotes) and an instruction.
Read the text and answer to the instruction in the end.

"""
{input text}
"""

Instruction: Extract the Named Entities of type DATE from the text chunk you have read.

You are given a DEFINITION and some GUIDELINES.

DEFINITION: DATE refers to specific points in time, including days, months, years, and relative time expressions like 'Week 2'.

GUIDELINES: Avoid labeling non-specific time references like 'recently' or 'soon'. Exercise caution with ambiguous terms like 'May' (month or verb) and 'Wednesday Adams' (person's name which includes a day of the week).

Return a JSON list of instances of this Named Entity type. Return an empty list if no instances are present.

[/INST]

Currently existing approaches fine-tune on an extensive number of entity classes (around 13K) and assess zero-shot NER capabilities on Out-Of-Distribution input domains. SLIMER performs comparably to these state-of-the-art models on OOD input domains, while being trained only a reduced number of samples and a set of NE tags that overlap in lesser degree with test sets.

We extend the standard zero-shot evaluations (CrossNER and MIT) with BUSTER, which is characterized by financial entities that are rather far from the more traditional tags observed by all models during training. An inverse trend can be observed, with SLIMER emerging as the most effective in dealing with these unseen labels, thanks to its lighter instruction tuning methodology and the use of definition and guidelines.

Model Backbone #Params MIT CrossNER BUSTER AVG
Movie Restaurant AI Literature Music Politics Science
ChatGPT gpt-3.5-turbo - 5.3 32.8 52.4 39.8 66.6 68.5 67.0 - -
InstructUIE Flan-T5-xxl 11B 63.0 21.0 49.0 47.2 53.2 48.2 49.3 - -
UniNER-type LLaMA-1 7B 42.4 31.7 53.5 59.4 65.0 60.8 61.1 34.8 51.1
UniNER-def LLaMA-1 7B 27.1 27.9 44.5 49.2 55.8 57.5 52.9 33.6 43.6
UniNER-type+sup. LLaMA-1 7B 61.2 35.2 62.9 64.9 70.6 66.9 70.8 37.8 58.8
GoLLIE Code-LLaMA 7B 63.0 43.4 59.1 62.7 67.8 57.2 55.5 27.7 54.6
GLiNER-L DeBERTa-v3 0.3B 57.2 42.9 57.2 64.4 69.6 72.6 62.6 26.6 56.6
GNER-T5 Flan-T5-xxl 11B 62.5 51.0 68.2 68.7 81.2 75.1 76.7 27.9 63.9
GNER-LLaMA LLaMA-1 7B 68.6 47.5 63.1 68.2 75.7 69.4 69.9 23.6 60.8
SLIMER w/o D&G LLaMA-2-chat 7B 46.4 36.3 49.6 58.4 56.8 57.9 53.8 40.4 49.9
SLIMER LLaMA-2-chat 7B 50.9 38.2 50.1 58.7 60.0 63.9 56.3 45.3 52.9
JSON Template
JSON SLIMER prompt
{
  "description": "SLIMER prompt",
  "prompt_input": "[INST] You are given a text chunk (delimited by triple quotes) and an instruction.\nRead the text and answer to the instruction in the end.\n\"\"\"\n{input}\n\"\"\"\nInstruction: Extract the Named Entities of type {NE_name} from the text chunk you have read. You are given a DEFINITION and some GUIDELINES.\nDEFINITION: {definition}\nGUIDELINES: {guidelines}\nReturn a JSON list of instances of this Named Entity type. Return an empty list if no instances are present.\n[/INST]\n"
}
from vllm import LLM, SamplingParams

vllm_model = LLM(model="expertai/SLIMER")

sampling_params = SamplingParams(temperature=0, max_tokens=128, stop=['</s>'])

prompts = [prompter.generate_prompt(instruction, input) for instruction, input in instruction_input_pairs]
responses = vllm_model.generate(prompts, sampling_params)

Citation

If you find SLIMER useful in your research or work, please cite the following paper:

@misc{zamai2024lessinstructmoreenriching,
      title={Show Less, Instruct More: Enriching Prompts with Definitions and Guidelines for Zero-Shot NER}, 
      author={Andrew Zamai and Andrea Zugarini and Leonardo Rigutini and Marco Ernandes and Marco Maggini},
      year={2024},
      eprint={2407.01272},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2407.01272}, 
}
Downloads last month
48
Safetensors
Model size
6.74B params
Tensor type
BF16
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Dataset used to train expertai/SLIMER

Collection including expertai/SLIMER