{"id":13605491,"url":"https://github.com/HKUST-KnowComp/FIT","last_synced_at":"2025-04-12T05:33:21.067Z","repository":{"id":166002957,"uuid":"635233612","full_name":"HKUST-KnowComp/FIT","owner":"HKUST-KnowComp","description":"Fuzzy Inference with Truth value","archived":false,"fork":false,"pushed_at":"2024-04-11T12:16:30.000Z","size":9165,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-02T19:37:42.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/HKUST-KnowComp.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}},"created_at":"2023-05-02T08:56:21.000Z","updated_at":"2024-04-08T14:18:23.000Z","dependencies_parsed_at":"2024-01-19T10:12:16.526Z","dependency_job_id":"fc96870a-9e30-4175-97cd-d5f3ff60a0ce","html_url":"https://github.com/HKUST-KnowComp/FIT","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUST-KnowComp%2FFIT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUST-KnowComp%2FFIT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUST-KnowComp%2FFIT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUST-KnowComp%2FFIT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HKUST-KnowComp","download_url":"https://codeload.github.com/HKUST-KnowComp/FIT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223497889,"owners_count":17155215,"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":[],"created_at":"2024-08-01T19:00:59.354Z","updated_at":"2024-11-07T10:30:43.032Z","avatar_url":"https://github.com/HKUST-KnowComp.png","language":"Python","funding_links":[],"categories":[":wrench: Implementations"],"sub_categories":["Dataset tools"],"readme":"# Rethinking Complex Queries on Knowledge Graphs with Neural Link Predictors\n\nThis repository is for implementation for the paper \"Rethinking Complex Queries on Knowledge Graphs with Neural Link Predictors\" of ICLR 2024. \nSee the [openreview version](https://openreview.net/forum?id=1BmveEMNbG), or [arxiv version](https://arxiv.org/abs/2304.07063).\n\n\n## 1 Preparation\n\n### 1.1 Data Preparation\nPlease download the data from [here](https://drive.google.com/drive/folders/17bPr6_ESqh5D0LgWNgpE4mY8gpg2iC5o?usp=sharing), \nthe data of three knowledge graphs can be downloaded separately and put it in the `data` folder.\n\nA example data folder should look like this:\n```\ndata/FB15k-237-EFO1\n  - kgindex.json\n  - train_kg.tsv\n  - valid_kg.tsv\n  - test_kg.tsv\n  - train_qaa.json\n  - valid_type0000_real_EFO1_qaa.json\n  - valid_...\n  - valid_type0000_real_EFO1_qaa.json\n  - test_...\n```\nWe note that there is only one file for training but multiple files for testing. \n\nMoreover, the four csv files containing the formulas used in training and testing should be directly put into the `data` folder:\n```\ndata/FIT_finetune1p3in.csv\n  - DNF_evaluate_EFO1.csv\n  - FIT_quick_evaluate.csv\n  - DNF_evaluate_c.csv\n```\n\nThe data of formula type0000-type0013 are inherited from the original BetaE dataset and converted \nto the format that can be used in our experiment, type0014-type0023 are the ten new formulas sampled by ourself.\n\nMoreover, one can also use our pipeline to sample query for their own after \nyou have already downloaded the knowledge graph from above.\n\nWe give the example of sampling query for test from FB15k-237:\n\n```angular2html\npython sample_query.py --output_folder data/FB15k-237-EFO1 --data_folder data/FB15k-237-EFO1 --mode test\n```\n\n### 1.2 Finetuning the neurla link preictor\n\nTo train the model, first download checkpoint of pretrained neural link predictor 'pretrain_cqd.zip' from [here](https://drive.google.com/drive/folders/17bPr6_ESqh5D0LgWNgpE4mY8gpg2iC5o?usp=sharing).\n\nUnzip the file, the folder `pretrain/cqd` should look like this:\n```\npretrain/cqd/FB15k-237.pt\n  - FB15k.pt\n  - NELL.pt\n```\n\nThen you can finetune these models by running the following code, taking FB15k-237 as an example:\n\n```\npython QG_FIT.py --config config/real_EFO1/FIT_FB15k-237_EFO1.yaml\n```\n\n\n\n## 2. Reproduce the result of the paper.\n\n### 2.1 Evaluation\n\nWhen comes to the evaluation, you need to use the fine-tuned neural link predictor get in the first step, \nor you can download the fine-tuned model 'pretrain_FIT.zip' from [here](https://drive.google.com/drive/folders/17bPr6_ESqh5D0LgWNgpE4mY8gpg2iC5o?usp=sharing).\nAfter downloading or finetuning, move the checkpoint into `pretrain/FIT` folder, the folder should look like this:\n```\npretrain/FIT/FB15k-237/5000.ckpt\n  - /FB15k/...\n  - /NELL/...\n```\nIf you fineutune the neural link predictor yourself, you should also put the checkpoint in the corresponding folder.\n(Manually assign the path of the checkpoint in the config file for testing is also OK, in 'load'/'checkpoint_path' and 'load'/'step')\n\nThen you can run the following code, taking FB15k-237 as an example:\n```\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_EFO1.yaml\n```\n\n\nWe note that the matrix can be directly created by the finetuned neural link predictor, but it will take a long time \nwhen it is created at the first time, then it will be saved in the `sparse` folder.\n\nAn example of the `sparse` sub folder should look like this:\n```\nsparse/FB15k-237\n  - finetune_1p3in.ckpt\n```\n\n\n\n### 2.2 Ablation Study\nIf you want to reproduce the ablation study of the influence of hyperparameter, you can make some adjustment as the following.\n\nFor different max enumeration:\n```\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_m5.yaml\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_m15.yaml\n```\n\nFor different epsilon, delta:\n```\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_EFO1_eps01.yaml\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_EFO1_thres01.yaml\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_EFO1_thres02.yaml\n```\n\n\nFor different c_norm, it is a bit complicated as new neural link predictor should be finetuned first:\n```\npython QG_FIT.py --config config/real_EFO1/FIT_FB15k-237_Godel.yaml\n```\nAfter assigning the path of the finetuned model in the config file,\n(you can also download the finetune neural link predictor [here](https://drive.google.com/drive/folders/17bPr6_ESqh5D0LgWNgpE4mY8gpg2iC5o?usp=sharing)) you can run the following code:\n\n```\npython QG_FIT.py --config config/test_EFO1/FIT_FB15k-237_Godel.yaml\n```\n\n\n## 3. Citing the paper\n\nPlease cite the paper if you found the resources in this repository useful.\n```\n@inproceedings{yin2023rethinking,\n  title={Rethinking Complex Queries on Knowledge Graphs with Neural Link Predictors},\n  author={Yin, Hang and Wang, Zihao and Song, Yangqiu},\n  booktitle={The Twelfth International Conference on Learning Representations},\n  year={2023}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHKUST-KnowComp%2FFIT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHKUST-KnowComp%2FFIT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHKUST-KnowComp%2FFIT/lists"}