Giter VIP home page Giter VIP logo

spanproto's Introduction

SpanProto:A Two-stage Span-based Prototypical Network for Few-shot Named Entity Recognition

This project is implemented for the EMNLP2022 (main conference) paper: "SpanProto: A Two-stage Span-based Prototypical Network for Few-shot Named Entity Recognition". Our code is based on pytorch and huggingface transformers.

Ps: This project is also committed at Alibaba EasyNLP. We will very HAPPY if you star and fork our projects!

In this paper, we present a novel two-stage span-based prototypical network (SpanProto) for few-shot named entity recognition (NER).

The main motivations are:

  • Traditional few-shot NER methods ignore of the mentions boundary information, which is more crucial to NER;
  • In few-shot NER, there are only k-shot entities of each class, but has many non-entity tokens (i.e., tagging "O") which may disturb the performance.

The main methods:

  • We decompose the few-shot NER into two stages, including span extraction and mention classifying.
  • In the span extractor, we convert the original sequentail tagging into a matrix, where each element stands for one span (start and end position) and 1 means this span is an entity and 0 means not. We can train the span extractor via cross-entropy on support set, and recall all candidate spans on query set by model inference.
  • In the mention classifier, we capture each span representations and train the model with protopical learning on support set. When inference on query set, we split out false negative spans via margin-based loss, and predict others class by calculating and sorting the distance between each span embeddings and prototype vectors.

The model architecture of SpanProto


Data and Models

Please download Few-NERD through this link: https://ningding97.github.io/fewnerd/, and move it under the dir: dataset/. (You can directly download from https://cloud.tsinghua.edu.cn/f/56fb277d3fd2437a8ee3/?dl=1, and unzip it by unzip episode-data.zip.)

We recommend you directly downloading the backbone (e.g., bert-base-uncased) through huggingface, and move it to a new dir (e.g., pre-trained-lm/bert-base-uncased).

Code Runing

You can run this code by:

sh scripts/fewner/run_fewnerd.sh

In this script, you can define the following values:

  • mode: the mode of Few-NERD. ("inter" or "intra")
  • N: the number of entity classes (w/o. "O" type). (5 or 10)
  • Q: the number of entities of each class in one episode support set. (1 or 5)
  • K: the number of entities of each class in one episode query set. (1 or 5)

Acknowledgement

This work has been supported by the National Natural Science Foundation of China, Alibaba Group through the Alibaba Innovation Research Program, the National Natural Science Foundation of China, the Research Project of Shanghai Science and Technology Commission and The Fundamental Research Funds for the Central Universities.

Citation

@article{DBLP:journals/corr/abs-2210-09049,
  author    = {Jianing Wang and
               Chengyu Wang and
               Chuanqi Tan and
               Minghui Qiu and
               Songfang Huang and
               Jun Huang and
               Ming Gao},
  title     = {SpanProto: {A} Two-stage Span-based Prototypical Network for Few-shot
               Named Entity Recognition},
  journal   = {CoRR},
  volume    = {abs/2210.09049},
  year      = {2022},
  url       = {https://doi.org/10.48550/arXiv.2210.09049},
  doi       = {10.48550/arXiv.2210.09049},
  eprinttype = {arXiv},
  eprint    = {2210.09049},
  timestamp = {Wed, 19 Oct 2022 12:47:31 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2210-09049.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

spanproto's People

Contributors

wjn1996 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.