Coder Social home page Coder Social logo

sukeey / container Goto Github PK

View Code? Open in Web Editor NEW

This project forked from psunlpgroup/container

0.0 0.0 0.0 114 KB

Code for ACL 2022 paper "CONTaiNER: Few-Shot Named Entity Recognition via Contrastive Learning"

License: MIT License

Shell 2.39% Python 97.61%

container's Introduction

CONTaiNER

Source code and relevant scripts for our ACL 2022 paper: "CONTaiNER: Few-Shot Named Entity Recognition via Contrastive Learning".

Requirements

  • Python 3.8.5
  • PyTorch (tested version 1.8.1)
  • Transformers (tested version 4.6.0)
  • seqeval

You can install all required Python packages with pip install -r requirements.txt

Dataset

   wget -O episode_data.zip https://cloud.tsinghua.edu.cn/f/8483dc1a34da4a34ab58/?dl=1
   wget -O data/few-nerd/inter/train.txt https://cloud.tsinghua.edu.cn/f/45d55face2a14c098a13/?dl=1
   wget -O data/few-nerd/intra/train.txt https://cloud.tsinghua.edu.cn/f/b169cfbeb90a48c1bf23/?dl=1

Update (6/13/2022): Looks like the previous links to Few-NERD dataset is expired. Thanks to jiayuemoon for pointing this out. Please follow this issue to get the updated link.

  • Execute process_fewnerd.sh for preprocessing and organization of support sets and test sets
  • To run the other tests, please obtain permission (publicly not available) and download OntoNotes and other datasets (Update: the corresponding support sets have been added for the target datasets). Then preprocess them in a similar manner. The datasets are required to be in the OntoNotes like NER format as organized in the case of Few-NERD.

Running CONTaiNER

  • Install all dependencies in requirements.txt
  • If you want to use the evaluate the few-shot performance, download the pre-trained models (inter and intra) here, and decompress in the main directory
  • Run exec_container.sh with the following parameters: [task-group] [gpu to use] [way (5/10)] [shots (1/5)]
    • Example: To run evaluation on Few-NERD (intra) on 5 way 5~10 shot task with GPU 0, run exec_container.sh intra 0 5 5
  • Since support set - test set pairs are evaluated separately, this test is lengthy. Thus by default the script only checks the performance on first 50 pairs. To do the full test, please increase the iteratrions in exec_container.sh to 5000.
  • Finally, calculate the micro-averaged F1 as done in the Few-NERD paper by running calc-micro-avg.py with the argument --target_dir [directory to results.txt] --range [iterations in the script ran]. Use the directory that contains all the results of the test.
  • To train the model from scratch with inter and intra training data, remove any remaining model files in saved_models and run container.py similar to exec_container.sh and use the argument --do_train. To learn further about all the arguments, please see container.py and exec_container.sh

Citation

If you use our work, please cite:

@inproceedings{das2022container,
  title={CONTaiNER: Few-Shot Named Entity Recognition via Contrastive Learning},
  author={Das, Sarkar Snigdha Sarathi and Katiyar, Arzoo and Passonneau, Rebecca J and Zhang, Rui},
  booktitle={ACL},
  year={2022}
}

container's People

Contributors

sarathismg 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.