linxy/GDELT
\ TL;DR: The datasets for temporal knowledge graph reasoning task. [[Github]](https://github.com/LinXueyuanStdio/TFLEX) [[OpenReview]](https://openreview.net/forum?id=oaGdsgB18L) [[arXiv]](https://arxiv.org/abs/2205.14307) - Built over ICEWS and GDELT, which are widly used benchmarks in TKGC. - First introduced in paper "TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph" - Please refer to the original paper for more details.
TL;DR: The datasets for the temporal knowledge graph reasoning task.
[[Github]](https://github.com/LinXueyuanStdio/TFLEX) [[OpenReview]](https://openreview.net/forum?id=oaGdsgB18L) [[arXiv]](https://arxiv.org/abs/2205.14307)
- Built over ICEWS and GDELT, which are widely used benchmarks in TKGC.
- First introduced in paper "TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph"
- Please refer to the original paper for more details.
See also: [[ICEWS14]](https://huggingface.co/datasets/linxy/ICEWS14) [[ICEWS0515]](https://huggingface.co/datasets/linxy/ICEWS0515)
🔬 Usage
>>> dataset = load_dataset("linxy/GDELT", "all")
>>> len(dataset["train"]) + len(dataset["validation"]) + len(dataset["test"])
22117475
>>> dataset["train"][0]
{'query_name': 'Pe',
'definition': 'def Pe(e1, r1, t1): return Pe(e1, r1, t1)',
'query': [483, 18, 217],
'answer': [26, 33, 40, 45, 65, 105, 107, 121, 139, 172, 187, 216, 264, 270, 313, 460, 480, 493],
'easy_answer': [],
'args': ['e1', 'r1', 't1']}
>>> dataset["test"][0]
{'query_name': 'Pe2',
'definition': 'def Pe2(e1, r1, t1, r2, t2): return Pe(Pe(e1, r1, t1), r2, t2)',
'query': [242, 38, 229, 1, 244],
'answer': [9, 11, 24, 46, 76, 121, 140, 146, 209, 275, 280, 300, 380, 445, 463, 484],
'easy_answer': [9, 11, 24, 46, 76, 146, 280, 300, 380, 445, 484],
'args': ['e1', 'r1', 't1', 'r2', 't2']}'args' is the argument list of the query function, where name starting with 'e' is entity, and 'r' for relation, 't' for timestamp.
assert len(query) == len(args)
In order to decode query ids into text, we should use a vocabulary (i.e. entity2idx, relation2idx and timestamp2idx). Therefore, we use the code below to load meta info which contains the vocabulary:
>>> dataset = load_dataset("linxy/GDELT", "meta")
>>> meta_info = dataset_meta["train"][0]
>>> meta_info
{'dataset': 'GDELT',
'entity_count': 500,
'relation_count': 20,
'timestamp_count': 366,
'valid_triples_count': 330906,
'test_triples_count': 330845,
'train_triples_count': 2308165,
'triple_count': 2969916,
'query_meta': {'query_name': [...], 'queries_count': [...], 'avg_answers_count': [...], ...},
'entity2idx': {'name': [...], 'id': [...]},
'relation2idx': {'name': [...], 'id': [...]},
'timestamp2idx': {'name': [...], 'id': [...]},Since the ids in the vocabulary are already sorted, we directly decode to access the name text:
>>> query
[483, 18, 217]
>>> args
['e1', 'r1', 't1']
>>> for idx, arg_type in zip(query, args):
if arg_type.startswith('e') or arg_type.startswith('s') or arg_type.startswith('o'): # s, o, e1, e2, ...
print(idx, meta_info['entity2idx']['name'][idx])
elif arg_type.startswith('r'): # r, r1, r2, ...
print(idx, meta_info['relation2idx']['name'][idx])
elif arg_type.startswith('t'): # t, t1, t2, ...
print(idx, meta_info['timestamp2idx']['name'][idx])Besides, we also provide query-type-specific subparts.
>>> dataset = load_dataset("linxy/GDELT", "e2i")
>>> some_datasets = [load_dataset("linxy/GDELT", query_name) for query_name in meta_info['query_meta']['query_name']]Help yourself!
<details> <summary>👈 🔎 Dataset statistics: queries_count</summary>
</details>
<details> <summary>👈 🔎 Dataset statistics: avganswerscount</summary>
</details>
<br/>
✉️ Contact
- Lin Xueyuan: linxy59@mail2.sysu.edu.cn
🤝 Citation
Please condiser citing this paper if you use the ``code` or `data`` from our work. Thanks a lot :)
(Xueyuan et al., 2023 preferred, instead of Lin et al., 2023)
@inproceedings{
xueyuan2023tflex,
title={TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph},
author={Lin Xueyuan and Haihong E and Chengjin Xu and Gengxian Zhou and Haoran Luo and Tianyi Hu and Fenglong Su and Ningyuan Li and Mingzhi Sun},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=oaGdsgB18L}
}TFLEX is released under the Apache License 2.0 license.
<p align="right">(<a href="#top">back to top</a>)</p>
