Skip to content

zjukg/MERRY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MERRY

Code for the paper "Beyond Completion: A Foundation Model for General Knowledge Graph Reasoning." It provides implementations for two representative tasks in the field of Knowledge Graphs (KGs): Knowledge Graph Completion (KGC) and Knowledge Graph Question Answering (KGQA).

Model Architecture

img

Requirements

  • CUDA version: 12.x

The code is designed to run in a Docker container on an internal enterprise platform. Many of the dependencies are custom-built for this platform. If you encounter any issues, please feel free to provide feedback.

Task Directories

  • KGC Task: Code located in the kg directory.
  • KGQA Task: Code located in the qa directory.

For environment setup, refer to the env.sh script located in each directory.

Data Preparation

KGC Task

  • Knowledge Graph (KG) data for various datasets can be downloaded by running the kg/script/prepare_emb.py script.
  • For textual description datasets, use the Wikidata API and the original KG dataset repositories to fetch the data.
  • To initialize node embeddings in the KG, run the kg/gen_emb.sh script.

KGQA Task

  • Download the datasets used in QAGNN (or GreaseLM), and due to version compatibility issues, you will need to convert the dataset format by running the qa/raw_data/pyg_trans.ipynb script.
  • For each question sample, use similarity search to obtain a few-shot set. The qa/sim.ipynb script will handle this task.

How to Run

KGC Task

  • Pre-training configuration: kg/config/pretrain/lp_retain.yaml
  • To start pre-training, run: kg/train.sh
  • To evaluate the model, run: kg/eval.sh

KGQA Task

  • Training configuration: qa/config/qa/csqa.yaml
  • To train the model, run: qa/train.sh
  • To evaluate the model, run: qa/eval.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors