• Stars
    star
    167
  • Rank 226,684 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[SIGIR 2022] Hybrid Transformer with Multi-level Fusion for Multimodal Knowledge Graph Completion

MKGFormer

Code for the SIGIR 2022 paper "Hybrid Transformer with Multi-level Fusion for Multimodal Knowledge Graph Completion"

Model Architecture

Illustration of MKGformer for (a) Unified Multimodal KGC Framework and (b) Detailed M-Encoder.

Requirements

To run the codes (Python 3.8), you need to install the requirements:

pip install -r requirements.txt

Data Preprocess

To extract visual object images int MNER and MRE tasks, we first use the NLTK parser to extract noun phrases from the text and apply the visual grouding toolkit to detect objects. Detailed steps are as follows:

  1. Using the NLTK parser (or Spacy, textblob) to extract noun phrases from the text.
  2. Applying the visual grouding toolkit to detect objects. Taking the twitter2017 dataset as an example, the extracted objects are stored in twitter2017_aux_images. The images of the object obey the following naming format: id_pred_yolo_crop_num.png, where id is the order of the raw image corresponding to the object, num is the number of the object predicted by the toolkit. (id is doesn't matter.)
  3. Establishing the correspondence between the raw images and the objects. We construct a dictionary to record the correspondence between the raw images and the objects. Taking twitter2017/twitter2017_train_dict.pth as an example, the format of the dictionary can be seen as follows: {imgname:['id_pred_yolo_crop_num0.png', 'id_pred_yolo_crop_num1.png', ...] }, where key is the name of raw images, value is a List of the objects (Note that in train/val/test.txt, text and raw image have a one-to-one relationship, so the imgnae can be used as a unique identifier for the raw images).

The detected objects and the dictionary of the correspondence between the raw images and the objects are available in our data links.

Data Download

The datasets that we used in our experiments are as follows:

  • Twitter2017

    You can download the twitter2017 dataset from Google Drive.

    For more information regarding the dataset, please refer to the UMT repository.

  • MRE

    The MRE dataset comes from MEGA, many thanks.

    You can download the MRE dataset with detected visual objects from Google Drive or using following command:

    cd MRE
    wget 120.27.214.45/Data/re/multimodal/data.tar.gz
    tar -xzvf data.tar.gz
  • MKG

    • FB15K-237-IMG

      You can download the image data of FB15k-237 from mmkb which provides a list of image URLs, and refer to more information of description of entity from kg-bert repositories.

      • ❗NOTE: we have found a severe bug in the code of data preprocessing for FB15k-237-IMG, which leads to the unfair performance comparison; we have updated the performance in arxiv and released the checkpoints (The model trained with/without the severe bug).
    • WN18-IMG

      Entity images in WN18 can be obtained from ImageNet, the specific steps can refer to RSME. the RSME repository.

We also provide additional network disk links for multimodal KG data (Images) at GoogleDrive or Baidu Pan with extraction (code:ilbd).

The expected structure of files is:

MKGFormer
 |-- MKG	# Multimodal Knowledge Graph
 |    |-- dataset       # task data
 |    |-- data          # data process file
 |    |-- lit_models    # lightning model
 |    |-- models        # mkg model
 |    |-- scripts       # running script
 |    |-- main.py   
 |-- MNER	# Multimodal Named Entity Recognition
 |    |-- data          # task data
 |    |    |-- twitter2017
 |    |    |    |-- twitter17_detect            # rcnn detected objects
 |    |    |    |-- twitter2017_aux_images      # visual grounding objects
 |    |    |    |-- twitter2017_images          # raw images
 |    |    |    |-- train.txt                   # text data
 |    |    |    |-- ...
 |    |    |    |-- twitter2017_train_dict.pth  # {imgname: [object-image]}
 |    |    |    |-- ...
 |    |-- models        # mner model
 |    |-- modules       # running script
 |    |-- processor     # data process file
 |    |-- utils
 |    |-- run_mner.sh
 |    |-- run.py
 |-- MRE    # Multimodal Relation Extraction
 |    |-- data          # task data
 |    |    |-- img_detect   # rcnn detected objects
 |    |    |-- img_org      # raw images
 |    |    |-- img_vg       # visual grounding objects
 |    |    |-- txt          # text data
 |    |    |    |-- ours_train.txt
 |    |    |    |-- ours_val.txt
 |    |    |    |-- ours_test.txt
 |    |    |    |-- mre_train_dict.pth  # {imgid: [object-image]}
 |    |    |    |-- ...
 |    |    |-- vg_data      # [(id, imgname, noun_phrase)], not useful
 |    |    |-- ours_rel2id.json         # relation data
 |    |-- models        # mre model
 |    |-- modules       # running script
 |    |-- processor     # data process file
 |    |-- run_mre.sh
 |    |-- run.py

How to run

  • MKG Task

    • First run Image-text Incorporated Entity Modeling to train entity embedding.
        cd MKG
        bash scripts/pretrain_fb15k-237-image.sh
    • Then do Missing Entity Prediction.
        bash scripts/fb15k-237-image.sh
  • MNER Task

    To run mner task, run this script.

    cd MNER
    bash run_mner.sh
  • MRE Task

    To run mre task, run this script.

    cd MRE
    bash run_mre.sh

Acknowledgement

The acquisition of image data for the multimodal link prediction task refer to the code from https://github.com/wangmengsd/RSME, many thanks.

Papers for the Project & How to Cite

If you use or extend our work, please cite the paper as follows:

@inproceedings{DBLP:conf/sigir/ChenZLDTXHSC22,
  author    = {Xiang Chen and
               Ningyu Zhang and
               Lei Li and
               Shumin Deng and
               Chuanqi Tan and
               Changliang Xu and
               Fei Huang and
               Luo Si and
               Huajun Chen},
  editor    = {Enrique Amig{\'{o}} and
               Pablo Castells and
               Julio Gonzalo and
               Ben Carterette and
               J. Shane Culpepper and
               Gabriella Kazai},
  title     = {Hybrid Transformer with Multi-level Fusion for Multimodal Knowledge
               Graph Completion},
  booktitle = {{SIGIR} '22: The 45th International {ACM} {SIGIR} Conference on Research
               and Development in Information Retrieval, Madrid, Spain, July 11 -
               15, 2022},
  pages     = {904--915},
  publisher = {{ACM}},
  year      = {2022},
  url       = {https://doi.org/10.1145/3477495.3531992},
  doi       = {10.1145/3477495.3531992},
  timestamp = {Mon, 11 Jul 2022 12:19:20 +0200},
  biburl    = {https://dblp.org/rec/conf/sigir/ChenZLDTXHSC22.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

More Repositories

1

DeepKE

[EMNLP 2022] An Open Toolkit for Knowledge Graph Extraction and Construction
Python
3,517
star
2

EasyEdit

[ACL 2024] An Easy-to-use Knowledge Editing Framework for LLMs.
Jupyter Notebook
1,815
star
3

LLMAgentPapers

Must-read Papers on LLM Agents.
1,683
star
4

KnowLM

An Open-sourced Knowledgable Large Language Model Framework.
Python
1,209
star
5

Prompt4ReasoningPapers

[ACL 2023] Reasoning with Language Model Prompting: A Survey
863
star
6

KnowledgeEditingPapers

Must-read Papers on Knowledge Editing for Large Language Models.
843
star
7

PromptKG

PromptKG Family: a Gallery of Prompt Learning & KG-related research works, toolkits, and paper-list.
Python
690
star
8

EasyInstruct

[ACL 2024] An Easy-to-use Instruction Processing Framework for LLMs.
Python
357
star
9

AutoKG

LLMs for Knowledge Graph Construction and Reasoning: Recent Capabilities and Future Opportunities
Python
345
star
10

OpenUE

[EMNLP 2020] OpenUE: An Open Toolkit of Universal Extraction from Text
Python
321
star
11

Mol-Instructions

[ICLR 2024] Mol-Instructions: A Large-Scale Biomolecular Instruction Dataset for Large Language Models
Python
233
star
12

KnowPrompt

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

KnowAgent

KnowAgent: Knowledge-Augmented Planning for LLM-Based Agents
Python
163
star
14

AutoAct

[ACL 2024] AUTOACT: Automatic Agent Learning from Scratch for QA via Self-Planning
Python
162
star
15

IEPile

[ACL 2024] IEPile: A Large-Scale Information Extraction Corpus
Python
158
star
16

OntoProtein

[ICLR 2022] OntoProtein: Protein Pretraining With Gene Ontology Embedding
Python
141
star
17

DocuNet

[IJCAI 2021] Document-level Relation Extraction as Semantic Segmentation
Python
130
star
18

DART

[ICLR 2022] Differentiable Prompt Makes Pre-trained Language Models Better Few-shot Learners
Python
127
star
19

MolGen

[ICLR 2024] Domain-Agnostic Molecular Generation with Chemical Feedback
Python
124
star
20

Relphormer

[Neurocomputing 2023] Relational Graph Transformer for Knowledge Graph Representation
Python
120
star
21

Low-resource-KEPapers

A Paper List of Low-resource Information Extraction
114
star
22

OneGen

[EMNLP 2024 Findings] OneGen: Efficient One-Pass Unified Generation and Retrieval for LLMs.
Python
114
star
23

Generative_KG_Construction_Papers

[EMNLP 2022] Generative Knowledge Graph Construction: A Review
104
star
24

HVPNeT

[NAACL 2022 Findings] Good Visual Guidance Makes A Better Extractor: Hierarchical Visual Prefix for Multimodal Entity and Relation Extraction
Python
97
star
25

MachineSoM

[ACL 2024] Exploring Collaboration Mechanisms for LLM Agents: A Social Psychology View
Python
91
star
26

MKG_Analogy

[ICLR 2023] Multimodal Analogical Reasoning over Knowledge Graphs
Python
89
star
27

FactCHD

[IJCAI 2024] FactCHD: Benchmarking Fact-Conflicting Hallucination Detection
Python
78
star
28

NLP4SciencePapers

Must-read papers on NLP for science.
53
star
29

KNN-KG

[NLPCC 2023] Reasoning Through Memorization: Nearest Neighbor Knowledge Graph Embeddings with Language Models
Python
49
star
30

KnowledgeCircuits

Knowledge Circuits in Pretrained Transformers
Python
47
star
31

ChatCell

ChatCell: Facilitating Single-Cell Analysis with Natural Language
Python
42
star
32

RAP

[SIGIR 2023] Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction
Python
39
star
33

DeepEE

DeepEE: Deep Event Extraction Algorithm Gallery (基于深度学习的开源中文事件抽取算法汇总)
Python
39
star
34

TRICE

[NAACL 2024] Making Language Models Better Tool Learners with Execution Feedback
Python
36
star
35

DocED

[ACL 2021] MLBiNet: A Cross-Sentence Collective Event Detection Network
Python
35
star
36

Kformer

[NLPCC 2022] Kformer: Knowledge Injection in Transformer Feed-Forward Layers
Python
34
star
37

LREBench

[EMNLP 2022 Findings] Towards Realistic Low-resource Relation Extraction: A Benchmark with Empirical Baseline Study
Python
33
star
38

ContinueMKGC

[IJCAI 2024] Continual Multimodal Knowledge Graph Construction
Python
32
star
39

IEDatasetZoo

Information Extraction Dataset Zoo.
31
star
40

WKM

Agent Planning with World Knowledge Model
Python
30
star
41

DiagnoseRE

[CCKS 2021] On Robustness and Bias Analysis of BERT-based Relation Extraction
Python
27
star
42

OceanGPT

[ACL 2024] OceanGPT: A Large Language Model for Ocean Science Tasks
25
star
43

PitfallsKnowledgeEditing

[ICLR 2024] Unveiling the Pitfalls of Knowledge Editing for Large Language Models
Python
22
star
44

AdaKGC

[EMNLP 2023 (Findings)] Schema-adaptable Knowledge Graph Construction
Python
17
star
45

knowledge-rumination

[EMNLP 2023] Knowledge Rumination for Pre-trained Language Models
Python
16
star
46

KnowUnDo

[EMNLP 2024 Findings] To Forget or Not? Towards Practical Knowledge Unlearning for Large Language Models
Python
16
star
47

EasyDetect

[ACL 2024] An Easy-to-use Hallucination Detection Framework for LLMs.
Python
16
star
48

OneEdit

OneEdit: A Neural-Symbolic Collaboratively Knowledge Editing System.
Python
15
star
49

SPEECH

[ACL 2023] SPEECH: Structured Prediction with Energy-Based Event-Centric Hyperspheres
Python
13
star
50

NLPCC2024_RegulatingLLM

[NLPCC 2024] Shared Task 10: Regulating Large Language Models
13
star
51

SemEval2021Task4

The 4th rank system of the SemEval 2021 Task4.
Python
10
star
52

Revisit-KNN

[CCL 2023] Revisiting k-NN for Fine-tuning Pre-trained Language Models
Python
10
star
53

EasyEval

An Easy-to-use Intelligence Evaluation Framework for LLMs.
Python
6
star
54

BiasEdit

Debiasing Stereotyped Language Models via Model Editing
Python
5
star
55

zjunlp.github.io

HTML
3
star
56

project

Project homepages for the NLP & KG Group of Zhejiang University
JavaScript
3
star
57

DQSetGen

[TASLP 2024] Sequence Labeling as Non-autoregressive Dual-Query Set Generation
Python
3
star
58

L2A

Python
2
star
59

KnowFM

2
star
60

EditBias

EditBias: Debiasing Stereotyped Language Models via Model Editing
Python
1
star