Coder Social home page Coder Social logo

mpikgc's Introduction

Multi-perspective Improvement of Knowledge Graph Completion with Large Language Models

This is the code and data of paper Multi-perspective Improvement of Knowledge Graph Completion with Large Language Models, LREC-COLING 2024.

The entire project consists of three steps: (1) Generating data, (2) Processing data and (3) Runing KGC models.

Generating data

You can directly download the data we generated from Goolge Drive. Put the data in current directory, e.g., MPIKGC/LP_fb_wn_chatglm2/.

If you want to generate data with LLMs by yourself, you can run the following command to query LLMs for data:

First, cd generating_MPIKG/, then

For FB15k237:

python querying_llm_fb15k237.py --max_length 256 --temperature 0.2 --cuda 0 --batchsize 1 --LLMfold './../LP_fb_wn_llama2/' --LLMname ChatGLM2

For WN18RR:

python querying_llm_wn18rr.py --max_length 256 --temperature 0.2 --cuda 0 --batchsize 1 --LLMfold './../LP_fb_wn_llama2/' --LLMname ChatGLM2

For FB13 and WN11:

python querying_llm_TC_FB13_WN11.py --max_length 256 --temperature 0.2 --cuda 0 --batchsize 1 --LLMfold './../TC_fb_wn_llama2/' --LLMname ChatGLM2 --fb_or_wn FB13

After getting extracted keywords, you can genearate the top K matching entities for Structure Extraction, and change the default parameters in codes to obtain the desired data:

python textmatch4structure.py 

Finally, generating data in corresponding path, e.g., LP_fb_wn_chatglm2/FB15k237/:

cotdes.txt for MPIKGC-E

rel2des.txt for MPIKGC-R Global

rel2sentence.txt for MPIKGC-R Local

rel2reverse.txt for MPIKGC-R Reverse

struc/* for MPIKGC-S

Processing data

Merge the enhanced data with original KG to generate new KG with regular form:

cd processing_MPIKG
python merge.py 

Download KGC models from their repository: CSprom-KG, LMKE, SimKGC, KG-BERT. Put these project in current directory, e.g., MPIKGC/CSprom-KG/.

For diffrent KGC models, you need to slightly modify the form of data by runing:

python data4kgc_models.py 

This code will transfer the form of data to adapt to different KGC model requirements, and copy the data to corresponding model project folder.

Note that KG-BERT need same form as LMKE, You can directly copy it over.

Runing KGC models

Configure according to the environment and process requirements of each model. Hyperparameters for KGC models can be found in Appendices of our paper.

mpikgc's People

Contributors

quqxui avatar

Stargazers

zhangdong avatar wll avatar Nikolaus Schlemm avatar  avatar Wyatt Walsh avatar Bian Qi avatar  avatar  avatar  avatar  avatar AUK avatar  avatar dorian avatar  avatar 陈宏恩 avatar  avatar  avatar hujili avatar  avatar  avatar  avatar dangerous avatar Yuchen Wu avatar Yan avatar  avatar fanny avatar  avatar  avatar Dr. Artificial曾小健 avatar  avatar Ziheng ZHANG avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

lucas0214

mpikgc's Issues

merge.py : The function on the last line lacks a parameter

Traceback (most recent call last):
File "merge.py", line 228, in
merge_srcdes_srckeywords_rel2sentence_struc_srckeywords_top3_selfloop('struc_srckeywords_top3_selfloop')
TypeError: merge_srcdes_srckeywords_rel2sentence_struc_srckeywords_top3_selfloop() missing 1 required positional argument: 'top_loop'

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.