GitXplorerGitXplorer
t

PromptNER

public
88 stars
7 forks
6 issues

Commits

List of commits on branch main.
Unverified
3857235fce0844a8441af9a6ef9b03ec619ce575

update data

ttricktreat committed a year ago
Unverified
de3f3391b1153e39c4ca8b7bc548cd55e3a0a3a0

update data #5

ttricktreat committed a year ago
Unverified
d5994f67277aae2aff8e65e118c9ab367fcc3107

first commit

ttricktreat committed 2 years ago

README

The README file for this repository.

PromptNER

Code for PromptNER: Prompt Locating and Typing for Named Entity Recognition, accepted at ACL 2023.

The left figure show a comparison of the type-oriented (a) and span-oriented (b) prompt learning with the proposed PromptNER (c). C, N and M denote the number of entity types, words and prompts, respectively; The right figure shows an overview of PromptNER. The left part describes the model’s inference process and the right part describes the dynamic template filling mechanism during training.

Setup

conda create -n promptner python=3.8
conda activate promptner
pip install -r requirements.txt

Usage

This repository is under construction. We will further detail the usage of the code and the data.

Data

For the data, please refer to data/README.md.

Training

  1. Supervised Setting:
  • PromptNER[BERT] on ACE2004:
python prompt4ner.py train --config configs/bert/ace2004.conf
  • PromptNER[RoBERTa] on ACE2005:
python prompt4ner.py train --config configs/roberta/ace2005.conf
  1. Low-resource Setting:
  • Wiki Warmup Pretrain:
python prompt4ner.py train --config configs/few_shot/wiki_pretrain/pretrain.conf
  • In-domain Setting:
python prompt4ner.py train --config configs/few_shot/in_domain/conll2003_sampling.conf
  • Cross-domain Setting:

First train PromptNER on source domain (CoNLL 2003) based on the pre-trained model from Wiki Warmup Pretrain:

python prompt4ner.py train  --config configs/few_shot/cross_domain/source.conf

Then train PromptNER on target domain (MIT Movie) using the model from the previous step:

python prompt4ner.py train --config configs/few_shot/cross_domain/mm.conf

Evaluation

For evaluation, please first replace the model_path@configs/eval.conf with the path of the trained model. Then run:

python prompt4ner.py eval --config configs/eval.conf