CoolFace
Datasetpublic

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.

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes161downloads
Dataset Card

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

python
>>> 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:

python
>>> 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:

python
>>> 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.

python
>>> 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>

queryICEWS14ICEWS05_15GDELT
trainvalidtesttrainvalidtesttrainvalidtest
Pe667838837884834404245829456441115102273842273432
Pe27282634824037368962100001000022153091000010000
Pe37282634924083368962100001000022153091000010000
e2i7282633053655368962100001000022153091000010000
e3i7282629663023368962100001000022153091000010000
Pt42690733174191427712879528752687326199780199419
aPt13234441144116826210000100002215301000010000
bPt13234441144116826210000100002215301000010000
Pe_Pt7282338536383689610000100002215301000010000
PtsPePt13234554162936826210000100002215301000010000
PtoPePt13234548062426826210000100002215301000010000
t2i7282651126631368962100001000022153091000010000
t3i7282630943296368962100001000022153091000010000
e2i_N7282294929753689610000100002215301000010000
e3i_N7282291329143689610000100002215301000010000
Pee2iPe_NPe7282296830123689610000100002215301000010000
e2i_PeN7282297130313689610000100002215301000010000
e2i_NPe7282306131923689610000100002215301000010000
t2i_N7282313533283689610000100002215301000010000
t3i_N7282292429443689610000100002215301000010000
Pet2iPtPe_NPt7282303131273689610000100002215301000010000
t2i_PtN7282330036093689610000100002215301000010000
t2i_NPt7282487354643689610000100002215301000010000
e2u-29132913-1000010000-1000010000
Pe_e2u-29132913-1000010000-1000010000
t2u-29132913-1000010000-1000010000
Pe_t2u-29132913-1000010000-1000010000
t2i_Pe-29132913-1000010000-1000010000
Pe_t2i-29132913-1000010000-1000010000
e2i_Pe-29132913-1000010000-1000010000
Pe_e2i-29132913-1000010000-1000010000
between7282291329133689610000100002215301000010000
Pe_aPt7282413447336826210000100002215301000010000
Pe_bPt7282397045653689610000100002215301000010000
Pt_sPe7282497656083689610000100002215301000010000
Pt_oPe7282332136213689610000100002215301000010000
Pt_se2i7282322634663689610000100002215301000010000
Pt_oe2i7282323634853689610000100002215301000010000
Pe_at2i7282460753383689610000100002215301000010000
Pe_bt2i7282458353863689610000100002215301000010000

</details>

<details> <summary>👈 🔎 Dataset statistics: avganswerscount</summary>

queryICEWS14ICEWS05_15GDELT
trainvalidtesttrainvalidtesttrainvalidtest
Pe1.091.011.011.071.011.012.071.211.21
Pe21.032.192.231.022.152.192.616.516.13
Pe31.042.252.291.022.182.215.1110.8610.70
e2i1.022.762.841.012.362.521.052.302.32
e3i1.001.571.591.001.261.261.001.201.35
Pt1.711.221.212.581.611.603.361.661.66
aPt177.99176.09175.892022.162003.851998.71156.48155.38153.41
bPt181.20179.88179.261929.981923.751919.83160.38159.29157.42
Pe_Pt1.587.908.622.8418.1120.6326.5642.5441.33
PtsPePt1.797.267.472.4913.5110.864.9214.1312.80
PtoPePt1.757.277.482.5513.0114.344.6214.4712.90
t2i1.196.296.383.0729.4525.611.978.987.76
t3i1.012.883.141.0810.0310.221.063.793.52
e2i_N1.022.102.141.012.052.082.044.664.58
e3i_N1.001.001.001.001.001.001.021.191.37
Pee2iPe_NPe1.042.212.251.022.162.193.678.548.12
e2i_PeN1.042.222.261.022.172.213.678.668.36
e2i_NPe1.183.033.111.122.872.994.008.157.81
t2i_N1.153.313.441.214.064.202.918.787.56
t3i_N1.001.021.031.011.021.021.153.193.20
Pet2iPtPe_NPt1.082.592.701.082.472.624.1012.0211.37
t2i_PtN1.415.225.471.708.108.114.5612.5611.32
t2i_NPt8.1425.9626.2366.99154.01147.3417.5835.6032.22
e2u0.003.123.170.002.382.400.005.045.41
Pe_e2u0.002.382.440.001.241.250.009.3910.78
t2u0.004.354.530.005.575.920.009.7010.51
Pe_t2u0.002.722.830.001.241.280.009.9011.27
t2i_Pe0.001.031.030.001.011.020.001.341.44
Pe_t2i0.001.141.160.001.071.080.002.012.20
e2i_Pe0.001.001.000.001.001.000.001.071.10
Pe_e2i0.002.182.240.001.321.330.005.085.49
between122.61120.94120.271407.871410.391404.76214.16210.99207.85
Pe_aPt4.6716.7316.5018.6843.8046.2349.3166.2168.88
Pe_bPt4.5317.0716.8018.7045.8148.2367.6784.7983.00
Pt_sPe8.6528.8629.2271.51162.36155.4627.5545.8343.73
Pt_oPe1.415.235.461.688.368.213.8411.3110.06
Pt_se2i1.315.726.191.379.009.302.768.727.66
Pt_oe2i1.326.517.001.4410.4910.892.558.177.27
Pe_at2i7.2622.6321.9830.4060.0353.1888.77101.60101.88
Pe_bt2i7.2721.9221.2330.3161.5964.9888.80100.64100.67

</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)

bibtex
@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>