Giter Club home page Giter Club logo

promptkg's Introduction

A Prompt Learning Framework for Knowledge Graph Representation Learning and Application

A Prompt Learning Framework for Knowledge Graph  with Pre-trained Language Models across tasks (predictive and generative), and modalities (language, image, vision + language, etc.)

Correlative Toolkit:

DeepKE:A Deep Learning Based Knowledge Extraction Toolkit for Knowledge Graph Construction

Paper: PromptKG: A Prompt Learning Framework for Knowledge Graph Representation Learning and Application

Directory Description
toolkit • A prompt-based toolkit for knowledge graph construction and application
research • A collection of research model implementations in Pytorch by researchers
tutorial-notebooks • Tutorial notebooks for beginners

Toolkit

Quick Start

Installation

Step1

Create the conda env.

conda create -n promptkg python=3.8

Step2

Install the dependence.

pip install -r requirements.txt

Step3

Install our preprocessed datasets and put them into the dataset folder.

Dataset (KGC) Google Drive Baidu Cloud
WN18RR google drive baidu drive axo7
FB15k-237 google drive baidu drive ju9t
MetaQA google drive baidu drive hzc9
KG20C google drive baidu drive stnh

Run your first experiment

We provide four tasks in our toolkit as Knowledgeg Graph Completion (KGC), Question Answering (QA), Recomandation (REC) and LAnguage Model Analysis (LAMA).

  • KGC is our basic task to the knowledge graph embedding and evaluate the ability of the models. ** You can run the script under kgc folder to train the model and get the KG embeddings (take simkgc as example).

    bash ./scripts/kgc/simkgc.sh
  • For QA task, you can run the script files under metaqa. ** We suggest you use generative model to solve the QA task as below:

    bash ./scripts/metaqa/run.sh
  • For REC task, you need to firstly get the KG embeddings and then train the rec system models. ** use two-stage scripts below:

    bash ./scripts/kgrec/pretrain_item.sh
    bash ./scripts/kgrec/ml20m.sh
  • For LAMA task, you can use the files under lama. ** We provide BERT and RoBERTa PLMs to evaluate their performance and with our KG embeddings (plet).

    bash ./scripts/lama/lama_roberta.sh

Implemented Models

Models  KGC    QA    REC   LAMA  
KG-BERT
GenKGC
KGT5
kNN-KGE
SimKGC

Framework

Process on your own data

For each knowledge graph, we have 5 files.

  • train.tsv, dev.tsv, test.tsv, list as (h, r, t) for entity id and relation id (start from 0).
  • entity2text.txt, as (entity_id, entity description).
  • relation2text.txt , as (relation_id, relation description).

For downstream tasks

Contact Information

For help or issues using the models, please submit a GitHub issue.

Citation

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

@article{DBLP:journals/corr/abs-2210-00305,
  author    = {Xin Xie and
               Zhoubo Li and
               Xiaohan Wang and
               Shumin Deng and
               Feiyu Xiong and
               Huajun Chen and
               Ningyu Zhang},
  title     = {PromptKG: {A} Prompt Learning Framework for Knowledge Graph Representation
               Learning and Application},
  journal   = {CoRR},
  volume    = {abs/2210.00305},
  year      = {2022},
  url       = {https://doi.org/10.48550/arXiv.2210.00305},
  doi       = {10.48550/arXiv.2210.00305},
  eprinttype = {arXiv},
  eprint    = {2210.00305},
  timestamp = {Fri, 07 Oct 2022 15:24:59 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2210-00305.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

Other KG Representation Open-Source Projects

promptkg's People

Contributors

cheasim avatar zxlzr avatar timelordri avatar alexzhuan avatar flow3rdown avatar njcx-ai 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.