linxy commited on
Commit
060bfcc
β€’
1 Parent(s): 23d4ff2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +218 -3
README.md CHANGED
@@ -1,3 +1,218 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ task_categories:
4
+ - graph-ml
5
+ language:
6
+ - en
7
+ size_categories:
8
+ - 1M<n<10M
9
+ ---
10
+
11
+ TL;DR: The datasets for the temporal knowledge graph reasoning task.
12
+
13
+ [[Github]](https://github.com/LinXueyuanStdio/TFLEX)
14
+ [[OpenReview]](https://openreview.net/forum?id=oaGdsgB18L)
15
+ [[arXiv]](https://arxiv.org/abs/2205.14307)
16
+
17
+ - Built over ICEWS and GDELT, which are widely used benchmarks in TKGC.
18
+ - First introduced in paper "TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph"
19
+ - Please refer to the original paper for more details.
20
+
21
+ See also: [[ICEWS14]](https://huggingface.co/datasets/linxy/ICEWS14) [[ICEWS05_15]](https://huggingface.co/datasets/linxy/ICEWS05_15)
22
+
23
+ ## πŸ”¬ Usage
24
+
25
+ ```python
26
+ >>> dataset = load_dataset("linxy/GDELT", "all")
27
+ >>> len(dataset["train"]) + len(dataset["validation"]) + len(dataset["test"])
28
+ 1088769
29
+ >>> dataset["train"][0]
30
+ {'query_name': 'Pe_aPt',
31
+ 'definition': 'def Pe_aPt(e1, r1, e2, r2, e3): return Pe(e1, r1, after(Pt(e2, r2, e3)))',
32
+ 'query': [6291, 372, 5683, 283, 5264],
33
+ 'answer': [1077],
34
+ 'easy_answer': [],
35
+ 'args': ['e1', 'r1', 'e2', 'r2', 'e3']}
36
+ >>> dataset["test"][0]
37
+ {'query_name': 'Pe',
38
+ 'definition': 'def Pe(e1, r1, t1): return Pe(e1, r1, t1)',
39
+ 'query': [1426, 115, 28],
40
+ 'answer': [3697],
41
+ 'easy_answer': [],
42
+ 'args': ['e1', 'r1', 't1']}
43
+ ```
44
+
45
+ 'args' is the argument list of the query function, where name starting with 'e' is entity, and 'r' for relation, 't' for timestamp.
46
+
47
+ assert len(query) == len(args)
48
+
49
+ In order to decode query ids into text, we should use a vocabulary (i.e. entity2idx, relation2idx and timestamp2idx).
50
+ Therefore, we use the code below to load meta info which contains the vocabulary:
51
+
52
+ ```python
53
+ >>> dataset = load_dataset("linxy/GDELT", "meta")
54
+ >>> meta_info = dataset_meta["train"][0]
55
+ >>> meta_info
56
+ {'dataset': 'ICEWS14',
57
+ 'entity_count': 7128,
58
+ 'relation_count': 230,
59
+ 'timestamp_count': 365,
60
+ 'valid_triples_count': 8941,
61
+ 'test_triples_count': 8963,
62
+ 'train_triples_count': 72826,
63
+ 'triple_count': 90730,
64
+ 'query_meta': {'query_name': [...], 'queries_count': [...], 'avg_answers_count': [...], ...},
65
+ 'entity2idx': {'name': [...], 'id': [...]},
66
+ 'relation2idx': {'name': [...], 'id': [...]},
67
+ 'timestamp2idx': {'name': [...], 'id': [...]},
68
+ ```
69
+
70
+ Since the ids in the vocabulary are already sorted, we directly decode to access the name text:
71
+
72
+ ```python
73
+ >>> query
74
+ [1426, 115, 28]
75
+ >>> args
76
+ ['e1', 'r1', 't1']
77
+ >>> for idx, arg_type in zip(query, args):
78
+ if arg_type.startswith('e') or arg_type.startswith('s') or arg_type.startswith('o'): # s, o, e1, e2, ...
79
+ print(idx, meta_info['entity2idx']['name'][idx])
80
+ elif arg_type.startswith('r'): # r, r1, r2, ...
81
+ print(idx, meta_info['relation2idx']['name'][idx])
82
+ elif arg_type.startswith('t'): # t, t1, t2, ...
83
+ print(idx, meta_info['timestamp2idx']['name'][idx])
84
+ ```
85
+
86
+ Besides, we also provide query-type-specific subparts.
87
+
88
+ ```python
89
+ >>> dataset = load_dataset("linxy/GDELT", "e2i")
90
+ >>> some_datasets = [load_dataset("linxy/GDELT", query_name) for query_name in meta_info['query_meta']['query_name']]
91
+ ```
92
+
93
+ Help yourself!
94
+
95
+ <details>
96
+ <summary>πŸ‘ˆ πŸ”Ž Dataset statistics: queries_count</summary>
97
+
98
+ | query | ICEWS14| | | ICEWS05_15| | | GDELT | | |
99
+ | :---- | :---- | :---- | :--- | :---- | :---- | :--- | :---- | :---- | :--- |
100
+ | | train | valid | test | train | valid | test | train | valid | test |
101
+ | Pe | 66783 | 8837 | 8848 | 344042 | 45829 | 45644 | 1115102 | 273842 | 273432 |
102
+ | Pe2 | 72826 | 3482 | 4037 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
103
+ | Pe3 | 72826 | 3492 | 4083 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
104
+ | e2i | 72826 | 3305 | 3655 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
105
+ | e3i | 72826 | 2966 | 3023 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
106
+ | Pt | 42690 | 7331 | 7419 | 142771 | 28795 | 28752 | 687326 | 199780 | 199419 |
107
+ | aPt | 13234 | 4411 | 4411 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
108
+ | bPt | 13234 | 4411 | 4411 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
109
+ | Pe_Pt | 7282 | 3385 | 3638 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
110
+ | Pt_sPe_Pt | 13234 | 5541 | 6293 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
111
+ | Pt_oPe_Pt | 13234 | 5480 | 6242 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
112
+ | t2i | 72826 | 5112 | 6631 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
113
+ | t3i | 72826 | 3094 | 3296 | 368962 | 10000 | 10000 | 2215309 | 10000 | 10000 |
114
+ | e2i_N | 7282 | 2949 | 2975 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
115
+ | e3i_N | 7282 | 2913 | 2914 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
116
+ | Pe_e2i_Pe_NPe | 7282 | 2968 | 3012 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
117
+ | e2i_PeN | 7282 | 2971 | 3031 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
118
+ | e2i_NPe | 7282 | 3061 | 3192 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
119
+ | t2i_N | 7282 | 3135 | 3328 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
120
+ | t3i_N | 7282 | 2924 | 2944 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
121
+ | Pe_t2i_PtPe_NPt | 7282 | 3031 | 3127 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
122
+ | t2i_PtN | 7282 | 3300 | 3609 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
123
+ | t2i_NPt | 7282 | 4873 | 5464 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
124
+ | e2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
125
+ | Pe_e2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
126
+ | t2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
127
+ | Pe_t2u | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
128
+ | t2i_Pe | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
129
+ | Pe_t2i | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
130
+ | e2i_Pe | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
131
+ | Pe_e2i | - | 2913 | 2913 | - | 10000 | 10000 | - | 10000 | 10000 |
132
+ | between | 7282 | 2913 | 2913 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
133
+ | Pe_aPt | 7282 | 4134 | 4733 | 68262 | 10000 | 10000 | 221530 | 10000 | 10000 |
134
+ | Pe_bPt | 7282 | 3970 | 4565 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
135
+ | Pt_sPe | 7282 | 4976 | 5608 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
136
+ | Pt_oPe | 7282 | 3321 | 3621 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
137
+ | Pt_se2i | 7282 | 3226 | 3466 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
138
+ | Pt_oe2i | 7282 | 3236 | 3485 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
139
+ | Pe_at2i | 7282 | 4607 | 5338 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
140
+ | Pe_bt2i | 7282 | 4583 | 5386 | 36896 | 10000 | 10000 | 221530 | 10000 | 10000 |
141
+ </details>
142
+
143
+ <details>
144
+ <summary>πŸ‘ˆ πŸ”Ž Dataset statistics: avg_answers_count</summary>
145
+
146
+ | query | ICEWS14| | | ICEWS05_15| | | GDELT | | |
147
+ | :---- | :---- | :---- | :--- | :---- | :---- | :--- | :---- | :---- | :--- |
148
+ | | train | valid | test | train | valid | test | train | valid | test |
149
+ |Pe | 1.09 | 1.01 | 1.01 | 1.07 | 1.01 | 1.01 | 2.07 | 1.21 | 1.21|
150
+ |Pe2 | 1.03 | 2.19 | 2.23 | 1.02 | 2.15 | 2.19 | 2.61 | 6.51 | 6.13|
151
+ |Pe3 | 1.04 | 2.25 | 2.29 | 1.02 | 2.18 | 2.21 | 5.11 | 10.86 | 10.70|
152
+ |e2i | 1.02 | 2.76 | 2.84 | 1.01 | 2.36 | 2.52 | 1.05 | 2.30 | 2.32|
153
+ |e3i | 1.00 | 1.57 | 1.59 | 1.00 | 1.26 | 1.26 | 1.00 | 1.20 | 1.35|
154
+ |Pt | 1.71 | 1.22 | 1.21 | 2.58 | 1.61 | 1.60 | 3.36 | 1.66 | 1.66|
155
+ |aPt | 177.99 | 176.09 | 175.89 | 2022.16 | 2003.85 | 1998.71 | 156.48 | 155.38 | 153.41|
156
+ |bPt | 181.20 | 179.88 | 179.26 | 1929.98 | 1923.75 | 1919.83 | 160.38 | 159.29 | 157.42|
157
+ |Pe_Pt | 1.58 | 7.90 | 8.62 | 2.84 | 18.11 | 20.63 | 26.56 | 42.54 | 41.33|
158
+ |Pt_sPe_Pt | 1.79 | 7.26 | 7.47 | 2.49 | 13.51 | 10.86 | 4.92 | 14.13 | 12.80|
159
+ |Pt_oPe_Pt | 1.75 | 7.27 | 7.48 | 2.55 | 13.01 | 14.34 | 4.62 | 14.47 | 12.90|
160
+ |t2i | 1.19 | 6.29 | 6.38 | 3.07 | 29.45 | 25.61 | 1.97 | 8.98 | 7.76|
161
+ |t3i | 1.01 | 2.88 | 3.14 | 1.08 | 10.03 | 10.22 | 1.06 | 3.79 | 3.52|
162
+ |e2i_N | 1.02 | 2.10 | 2.14 | 1.01 | 2.05 | 2.08 | 2.04 | 4.66 | 4.58|
163
+ |e3i_N | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.02 | 1.19 | 1.37|
164
+ |Pe_e2i_Pe_NPe | 1.04 | 2.21 | 2.25 | 1.02 | 2.16 | 2.19 | 3.67 | 8.54 | 8.12|
165
+ |e2i_PeN | 1.04 | 2.22 | 2.26 | 1.02 | 2.17 | 2.21 | 3.67 | 8.66 | 8.36|
166
+ |e2i_NPe | 1.18 | 3.03 | 3.11 | 1.12 | 2.87 | 2.99 | 4.00 | 8.15 | 7.81|
167
+ |t2i_N | 1.15 | 3.31 | 3.44 | 1.21 | 4.06 | 4.20 | 2.91 | 8.78 | 7.56|
168
+ |t3i_N | 1.00 | 1.02 | 1.03 | 1.01 | 1.02 | 1.02 | 1.15 | 3.19 | 3.20|
169
+ |Pe_t2i_PtPe_NPt | 1.08 | 2.59 | 2.70 | 1.08 | 2.47 | 2.62 | 4.10 | 12.02 | 11.37|
170
+ |t2i_PtN | 1.41 | 5.22 | 5.47 | 1.70 | 8.10 | 8.11 | 4.56 | 12.56 | 11.32|
171
+ |t2i_NPt | 8.14 | 25.96 | 26.23 | 66.99 | 154.01 | 147.34 | 17.58 | 35.60 | 32.22|
172
+ |e2u | 0.00 | 3.12 | 3.17 | 0.00 | 2.38 | 2.40 | 0.00 | 5.04 | 5.41|
173
+ |Pe_e2u | 0.00 | 2.38 | 2.44 | 0.00 | 1.24 | 1.25 | 0.00 | 9.39 | 10.78|
174
+ |t2u | 0.00 | 4.35 | 4.53 | 0.00 | 5.57 | 5.92 | 0.00 | 9.70 | 10.51|
175
+ |Pe_t2u | 0.00 | 2.72 | 2.83 | 0.00 | 1.24 | 1.28 | 0.00 | 9.90 | 11.27|
176
+ |t2i_Pe | 0.00 | 1.03 | 1.03 | 0.00 | 1.01 | 1.02 | 0.00 | 1.34 | 1.44|
177
+ |Pe_t2i | 0.00 | 1.14 | 1.16 | 0.00 | 1.07 | 1.08 | 0.00 | 2.01 | 2.20|
178
+ |e2i_Pe | 0.00 | 1.00 | 1.00 | 0.00 | 1.00 | 1.00 | 0.00 | 1.07 | 1.10|
179
+ |Pe_e2i | 0.00 | 2.18 | 2.24 | 0.00 | 1.32 | 1.33 | 0.00 | 5.08 | 5.49|
180
+ |between | 122.61 | 120.94 | 120.27 | 1407.87 | 1410.39 | 1404.76 | 214.16 | 210.99 | 207.85|
181
+ |Pe_aPt | 4.67 | 16.73 | 16.50 | 18.68 | 43.80 | 46.23 | 49.31 | 66.21 | 68.88|
182
+ |Pe_bPt | 4.53 | 17.07 | 16.80 | 18.70 | 45.81 | 48.23 | 67.67 | 84.79 | 83.00|
183
+ |Pt_sPe | 8.65 | 28.86 | 29.22 | 71.51 | 162.36 | 155.46 | 27.55 | 45.83 | 43.73|
184
+ |Pt_oPe | 1.41 | 5.23 | 5.46 | 1.68 | 8.36 | 8.21 | 3.84 | 11.31 | 10.06|
185
+ |Pt_se2i | 1.31 | 5.72 | 6.19 | 1.37 | 9.00 | 9.30 | 2.76 | 8.72 | 7.66|
186
+ |Pt_oe2i | 1.32 | 6.51 | 7.00 | 1.44 | 10.49 | 10.89 | 2.55 | 8.17 | 7.27|
187
+ |Pe_at2i | 7.26 | 22.63 | 21.98 | 30.40 | 60.03 | 53.18 | 88.77 | 101.60 | 101.88|
188
+ |Pe_bt2i | 7.27 | 21.92 | 21.23 | 30.31 | 61.59 | 64.98 | 88.80 | 100.64 | 100.67|
189
+ </details>
190
+
191
+ <br/>
192
+
193
+ ## βœ‰οΈ Contact
194
+
195
+ - Lin Xueyuan: linxy59@mail2.sysu.edu.cn
196
+
197
+ ## 🀝 Citation
198
+
199
+ Please condiser citing this paper if you use the ```code``` or ```data``` from our work. Thanks a lot :)
200
+
201
+ (`Xueyuan et al., 2023` preferred, instead of `Lin et al., 2023`)
202
+
203
+ ```bibtex
204
+ @inproceedings{
205
+ xueyuan2023tflex,
206
+ title={TFLEX: Temporal Feature-Logic Embedding Framework for Complex Reasoning over Temporal Knowledge Graph},
207
+ 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},
208
+ booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
209
+ year={2023},
210
+ url={https://openreview.net/forum?id=oaGdsgB18L}
211
+ }
212
+ ```
213
+
214
+ ---
215
+
216
+ TFLEX is released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) license.
217
+
218
+ <p align="right">(<a href="#top">back to top</a>)</p>