license: apache-2.0
task_categories:
- graph-ml
language:
- en
size_categories:
- 1M<n<10M
TL;DR: The datasets for the temporal knowledge graph reasoning task.
- 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] [ICEWS05_15]
π¬ Usage
>>> dataset = load_dataset("linxy/GDELT", "all")
>>> len(dataset["train"]) + len(dataset["validation"]) + len(dataset["test"])
1088769
>>> dataset["train"][0]
{'query_name': 'Pe_aPt',
'definition': 'def Pe_aPt(e1, r1, e2, r2, e3): return Pe(e1, r1, after(Pt(e2, r2, e3)))',
'query': [6291, 372, 5683, 283, 5264],
'answer': [1077],
'easy_answer': [],
'args': ['e1', 'r1', 'e2', 'r2', 'e3']}
>>> dataset["test"][0]
{'query_name': 'Pe',
'definition': 'def Pe(e1, r1, t1): return Pe(e1, r1, t1)',
'query': [1426, 115, 28],
'answer': [3697],
'easy_answer': [],
'args': ['e1', 'r1', 't1']}
'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': 'ICEWS14',
'entity_count': 7128,
'relation_count': 230,
'timestamp_count': 365,
'valid_triples_count': 8941,
'test_triples_count': 8963,
'train_triples_count': 72826,
'triple_count': 90730,
'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
[1426, 115, 28]
>>> 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!
π π Dataset statistics: queries_count
query | ICEWS14 | ICEWS05_15 | GDELT | ||||||
---|---|---|---|---|---|---|---|---|---|
train | valid | test | train | valid | test | train | valid | test | |
Pe | 66783 | 8837 | 8848 | 344042 | 45829 | 45644 | 1115102 | 273842 | 273432 |
Pe2 | 72826 | 3482 | 4037 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
Pe3 | 72826 | 3492 | 4083 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
e2i | 72826 | 3305 | 3655 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
e3i | 72826 | 2966 | 3023 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
Pt | 42690 | 7331 | 7419 | 142771 | 28795 | 28752 | 687326 | 199780 | 199419 |
aPt | 13234 | 4411 | 4411 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
bPt | 13234 | 4411 | 4411 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_Pt | 7282 | 3385 | 3638 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_sPe_Pt | 13234 | 5541 | 6293 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_oPe_Pt | 13234 | 5480 | 6242 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
t2i | 72826 | 5112 | 6631 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
t3i | 72826 | 3094 | 3296 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
e2i_N | 7282 | 2949 | 2975 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
e3i_N | 7282 | 2913 | 2914 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_e2i_Pe_NPe | 7282 | 2968 | 3012 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
e2i_PeN | 7282 | 2971 | 3031 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
e2i_NPe | 7282 | 3061 | 3192 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
t2i_N | 7282 | 3135 | 3328 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
t3i_N | 7282 | 2924 | 2944 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_t2i_PtPe_NPt | 7282 | 3031 | 3127 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
t2i_PtN | 7282 | 3300 | 3609 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
t2i_NPt | 7282 | 4873 | 5464 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
e2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
Pe_e2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
t2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
Pe_t2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
t2i_Pe | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
Pe_t2i | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
e2i_Pe | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
Pe_e2i | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
between | 7282 | 2913 | 2913 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_aPt | 7282 | 4134 | 4733 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_bPt | 7282 | 3970 | 4565 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_sPe | 7282 | 4976 | 5608 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_oPe | 7282 | 3321 | 3621 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_se2i | 7282 | 3226 | 3466 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pt_oe2i | 7282 | 3236 | 3485 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_at2i | 7282 | 4607 | 5338 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
Pe_bt2i | 7282 | 4583 | 5386 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
π π Dataset statistics: avg_answers_count
query | ICEWS14 | ICEWS05_15 | GDELT | ||||||
---|---|---|---|---|---|---|---|---|---|
train | valid | test | train | valid | test | train | valid | test | |
Pe | 1.09 | 1.01 | 1.01 | 1.07 | 1.01 | 1.01 | 2.07 | 1.21 | 1.21 |
Pe2 | 1.03 | 2.19 | 2.23 | 1.02 | 2.15 | 2.19 | 2.61 | 6.51 | 6.13 |
Pe3 | 1.04 | 2.25 | 2.29 | 1.02 | 2.18 | 2.21 | 5.11 | 10.86 | 10.70 |
e2i | 1.02 | 2.76 | 2.84 | 1.01 | 2.36 | 2.52 | 1.05 | 2.30 | 2.32 |
e3i | 1.00 | 1.57 | 1.59 | 1.00 | 1.26 | 1.26 | 1.00 | 1.20 | 1.35 |
Pt | 1.71 | 1.22 | 1.21 | 2.58 | 1.61 | 1.60 | 3.36 | 1.66 | 1.66 |
aPt | 177.99 | 176.09 | 175.89 | 2022.16 | 2003.85 | 1998.71 | 156.48 | 155.38 | 153.41 |
bPt | 181.20 | 179.88 | 179.26 | 1929.98 | 1923.75 | 1919.83 | 160.38 | 159.29 | 157.42 |
Pe_Pt | 1.58 | 7.90 | 8.62 | 2.84 | 18.11 | 20.63 | 26.56 | 42.54 | 41.33 |
Pt_sPe_Pt | 1.79 | 7.26 | 7.47 | 2.49 | 13.51 | 10.86 | 4.92 | 14.13 | 12.80 |
Pt_oPe_Pt | 1.75 | 7.27 | 7.48 | 2.55 | 13.01 | 14.34 | 4.62 | 14.47 | 12.90 |
t2i | 1.19 | 6.29 | 6.38 | 3.07 | 29.45 | 25.61 | 1.97 | 8.98 | 7.76 |
t3i | 1.01 | 2.88 | 3.14 | 1.08 | 10.03 | 10.22 | 1.06 | 3.79 | 3.52 |
e2i_N | 1.02 | 2.10 | 2.14 | 1.01 | 2.05 | 2.08 | 2.04 | 4.66 | 4.58 |
e3i_N | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.02 | 1.19 | 1.37 |
Pe_e2i_Pe_NPe | 1.04 | 2.21 | 2.25 | 1.02 | 2.16 | 2.19 | 3.67 | 8.54 | 8.12 |
e2i_PeN | 1.04 | 2.22 | 2.26 | 1.02 | 2.17 | 2.21 | 3.67 | 8.66 | 8.36 |
e2i_NPe | 1.18 | 3.03 | 3.11 | 1.12 | 2.87 | 2.99 | 4.00 | 8.15 | 7.81 |
t2i_N | 1.15 | 3.31 | 3.44 | 1.21 | 4.06 | 4.20 | 2.91 | 8.78 | 7.56 |
t3i_N | 1.00 | 1.02 | 1.03 | 1.01 | 1.02 | 1.02 | 1.15 | 3.19 | 3.20 |
Pe_t2i_PtPe_NPt | 1.08 | 2.59 | 2.70 | 1.08 | 2.47 | 2.62 | 4.10 | 12.02 | 11.37 |
t2i_PtN | 1.41 | 5.22 | 5.47 | 1.70 | 8.10 | 8.11 | 4.56 | 12.56 | 11.32 |
t2i_NPt | 8.14 | 25.96 | 26.23 | 66.99 | 154.01 | 147.34 | 17.58 | 35.60 | 32.22 |
e2u | 0.00 | 3.12 | 3.17 | 0.00 | 2.38 | 2.40 | 0.00 | 5.04 | 5.41 |
Pe_e2u | 0.00 | 2.38 | 2.44 | 0.00 | 1.24 | 1.25 | 0.00 | 9.39 | 10.78 |
t2u | 0.00 | 4.35 | 4.53 | 0.00 | 5.57 | 5.92 | 0.00 | 9.70 | 10.51 |
Pe_t2u | 0.00 | 2.72 | 2.83 | 0.00 | 1.24 | 1.28 | 0.00 | 9.90 | 11.27 |
t2i_Pe | 0.00 | 1.03 | 1.03 | 0.00 | 1.01 | 1.02 | 0.00 | 1.34 | 1.44 |
Pe_t2i | 0.00 | 1.14 | 1.16 | 0.00 | 1.07 | 1.08 | 0.00 | 2.01 | 2.20 |
e2i_Pe | 0.00 | 1.00 | 1.00 | 0.00 | 1.00 | 1.00 | 0.00 | 1.07 | 1.10 |
Pe_e2i | 0.00 | 2.18 | 2.24 | 0.00 | 1.32 | 1.33 | 0.00 | 5.08 | 5.49 |
between | 122.61 | 120.94 | 120.27 | 1407.87 | 1410.39 | 1404.76 | 214.16 | 210.99 | 207.85 |
Pe_aPt | 4.67 | 16.73 | 16.50 | 18.68 | 43.80 | 46.23 | 49.31 | 66.21 | 68.88 |
Pe_bPt | 4.53 | 17.07 | 16.80 | 18.70 | 45.81 | 48.23 | 67.67 | 84.79 | 83.00 |
Pt_sPe | 8.65 | 28.86 | 29.22 | 71.51 | 162.36 | 155.46 | 27.55 | 45.83 | 43.73 |
Pt_oPe | 1.41 | 5.23 | 5.46 | 1.68 | 8.36 | 8.21 | 3.84 | 11.31 | 10.06 |
Pt_se2i | 1.31 | 5.72 | 6.19 | 1.37 | 9.00 | 9.30 | 2.76 | 8.72 | 7.66 |
Pt_oe2i | 1.32 | 6.51 | 7.00 | 1.44 | 10.49 | 10.89 | 2.55 | 8.17 | 7.27 |
Pe_at2i | 7.26 | 22.63 | 21.98 | 30.40 | 60.03 | 53.18 | 88.77 | 101.60 | 101.88 |
Pe_bt2i | 7.27 | 21.92 | 21.23 | 30.31 | 61.59 | 64.98 | 88.80 | 100.64 | 100.67 |
βοΈ Contact
- Lin Xueyuan: [email protected]
π€ 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.