Git Product home page Git Product logo

np-fkgc's Introduction

NP-FKGC

Official code implementation for SIGIR 23 paper Normalizing Flow-based Neural Process for Few-Shot Knowledge Graph Completion

Requirement

pytorch==1.11
tqdm==4.64
normflows==1.4
dgl==0.9.0
tensorboardx==2.5.1

Note: Please make sure dgl==0.9.0 and use CUDA, our codes rely on a small bug of dgl for running.

Environment

  • python 3.8
  • Ubuntu 22.04
  • RTX3090/A100
  • Memory 32G/128G

Dataset & Checkpoint

Original Dataset

Processed Dataset

Download the datasets and extract to the project root folder.

Train

NELL (3090)

python main.py --dataset NELL-One --data_path ./NELL --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_nellone_5shot_intrain --device 0 --batch_size 128 --flow Planar --g_batch 1024

WIKI (A100)

python main.py --dataset Wiki-One --data_path ./Wiki --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_wiki_5shot_intrain_g_batch_1024_eval_8 --device 0 --batch_size 64 --flow Planar -dim 50 --g_batch 1024 --eval_batch 8 --eval_epoch 4000

FB15K-237 (3090)

python main.py --dataset FB15K-One --data_path ./FB15K --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_fb15k_5shot_intrain --device 0 --batch_size 128 --flow Planar --g_batch 1024 --eval_batch_size 128 --K 14

Eval

Download the checkpoint and extract to the state/ folder.

NELL

python main.py --dataset NELL-One --data_path ./NELL --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_nellone_5shot_intrain_0.46 --device 0 --batch_size 128 --flow Planar --g_batch 1024 --step test

WIKI

python main.py --dataset Wiki-One --data_path ./Wiki --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_wiki_5shot_intrain_g_batch_1024_eval_8_0.503 --device 0 --batch_size 64 --flow Planar -dim 50 --g_batch 1024 --eval_batch 8 --eval_epoch 4000 --step test

FB15K-237

python main.py --dataset FB15K-One --data_path ./FB15K --few 5 --data_form Pre-Train --prefix np_rgcn_attn_planar_fb15k_5shot_intrain_0.536 --device 0 --batch_size 128 --flow Planar --g_batch 1024 --eval_batch_size 128 --K 14 --step test

Results

5-shot FKGC results

Dataset MRR Hits@10 Hits@5 Hits@1
NELL 0.460 0.494 0.471 0.437
WIKI 0.503 0.668 0.599 0.423
FB15K-237 0.538 0.671 0.593 0.476

See full results in our paper.

Citations

If you use this repo, please cite the following paper.

@inproceedings{luo2023npfkgc,
  title     = {Normalizing Flow-based Neural Process for Few-Shot Knowledge Graph Completion},
  author    = {Luo, Linhao and Li, Yuan-Fang and Haffari, Gholamreza and Pan, Shirui},
  booktitle = {The 46th International ACM SIGIR Conference on Research and Development in Information Retrieval},
  year      = {2023}
}

Acknowledgement

This repo is mainly based on GANA. We thank the authors for their great works.

np-fkgc's People

Contributors

rmanluo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

np-fkgc's Issues

关于复现实验结果出现偏差

作者您好,我将您的代码下载下来,并按照论文提到的参数配置跑实验,发现实验结果并没有您论文里写的那么高,其中在nell数据集下跑出的结果是0.432,您能说一下参数配置和达到最好效果的epoch是多少吗,期待您的回复,感谢

关于query和negative的测试问题

您好,关于您的代码我有两点疑问:

(1)您认为测试时query和negative分开输入gnn中没有影响。可当我将query也添加到negative中,让模型输出正负样本分数时,在negative score中没有与positive score 相同的分数。这说明query单独输入和混合输入时,模型预测结果不同。
image

(2)在我之前提出的问题中,用TransE作为解码器,无需训练,您的模型在MRR指标就能达到0.53的结果。

因此我认为在您的方法中分开输入query和negative到gnn中是存在问题的(query和negative一起输入,结果有大幅度降低)。期待您的回复。

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.