knowprompt

[WWW 2022] KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction

https://github.com/zjunlp/knowprompt

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

dataset dialogre few-shot-learning knowledge-informed-prompt-learning knowprompt prompt prompt-learning prompt-tuning pytorch re relation-extraction semeval tacred text-classification
Last synced: 6 months ago · JSON representation ·

Repository

[WWW 2022] KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction

Basic Info
  • Host: GitHub
  • Owner: zjunlp
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 27.9 MB
Statistics
  • Stars: 202
  • Watchers: 6
  • Forks: 35
  • Open Issues: 0
  • Releases: 0
Topics
dataset dialogre few-shot-learning knowledge-informed-prompt-learning knowprompt prompt prompt-learning prompt-tuning pytorch re relation-extraction semeval tacred text-classification
Created over 4 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

KnowPrompt

Code and datasets for the WWW2022 paper KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction.

  • ❗NOTE: We provide a paper-list at PromptKG and open-source KnowLM, a knowledgeable large language model framework with pre-training and instruction fine-tuning code (supports multi-machine multi-GPU setup).

What's New

Apr,5 2023

Dec,7 2022

Sept,21 2022

March,30 2022

Jan,14 2022

Requirements

It is recommended to use a virtual environment to run KnowPrompt.

```bash conda create -n knowprompt python=3.8

conda activate knowprompt ```

To install requirements:

pip install -r requirements.txt

Datasets

We provide all the datasets and prompts used in our experiments.

The expected structure of files is:

``` knowprompt |-- dataset | |-- semeval | | |-- train.txt
| | |-- dev.txt | | |-- test.txt | | |-- temp.txt | | |-- rel2id.json | |-- dialogue | | |-- train.json
| | |-- dev.json | | |-- test.json | | |-- rel2id.json | |-- tacred | | |-- train.txt
| | |-- dev.txt | | |-- test.txt | | |-- temp.txt | | |-- rel2id.json | |-- tacrev | | |-- train.txt
| | |-- dev.txt | | |-- test.txt | | |-- temp.txt | | |-- rel2id.json | |-- retacred | | |-- train.txt
| | |-- dev.txt | | |-- test.txt | | |-- temp.txt | | |-- rel2id.json |-- scripts | |-- semeval.sh | |-- dialogue.sh | |-- ...

```

Run the experiments

Initialize the answer words

Use the comand below to get the answer words to use in the training.

shell python get_label_word.py --model_name_or_path bert-large-uncased --dataset_name semeval

The {answer_words}.ptwill be saved in the dataset, you need to assign the model_name_or_path and dataset_name in the get_label_word.py.

Split dataset

Download the data first, and put it to dataset folder. Run the comand below, and get the few shot dataset.

shell python generate_k_shot.py --data_dir ./dataset --k 8 --dataset semeval cd dataset cd semeval cp rel2id.json val.txt test.txt ./k-shot/8-1 You need to modify the k and dataset to assign k-shot and dataset. Here we default seed as 1,2,3,4,5 to split each k-shot, you can revise it in the generate_k_shot.py

Let's run

Our script code can automatically run the experiments in 8-shot, 16-shot, 32-shot and standard supervised settings with both the procedures of train, eval and test. We just choose the random seed to be 1 as an example in our code. Actually you can perform multiple experments with different seeds.

Example for SEMEVAL

Train the KonwPrompt model on SEMEVAL with the following command:

```bash

bash scripts/semeval.sh # for roberta-large `` As the scripts forTACRED-Revist,Re-TACRED,Wiki80` included in our paper are also provided, you just need to run it like above example.

Example for DialogRE

As the data format of DialogRE is very different from other dataset, Class of processor is also different. Train the KonwPrompt model on DialogRE with the following command:

```bash

bash scripts/dialogue.sh # for roberta-base ```

More emperical results

We report emperical results on more datasets in the EMNLP 2022 (Findings) paper "Towards Realistic Low-resource Relation Extraction: A Benchmark with Empirical Baseline Study" [code].

Acknowledgement

