Giter Site home page Giter Site logo

pandinosaurus / seq2seq-prompt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thunlp/seq2seq-prompt

0.0 1.0 0.0 1.56 MB

Source code for COLING 2022 paper "Automatic Label Sequence Generation for Prompting Sequence-to-sequence Models"

License: MIT License

Shell 10.72% Python 89.28%

seq2seq-prompt's Introduction

Seq2Seq-Prompt

Source code and dataset for Automatic Label Sequence Generation for Prompting Sequence-to-sequence Models.

Quick links

Overview

In this work we propose AutoSeq, a general-purpose, fully automatic prompting method that depends only on few-shot annotations.

Figure: Illustration of AutoSeq. We first use T5 to generate label sequence candidates given each label's training instances; we then use contrastive re-ranking to get label sequences that are more label-specific; in the end we enumerate all the combinations and re-rank by the fine-tuning performance.

Requirements

To run our code, please install all the dependencies:

pip install -r requirements.txt

Prepare the data

Please download the official GLUE and SuperGLUE data and extract the files to ./data/GLUE/TASK_NAME and ./data/SuperGLUE/TASK_NAME.

Then use the following command to generate the few-shot data:

python tools/generate_k_shot_data_for_GLUE.py
python tools/generate_k_shot_data_for_SuperGLUE.py

Run AutoSeq

To reproduce our results, please use the scripts we provide. For convenience, we use SST-2 as an example below.

Main results

AutoSeq:

task=SST-2 bash scripts/t5_seq.sh

AutoWord:

task=SST-2 bash scripts/t5_word.sh

Manual:

task=SST-2 bash scripts/t5_man.sh

Manual with eng.:

task=SST-2 bash scripts/t5_man_eng.sh

Fine-tuning:

task=SST-2 bash scripts/t5_fine_tuning.sh

Fine-tuning (Full train set):

task=SST-2 bash scripts/t5_full_fine_tuning.sh

Prompt tuning:

task=SST-2 bash scripts/t5_prompt_tuning.sh

All the results will be stored in ./log. To gather all the results, run the following command:

python tools/gather_result.py --condition "{'tag': 'exp-autoseq-SST-2', 'task_name': 'sst-2', 'few_shot_type': 'prompt'}"

We also release the original log of our experiments to facilitate the reproduction.

Search for automatic label sequence and label word mappings

You can find our generated mappings in ./auto_label_sequences and ./auto_label_words.

We first generate candidate label sequence and label word mappings by running:

python tools/generate_label_sequences.py
python tools/generate_label_words.py

The generated candidates will be saved in ./my_auto_label_sequences and ./my_auto_label_words.

Then we do prompt-based fine-tuning of all the mappings by:

task=SST-2 bash scripts/sort_mapping.sh

Finally we sort them based on dev set performance:

python tools/sort_mapping.py --condition "{'tag': 'exp-mapping-SST-2', 'task_name': 'sst-2'}" --mapping_dir auto_label_sequences

Citation

Please cite our paper if you use AutoSeq in your work:

@inproceedings{yu2022automatic,
   title={Automatic Label Sequence Generation for Prompting Sequence-to-sequence Models},
   author={Zichun Yu and Tianyu Gao and Zhengyan Zhang and Yankai Lin and Zhiyuan Liu and Maosong Sun and Jie Zhou},
   booktitle={International Conference on Computational Linguistics (COLING)},
   year={2022}
}

seq2seq-prompt's People

Contributors

yuzc19 avatar zzy14 avatar

Watchers

 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.