Code repo for EMNLP21 paper "Zero-Shot Information Extraction as a Unified Text-to-Triple Translation"

Related tags

Deep Learning deepex
Overview

Zero-Shot Information Extraction as a Unified Text-to-Triple Translation

Source code repo for paper Zero-Shot Information Extraction as a Unified Text-to-Triple Translation, EMNLP 2021.

Installation

git clone --recursive [email protected]:cgraywang/deepex.git
cd ./deepex
conda create --name deepex python=3.7 -y
conda activate deepex
pip install -r requirements.txt
pip install -e .

Requires PyTorch version 1.5.1 or above with CUDA. PyTorch 1.7.1 with CUDA 10.1 is tested. Please refer to https://pytorch.org/get-started/locally/ for installing PyTorch.

Dataset Preparation

Relation Classification

FewRel

You can add --prepare-rc-dataset argument when running the scripts in this section, which would allow the script to automatically handle the preparation of FewRel dataset.

Or, you could manually download and prepare the FewRel dataset using the following script:

bash scripts/rc/prep_FewRel.sh

The processed data will be stored at data/FewRel/data.jsonl.

TACRED

TACRED is licensed under LDC, please first download TACRED dataset from link. The downloaded file should be named as tacred_LDC2018T24.tgz.

After downloading and correctly naming the tacred .tgz data file, you can add --prepare-rc-dataset argument when running the scripts in this section, which would allow the script to automatically handle the preparation of TACRED dataset.

Or, you could manually download and prepare the TACRED dataset using the following script:

bash scripts/rc/prep_TACRED.sh

The processed data will be stored at data/TACRED/data.jsonl.

Scripts for Reproducing Results

This section contains the scripts for running the tasks with default setting (e.g.: using model bert-large-cased, using 8 CUDA devices with per-device batch size equal to 4).

To modify the settings, please checkout this section.

Open Information Extraction

bash tasks/OIE_2016.sh
bash tasks/PENN.sh
bash tasks/WEB.sh
bash tasks/NYT.sh

Relation Classification

bash tasks/FewRel.sh
bash tasks/TACRED.sh

Arguments

General script:

python scripts/manager.py --task=<task_name> <other_args>

The default setting is:

python scripts/manager.py --task=<task_name> --model="bert-large-cased" --beam-size=6
                          --max-distance=2048 --batch-size-per-device=4 --stage=0
                          --cuda=0,1,2,3,4,5,6,7

All tasks are already implemented as above .sh files in tasks/, using the default arguments.

The following are the most important command-line arguments for the scripts/manager.py script:

  • --task: The task to be run, supported tasks are OIE_2016, WEB, NYT, PENN, FewRel and TACRED.
  • --model: The pre-trained model type to be used for generating attention matrices to perform beam search on, supported models are bert-base-cased and bert-large-cased.
  • --beam-size: The beam size during beam search.
  • --batch-size-per-device: The batch size on a single device.
  • --stage: Run task starting from an intermediate stage:
    • --stage=0: data preparation and beam-search
    • --stage=1: post processing
    • --stage=2: ranking
    • --stage=3: evaluation
  • --prepare-rc-dataset: If true, automatically run the relation classification dataset preparation scripts. Notice that this argument should be turned on only for relation classification tasks (i.e.: FewRel and TACRED).
  • --cuda: Specify CUDA gpu devices.

Run python scripts/manager.py -h for the full list.

Results

NOTE

We are able to obtain improved or same results compared to the paper's results. We will release the code and datasets for factual probe soon!

Related Work

We implement an extended version of the beam search algorithm proposed in Language Models are Open Knowledge Graphs in src/deepex/model/kgm.py.

Citation

@inproceedings{wang-etal-2021-deepex,
    title = "Zero-Shot Information Extraction as a Unified Text-to-Triple Translation",
    author = "Chenguang Wang and Xiao Liu and Zui Chen and Haoyun Hong and Jie Tang and Dawn Song",
    booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing",
    year = "2021",
    publisher = "Association for Computational Linguistics"
}

