{"id":28098793,"url":"https://github.com/rmanluo/np-fkgc","last_synced_at":"2025-06-21T18:08:04.824Z","repository":{"id":153333077,"uuid":"543549477","full_name":"RManLuo/NP-FKGC","owner":"RManLuo","description":"Official code implementation for SIGIR 23 paper Normalizing Flow-based Neural Process for Few-Shot Knowledge Graph Completion","archived":false,"fork":false,"pushed_at":"2024-10-04T10:32:56.000Z","size":46,"stargazers_count":39,"open_issues_count":6,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T18:02:00.628Z","etag":null,"topics":["few-shot-learning","gnn","graph-neural-networks","knowledge-graph","knowledge-graph-completion","neural-processes","sigir"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RManLuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-09-30T10:36:23.000Z","updated_at":"2024-12-30T22:27:22.000Z","dependencies_parsed_at":"2024-02-23T05:21:02.351Z","dependency_job_id":"38304e8a-3ce7-426c-8803-d7964f19a47f","html_url":"https://github.com/RManLuo/NP-FKGC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RManLuo/NP-FKGC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FNP-FKGC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FNP-FKGC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FNP-FKGC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FNP-FKGC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RManLuo","download_url":"https://codeload.github.com/RManLuo/NP-FKGC/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RManLuo%2FNP-FKGC/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261170423,"owners_count":23119513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["few-shot-learning","gnn","graph-neural-networks","knowledge-graph","knowledge-graph-completion","neural-processes","sigir"],"created_at":"2025-05-13T17:58:50.944Z","updated_at":"2025-06-21T18:07:59.795Z","avatar_url":"https://github.com/RManLuo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NP-FKGC\nOfficial code implementation for SIGIR 23 paper [Normalizing Flow-based Neural Process for Few-Shot Knowledge Graph Completion](https://arxiv.org/abs/2304.08183)\n## Requirement\n```\npytorch==1.11\ntqdm==4.64\nnormflows==1.4\ndgl==0.9.0\ntensorboardx==2.5.1\n```\nNote: Please make sure `dgl==0.9.0` and use CUDA, our codes rely on a small [bug](https://github.com/dmlc/dgl/issues/4512#issuecomment-1250642930) of dgl for running.\n\n## Environment\n* python 3.8\n* Ubuntu 22.04\n* RTX3090/A100\n* Memory 32G/128G\n\n## Dataset \u0026 Checkpoint\n### Original Dataset\n* [NELL/WIKI](https://github.com/xwhan/One-shot-Relational-Learning)\n* [FB15K-237](https://github.com/SongW-SW/REFORM)\n### Processed Dataset\n* [Dataset](https://drive.google.com/drive/u/0/folders/1vN1AMapGZaUnQ4c7gPiBmO_nB6vvhj1c)\n* [Checkpoint](https://drive.google.com/drive/u/0/folders/1gpHkQDgr5KzAXptl_fa1pATvk__prYUc)\n\nDownload the datasets and extract to the project root folder.  \n\n## Train\nNELL (3090)\n```bash\npython 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\n```\n\nWIKI (A100)\n```bash\npython 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\n```\n\nFB15K-237 (3090)\n```bash\npython 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\n```\n\n## Eval\nDownload the checkpoint and extract to the `state/` folder.\n\nNELL\n```bash\npython 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\n```\n\nWIKI\n```bash\npython 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\n```\n\nFB15K-237\n```bash\npython 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\n```\n\n## Results\n5-shot FKGC results\n| Dataset | MRR   | Hits@10 | Hits@5 | Hits@1 |\n| ------- | ----- | ------- | ------ | ------ |\n| NELL    | 0.460 | 0.494   | 0.471  | 0.437  |\n| WIKI    | 0.503 | 0.668   | 0.599  | 0.423  |\n| FB15K-237   | 0.538 | 0.671   | 0.593  | 0.476  |\n\nSee full results in our paper.\n\n## Citations\nIf you use this repo, please cite the following paper.\n```\n@inproceedings{luo2023npfkgc,\n  title     = {Normalizing Flow-based Neural Process for Few-Shot Knowledge Graph Completion},\n  author    = {Luo, Linhao and Li, Yuan-Fang and Haffari, Gholamreza and Pan, Shirui},\n  booktitle = {The 46th International ACM SIGIR Conference on Research and Development in Information Retrieval},\n  year      = {2023}\n}\n```\n\n## Acknowledgement\nThis repo is mainly based on [GANA](https://github.com/ngl567/GANA-FewShotKGC). We thank the authors for their great works.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmanluo%2Fnp-fkgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmanluo%2Fnp-fkgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmanluo%2Fnp-fkgc/lists"}