{"id":13605369,"url":"https://github.com/snap-stanford/KGReasoning","last_synced_at":"2025-04-12T05:32:43.641Z","repository":{"id":50004432,"uuid":"306432023","full_name":"snap-stanford/KGReasoning","owner":"snap-stanford","description":"Multi-Hop Logical Reasoning in Knowledge Graphs","archived":false,"fork":false,"pushed_at":"2022-03-27T20:05:19.000Z","size":21,"stargazers_count":291,"open_issues_count":10,"forks_count":57,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-05T13:47:01.414Z","etag":null,"topics":["embedding","knowledge-base","knowledge-graph","reasoning"],"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/snap-stanford.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}},"created_at":"2020-10-22T18:55:12.000Z","updated_at":"2025-02-27T17:53:38.000Z","dependencies_parsed_at":"2022-09-14T15:02:04.234Z","dependency_job_id":null,"html_url":"https://github.com/snap-stanford/KGReasoning","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/snap-stanford%2FKGReasoning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FKGReasoning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FKGReasoning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snap-stanford%2FKGReasoning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snap-stanford","download_url":"https://codeload.github.com/snap-stanford/KGReasoning/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248524185,"owners_count":21118609,"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":["embedding","knowledge-base","knowledge-graph","reasoning"],"created_at":"2024-08-01T19:00:57.911Z","updated_at":"2025-04-12T05:32:43.396Z","avatar_url":"https://github.com/snap-stanford.png","language":"Python","funding_links":[],"categories":[":wrench: Implementations"],"sub_categories":["Dataset tools"],"readme":"# KGReasoning\nThis repo contains several algorithms for multi-hop reasoning on knowledge graphs, including the official Pytorch implementation of [Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs](https://arxiv.org/abs/2010.11465).\n\n**Models**\n- [x] [BetaE](https://arxiv.org/abs/2010.11465)\n- [x] [Query2box](https://arxiv.org/abs/2002.05969)\n- [x] [GQE](https://arxiv.org/abs/1806.01445)\n\n**KG Data**\n\nThe KG data (FB15k, FB15k-237, NELL995) mentioned in the BetaE paper and the Query2box paper can be downloaded [here](http://snap.stanford.edu/betae/KG_data.zip). Note the two use the same training queries, but the difference is that the valid/test queries in BetaE paper have a maximum number of answers, making it more realistic.\n\nEach folder in the data represents a KG, including the following files.\n- `train.txt/valid.txt/test.txt`: KG edges\n- `id2rel/rel2id/ent2id/id2ent.pkl`: KG entity relation dicts\n- `train-queries/valid-queries/test-queries.pkl`: `defaultdict(set)`, each key represents a query structure, and the value represents the instantiated queries\n- `train-answers.pkl`: `defaultdict(set)`, each key represents a query, and the value represents the answers obtained in the training graph (edges in `train.txt`)\n- `valid-easy-answers/test-easy-answers.pkl`: `defaultdict(set)`, each key represents a query, and the value represents the answers obtained in the training graph (edges in `train.txt`) / valid graph (edges in `train.txt`+`valid.txt`)\n- `valid-hard-answers/test-hard-answers.pkl`: `defaultdict(set)`, each key represents a query, and the value represents the **additional** answers obtained in the validation graph (edges in `train.txt`+`valid.txt`) / test graph (edges in `train.txt`+`valid.txt`+`test.txt`)\n\nWe represent the query structures using a tuple in case we run out of names :), (credits to @michiyasunaga). For example, 1p queries: (e, (r,)) and 2i queries: ((e, (r,)),(e, (r,))). Check the code for more details.\n\n**Examples**\n\nPlease refer to the `examples.sh` for the scripts of all 3 models on all 3 datasets.\n\n**Citations**\n\nIf you use this repo, please cite the following paper.\n\n```\n@inproceedings{\n ren2020beta,\n title={Beta Embeddings for Multi-Hop Logical Reasoning in Knowledge Graphs},\n author={Hongyu Ren and Jure Leskovec},\n booktitle={Neural Information Processing Systems},\n year={2020}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnap-stanford%2FKGReasoning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnap-stanford%2FKGReasoning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnap-stanford%2FKGReasoning/lists"}