@article{wang-etal-2020-language,
    title = "Language Models are Open Knowledge Graphs",
    author = "Chenguang Wang and Xiao Liu and Dawn Song",
    journal = "arXiv preprint arXiv:2010.11967",
    year = "2020"
}
Comments
  • About the reproduce results of deepex

    About the reproduce results of deepex

    Hi, thank you for your good work in OIE2016, but I use your default parameters with 1 V100 GPU, but I get the following results:

    image

    Did I have some mistakes that I cannot get the 0.72 F1?

    Also, I find that the constractive pretrain deep-ranking-model has not been released and the code is inference code now. It needs about 3 hours to test. Am I right?

    Hope for your reply!

    opened by EternalEep 3
  • Details of output from OIE_2016.sh

    Details of output from OIE_2016.sh

    Hello, thanks for your contribution to Open Information Extraction research.

    I'm currently working on using your repo to create triples from the raw texts in Wikipedia by using your code.

    bash tasks/OIE_2016.sh
    

    I changed the data_dir to construct triples then executed the above code. Code works fine, and it gave me the output called search_res.json.

    The problem is, I can't find the description for the format of this output. I can't find the keys for each value of this output.

    {"deduplicated:": {"Another Temporary Gallery [SEP] gallery [SEP] The Museum": [8, 0.7081716619431973, [[0, 25], [65, 75]], 27, 0] ...
    

    For example, the thing I want to know is this list. [8, 0.7081716619431973, [[0, 25], [65, 75]], 27, 0] Coudl you briefly explain what each of this value mean?

    opened by Metalchaos8527 2
  • Help running inference

    Help running inference

    Hi, I am unable to figure out how to run OIE inference using the deepex models. Can you please help answering:

    1. Where is the model
    2. how to run OIE on the model thanks,
    opened by adityakatta 2
  • Unable to run bash tasks/OIE_2016.sh

    Unable to run bash tasks/OIE_2016.sh

    PyTorch 1.7.1 with CUDA 10.1, single GPU.

    After running

    git clone --recursive [email protected]:cgraywang/deepex.git
    cd ./deepex
    conda create --name deepex python=3.7 -y
    conda activate deepex
    pip install -r requirements.txt
    pip install -e .
    
    bash tasks/OIE_2016.sh
    

    I am getting

    FileNotFoundError: [Errno 2] No such file or directory: 'result/OIE_2016.bert-large-cased.np.d2048.b6.sorted/P0_result.json'
    

    I suspect that because the output file was not generated, so digging in the trace log I found:

    RuntimeError
    : RuntimeErrorRuntimeError
    NCCL error in: /opt/conda/conda-bld/pytorch_1607370141920/work/torch/lib/c10d/ProcessGroupNCCL.cpp:784, invalid usage, NCCL version 2.7.8: RuntimeError: 
    NCCL error in: /opt/conda/conda-bld/pytorch_1607370141920/work/torch/lib/c10d/ProcessGroupNCCL.cpp:784, invalid usage, NCCL version 2.7.8: NCCL error in: /opt/conda/conda-bld/pytorch_1607370141920/work/torch/lib/c10d/ProcessGroupNCCL.cpp:784, invalid usage, NCCL version 2.7.8RuntimeError
    

    And some other NCCL errors. I am not sure where to start debugging.

    Thank you in advance.

    I am trying to do a simple text-to-triple inference task (openIE) and I thought that this would be the way to start.

    opened by filip-cermak 1
  • Regarding the Task-agnostic Corpus

    Regarding the Task-agnostic Corpus

    Thank you for your great work on zero-shot IE. I am very impressed with the results while I am very curious on what is the 'task agnostic corpus', is it an open dataset?

    opened by tonytan48 1
  • git clone时出现问题

    git clone时出现问题

    使用 ‘git clone --recursive [email protected]:cgraywang/deepex.git’ 进行下载时出现:

    Cloning into 'deepex'... Permission denied (publickey). fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

    image 请问这个问题的原因是什么,感谢

    opened by panghaoyu 0
  • Poor triple extractor performance (OpenIE)

    Poor triple extractor performance (OpenIE)

    I followed the README and successfully run the OpenIE16 benchmark, then I modified OIE_2016.json file to point to my directory with test.txt file containing just one line Julia owns two cats and one dog. The output is however really poor, the expected triples [Julia, owns, two cats] and [Julia, owns, one dog] have low scores and there are many other (ill-created) triples, sometimes with even higher score values (complete output attached below).

    Is this the normal behavior of the model? Why is the performance so poor? Is there a systematic issue with how I am doing this?

    ['$input_txt:$ Julia owns two cats and one dog',
     {'deduplicated:': {'Julia [SEP] owns two [SEP] One Dog': [2,
        0.15572701767086983,
        [[0, 5], [24, 31]],
        8,
        0],
       'Julia [SEP] owns two cats [SEP] One Dog': [5,
        0.38142501655966043,
        [[0, 5], [24, 31]],
        21,
        0],
       'Julia [SEP] cats [SEP] One Dog': [2,
        0.09584893216378987,
        [[0, 5], [24, 31]],
        6,
        0],
       'Two Cats [SEP] cats [SEP] One Dog': [2,
        0.09491016250103712,
        [[11, 19], [24, 31]],
        6,
        0],
       'Julia [SEP] owns two cats and [SEP] One Dog': [6,
        0.4070159122347832,
        [[0, 5], [24, 31]],
        26,
        0],
       'Julia [SEP] cats and [SEP] Two Cats': [2,
        0.14055378548800945,
        [[0, 5], [11, 19]],
        9,
        0],
       'Julia [SEP] two cats [SEP] One Dog': [1,
        0.06196947582066059,
        [[0, 5], [24, 31]],
        4,
        0],
       'Julia [SEP] one [SEP] Two Cats': [1,
        0.06188515014946461,
        [[0, 5], [11, 19]],
        4,
        0],
       'Julia [SEP] owns [SEP] Two Cats': [6,
        0.2982198027893901,
        [[0, 5], [11, 19]],
        20,
        0],
       'Julia [SEP] owns [SEP] One Dog': [4,
        0.17877793312072754,
        [[0, 5], [24, 31]],
        12,
        0],
       'Julia [SEP] two [SEP] One Dog': [3,
        0.1447404371574521,
        [[0, 5], [24, 31]],
        10,
        0],
       'Julia [SEP] and one [SEP] Two Cats': [5,
        0.32297115167602897,
        [[0, 5], [11, 19]],
        23,
        0],
       'Two Cats [SEP] owns [SEP] One Dog': [8,
        0.44091942673549056,
        [[11, 19], [24, 31]],
        32,
        0],
       'Julia [SEP] and [SEP] One Dog': [1,
        0.04122000187635422,
        [[0, 5], [24, 31]],
        3,
        0],
       'Julia [SEP] cats and one [SEP] Two Cats': [2,
        0.10967723815701902,
        [[0, 5], [11, 19]],
        8,
        0],
       'Two Cats [SEP] one [SEP] One Dog': [2,
        0.08130411058664322,
        [[11, 19], [24, 31]],
        6,
        0],
       'Two Cats [SEP] owns two [SEP] One Dog': [8,
        0.4609282175078988,
        [[11, 19], [24, 31]],
        36,
        0],
       'Julia [SEP] and [SEP] Two Cats': [3,
        0.14550211280584335,
        [[0, 5], [11, 19]],
        12,
        0],
       'Two Cats [SEP] two [SEP] One Dog': [4,
        0.19086267473176122,
        [[11, 19], [24, 31]],
        16,
        0],
       'Two Cats [SEP] and [SEP] One Dog': [6,
        0.1381131475791335,
        [[11, 19], [24, 31]],
        21,
        0]}}]
    
    opened by filip-cermak 1
  • Running inference on sentences

    Running inference on sentences

    Hi, I am unable to figure out how to use the deepex model. I want to input a sentence and get the triplets generated from it. Is there any code snippet/script in the repo that can help me do that?

    Thanks

    opened by PratikGarai 3
  • Reproducing results shown in paper

    Reproducing results shown in paper

    Hi

    Could you described the steps to reproduce the results in your paper for OIE 2016 and the other systems. You used the supervised-oie repo and the benchmark included in there. There is also a related repo from the same author oie-benchmark with the same evaluation. However they are slightly different and have had updates and neither seems to work out of the box when running the eval.sh script which should produce the PR Curve plots (part of what i was interested in comparing).

    Looking at them its unclear which version of the benchmark corpus is being used and whether you picked test (or dev) split or used the whole dataset. The default script seems to use all the data but when going through the tasks you provide it seems to use the test split.

    Thanks

    Tony

    opened by antonyscerri 1
  • 测试 Born in Glasgow, Fisher is a graduate of the London Opera Centre 生成三元组结果

    测试 Born in Glasgow, Fisher is a graduate of the London Opera Centre 生成三元组结果

    使用论文中举的例子 ,”Born in Glasgow, Fisher is a graduate of the London Opera Centre. “ ,在第一步generator中抽取的三元组结果比较混乱,不知是否正常(OIE2016结果复现没有问题,top3 f1=72.6)。模型为默认的bert-large-cased。 search_res.json.txt

    opened by zzypeak 5
Repo for the Video Person Clustering dataset, and code for the associated paper

Video Person Clustering Repo for the Video Person Clustering dataset, and code for the associated paper. This reporsitory contains the Video Person Cl

Andrew Brown 47 Nov 2, 2022
This repo contains the code and data used in the paper "Wizard of Search Engine: Access to Information Through Conversations with Search Engines"

Wizard of Search Engine: Access to Information Through Conversations with Search Engines by Pengjie Ren, Zhongkun Liu, Xiaomeng Song, Hongtao Tian, Zh

null 19 Oct 27, 2022
Code Repo for the ACL21 paper "Common Sense Beyond English: Evaluating and Improving Multilingual LMs for Commonsense Reasoning"

Common Sense Beyond English: Evaluating and Improving Multilingual LMs for Commonsense Reasoning This is the Github repository of our paper, "Common S

INK Lab @ USC 19 Nov 30, 2022
This repo is the code release of EMNLP 2021 conference paper "Connect-the-Dots: Bridging Semantics between Words and Definitions via Aligning Word Sense Inventories".

Connect-the-Dots: Bridging Semantics between Words and Definitions via Aligning Word Sense Inventories This repo is the code release of EMNLP 2021 con

null 12 Nov 22, 2022
The LaTeX and Python code for generating the paper, experiments' results and visualizations reported in each paper is available (whenever possible) in the paper's directory

This repository contains the software implementation of most algorithms used or developed in my research. The LaTeX and Python code for generating the

João Fonseca 3 Jan 3, 2023
Repo for CVPR2021 paper "QPIC: Query-Based Pairwise Human-Object Interaction Detection with Image-Wide Contextual Information"

QPIC: Query-Based Pairwise Human-Object Interaction Detection with Image-Wide Contextual Information by Masato Tamura, Hiroki Ohashi, and Tomoaki Yosh

null 105 Dec 23, 2022
The official repo of the CVPR2021 oral paper: Representative Batch Normalization with Feature Calibration

Representative Batch Normalization (RBN) with Feature Calibration The official implementation of the CVPR2021 oral paper: Representative Batch Normali

Open source projects of ShangHua-Gao 76 Nov 9, 2022
The repo of the preprinting paper "Labels Are Not Perfect: Inferring Spatial Uncertainty in Object Detection"

Inferring Spatial Uncertainty in Object Detection A teaser version of the code for the paper Labels Are Not Perfect: Inferring Spatial Uncertainty in

ZINING WANG 21 Mar 3, 2022
This Repo is the official CUDA implementation of ICCV 2019 Oral paper for CARAFE: Content-Aware ReAssembly of FEatures

Introduction This Repo is the official CUDA implementation of ICCV 2019 Oral paper for CARAFE: Content-Aware ReAssembly of FEatures. @inproceedings{Wa

Jiaqi Wang 42 Jan 7, 2023
This is the repo for the paper `SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization'. (published in Bioinformatics'21)

SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization This is the code for our paper ``SumGNN: Multi-typed Drug

Yue Yu 58 Dec 21, 2022
This repo is a PyTorch implementation for Paper "Unsupervised Learning for Cuboid Shape Abstraction via Joint Segmentation from Point Clouds"

Unsupervised Learning for Cuboid Shape Abstraction via Joint Segmentation from Point Clouds This repository is a PyTorch implementation for paper: Uns

Kaizhi Yang 42 Dec 9, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
The official repo of the CVPR 2021 paper Group Collaborative Learning for Co-Salient Object Detection .

GCoNet The official repo of the CVPR 2021 paper Group Collaborative Learning for Co-Salient Object Detection . Trained model Download final_gconet.pth

Qi Fan 46 Nov 17, 2022
This repo in the implementation of EMNLP'21 paper "SPARQLing Database Queries from Intermediate Question Decompositions" by Irina Saparina, Anton Osokin

SPARQLing Database Queries from Intermediate Question Decompositions This repo is the implementation of the following paper: SPARQLing Database Querie

Yandex Research 20 Dec 19, 2022
Official Repo for ICCV2021 Paper: Learning to Regress Bodies from Images using Differentiable Semantic Rendering

[ICCV2021] Learning to Regress Bodies from Images using Differentiable Semantic Rendering Getting Started DSR has been implemented and tested on Ubunt

Sai Kumar Dwivedi 83 Nov 27, 2022
Official repo for BMVC2021 paper ASFormer: Transformer for Action Segmentation

ASFormer: Transformer for Action Segmentation This repo provides training & inference code for BMVC 2021 paper: ASFormer: Transformer for Action Segme

null 42 Dec 23, 2022
Repo for the paper "DiLBERT: Cheap Embeddings for Disease Related Medical NLP"

DiLBERT Repo for the paper "DiLBERT: Cheap Embeddings for Disease Related Medical NLP" Pretrained Model The pretrained model presented in the paper is

Kevin Roitero 2 Dec 15, 2022
Repo for the paper Extrapolating from a Single Image to a Thousand Classes using Distillation

Extrapolating from a Single Image to a Thousand Classes using Distillation by Yuki M. Asano* and Aaqib Saeed* (*Equal Contribution) Extrapolating from

Yuki M. Asano 16 Nov 4, 2022
Repo for WWW 2022 paper: Progressively Optimized Bi-Granular Document Representation for Scalable Embedding Based Retrieval

BiDR Repo for WWW 2022 paper: Progressively Optimized Bi-Granular Document Representation for Scalable Embedding Based Retrieval. Requirements torch==

Microsoft 11 Oct 20, 2022