Part of our code is borrowed from code of PTR: Prompt Tuning with Rules for Text Classification, many thanks.

Citation

If you use the code, please cite the following paper:

bibtex @inproceedings{DBLP:conf/www/ChenZXDYTHSC22, author = {Xiang Chen and Ningyu Zhang and Xin Xie and Shumin Deng and Yunzhi Yao and Chuanqi Tan and Fei Huang and Luo Si and Huajun Chen}, editor = {Fr{\'{e}}d{\'{e}}rique Laforest and Rapha{\"{e}}l Troncy and Elena Simperl and Deepak Agarwal and Aristides Gionis and Ivan Herman and Lionel M{\'{e}}dini}, title = {KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction}, booktitle = {{WWW} '22: The {ACM} Web Conference 2022, Virtual Event, Lyon, France, April 25 - 29, 2022}, pages = {2778--2788}, publisher = {{ACM}}, year = {2022}, url = {https://doi.org/10.1145/3485447.3511998}, doi = {10.1145/3485447.3511998}, timestamp = {Tue, 26 Apr 2022 16:02:09 +0200}, biburl = {https://dblp.org/rec/conf/www/ChenZXDYTHSC22.bib}, bibsource = {dblp computer science bibliography, https://dblp.org} }

Owner

  • Name: ZJUNLP
  • Login: zjunlp
  • Kind: organization
  • Location: China

A NLP & KG Group of Zhejiang University

Citation (CITATION.cff)

cff-version: "1.0.0"
message: "If you use the code, please cite the following paper:"
title: "deepke"
repository-code: "https://https://github.com/zjunlp/DeepKE"
authors: 
  - family-names: Chen
    given-names: Xiang
  - family-names: Zhang
    given-names: Ningyu
  - family-names: Xie
    given-names: Xin
  - family-names: Deng
    given-names: Shumin
  - family-names: Yao
    given-names: Yunzhi
  - family-names: Tan
    given-names: Chuanqi
  - family-names: Huang
    given-names: Fei
  - family-names: Si
    given-names: Luo
  - family-names: Chen
    given-names: Huajun
preferred-citation:
  type: article
  title: "KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction"
  authors:
  - family-names: Chen
    given-names: Xiang
  - family-names: Zhang
    given-names: Ningyu
  - family-names: Xie
    given-names: Xin
  - family-names: Deng
    given-names: Shumin
  - family-names: Yao
    given-names: Yunzhi
  - family-names: Tan
    given-names: Chuanqi
  - family-names: Huang
    given-names: Fei
  - family-names: Si
    given-names: Luo
  - family-names: Chen
    given-names: Huajun
  journal: "International World Wide Web Conferences (WWW)"
  year: 2022

GitHub Events

Total
  • Watch event: 8
  • Fork event: 1
Last Year
  • Watch event: 8
  • Fork event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 40
  • Total Committers: 3
  • Avg Commits per committer: 13.333
  • Development Distribution Score (DDS): 0.5
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Eric z****0@v****m 20
njcx-ai c****j@o****m 10
CheaSim 8****3@q****m 10
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 33
  • Total pull requests: 0
  • Average time to close issues: 8 days
  • Average time to close pull requests: N/A
  • Total issue authors: 29
  • Total pull request authors: 0
  • Average comments per issue: 4.03
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 0
  • Average time to close issues: 9 days
  • Average time to close pull requests: N/A
  • Issue authors: 4
  • Pull request authors: 0
  • Average comments per issue: 4.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Facico (2)
  • githubgtl (2)
  • chenhaishun (2)
  • typhoonlee (1)
  • Goye-Cassini (1)
  • cpmss521 (1)
  • ZHUXUHAN (1)
  • jyf123 (1)
  • Frankie123421 (1)
  • MrZilinXiao (1)
  • anushkasw (1)
  • zfbz (1)
  • yccckid (1)
  • loxs123 (1)
  • xerrors (1)
Pull Request Authors
Top Labels
Issue Labels
question (10) help wanted (1)
Pull Request Labels