Datasets:

Modalities:
Text
Libraries:
Datasets
Jon Gauthier commited on
Commit
e019438
·
1 Parent(s): abe5584

add pytest comparison between gpt2 outputs from this code and from syntaxgym-core

Browse files
Files changed (1) hide show
  1. test.py +507 -9
test.py CHANGED
@@ -1,17 +1,515 @@
1
- import itertools
2
  from typing import List
3
 
4
  import datasets
5
  import numpy as np
6
- import transformers
7
- import torch
8
 
 
9
 
10
- dataset = datasets.load_dataset("syntaxgym", "subordination_src-src")
11
- metric = datasets.load_metric("syntaxgym")
12
 
13
- model_ref = "gpt2"
14
- # model_ref = "hf-internal-testing/tiny-random-gpt_neo"
 
15
 
16
- result = metric.compute(suite=dataset["test"], model_id=model_ref)
17
- print(result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from typing import List
2
 
3
  import datasets
4
  import numpy as np
 
 
5
 
6
+ import pytest
7
 
 
 
8
 
9
+ @pytest.fixture(scope="session")
10
+ def syntaxgym_dataset():
11
+ return datasets.load_dataset("syntaxgym", "subordination_src-src")
12
 
13
+
14
+ @pytest.fixture(scope="session")
15
+ def syntaxgym_metric():
16
+ return datasets.load_metric("syntaxgym")
17
+
18
+
19
+ @pytest.fixture(scope="session")
20
+ def model_ref():
21
+ # return "hf-internal-testing/tiny-random-gpt_neo"
22
+ return "gpt2"
23
+
24
+
25
+ # Reference region surprisals computed with syntaxgym-core.
26
+ # See notebook in https://colab.research.google.com/drive/1qziyPcu65jffizSPi-ZGHKR0x7BaHFMS#scrollTo=RgtnScy6LLKi .
27
+ GPT2_SUBORDINATION_SRC_REFERENCE = \
28
+ [{('no-sub_matrix', 1): 13.151199615123803,
29
+ ('no-sub_matrix', 2): 38.503222716703526,
30
+ ('no-sub_matrix', 3): 27.623861034812286,
31
+ ('no-sub_matrix', 4): 48.831672846038224,
32
+ ('no-sub_matrix', 5): 38.08533699286694,
33
+ ('no-sub_no-matrix', 1): 13.151199615123803,
34
+ ('no-sub_no-matrix', 2): 38.503222716703526,
35
+ ('no-sub_no-matrix', 3): 27.623861034812286,
36
+ ('no-sub_no-matrix', 4): 48.831687980511504,
37
+ ('no-sub_no-matrix', 5): 1.8096143510772873,
38
+ ('sub_matrix', 1): 14.905592916748805,
39
+ ('sub_matrix', 2): 39.06304309956175,
40
+ ('sub_matrix', 3): 26.862648365854433,
41
+ ('sub_matrix', 4): 50.56554401687938,
42
+ ('sub_matrix', 5): 26.532245572980194,
43
+ ('sub_no-matrix', 1): 14.905592916748805,
44
+ ('sub_no-matrix', 2): 39.06304309956175,
45
+ ('sub_no-matrix', 3): 26.862648365854433,
46
+ ('sub_no-matrix', 4): 50.56553438585093,
47
+ ('sub_no-matrix', 5): 7.470089829866611},
48
+ {('no-sub_matrix', 1): 10.116093820255577,
49
+ ('no-sub_matrix', 2): 20.96513246705127,
50
+ ('no-sub_matrix', 3): 20.02959138986416,
51
+ ('no-sub_matrix', 4): 23.779661397107446,
52
+ ('no-sub_matrix', 5): 33.2560281692696,
53
+ ('no-sub_no-matrix', 1): 10.116093820255577,
54
+ ('no-sub_no-matrix', 2): 20.96513246705127,
55
+ ('no-sub_no-matrix', 3): 20.02959138986416,
56
+ ('no-sub_no-matrix', 4): 23.779661397107446,
57
+ ('no-sub_no-matrix', 5): 1.9449125865631063,
58
+ ('sub_matrix', 1): 13.545157521732826,
59
+ ('sub_matrix', 2): 24.96048395897244,
60
+ ('sub_matrix', 3): 18.609464944317324,
61
+ ('sub_matrix', 4): 23.057566440062317,
62
+ ('sub_matrix', 5): 26.424454285669032,
63
+ ('sub_no-matrix', 1): 13.545157521732826,
64
+ ('sub_no-matrix', 2): 24.96048395897244,
65
+ ('sub_no-matrix', 3): 18.609464944317324,
66
+ ('sub_no-matrix', 4): 23.057566440062317,
67
+ ('sub_no-matrix', 5): 2.807467838359704},
68
+ {('no-sub_matrix', 1): 11.992867568477442,
69
+ ('no-sub_matrix', 2): 45.813114232935774,
70
+ ('no-sub_matrix', 3): 24.57554828372551,
71
+ ('no-sub_matrix', 4): 45.334025774062916,
72
+ ('no-sub_matrix', 5): 26.208189541862073,
73
+ ('no-sub_no-matrix', 1): 11.992867568477442,
74
+ ('no-sub_no-matrix', 2): 45.813114232935774,
75
+ ('no-sub_no-matrix', 3): 24.57554828372551,
76
+ ('no-sub_no-matrix', 4): 45.33402766587207,
77
+ ('no-sub_no-matrix', 5): 1.8284485151385752,
78
+ ('sub_matrix', 1): 14.219887768799735,
79
+ ('sub_matrix', 2): 46.25055434117979,
80
+ ('sub_matrix', 3): 23.054221678472672,
81
+ ('sub_matrix', 4): 47.08503858470256,
82
+ ('sub_matrix', 5): 22.154772321452022,
83
+ ('sub_no-matrix', 1): 14.219887768799735,
84
+ ('sub_no-matrix', 2): 46.25055434117979,
85
+ ('sub_no-matrix', 3): 23.054221678472672,
86
+ ('sub_no-matrix', 4): 47.08503858470256,
87
+ ('sub_no-matrix', 5): 3.0655133594366757},
88
+ {('no-sub_matrix', 1): 10.55002943802296,
89
+ ('no-sub_matrix', 2): 52.419810137608856,
90
+ ('no-sub_matrix', 3): 23.30710475332303,
91
+ ('no-sub_matrix', 4): 37.957905964008944,
92
+ ('no-sub_matrix', 5): 29.259648135104936,
93
+ ('no-sub_no-matrix', 1): 10.55002943802296,
94
+ ('no-sub_no-matrix', 2): 52.419810137608856,
95
+ ('no-sub_no-matrix', 3): 23.30710475332303,
96
+ ('no-sub_no-matrix', 4): 37.957905964008944,
97
+ ('no-sub_no-matrix', 5): 1.9632913405649093,
98
+ ('sub_matrix', 1): 15.289384584900025,
99
+ ('sub_matrix', 2): 53.93652737134243,
100
+ ('sub_matrix', 3): 19.43915835312633,
101
+ ('sub_matrix', 4): 36.459591551099386,
102
+ ('sub_matrix', 5): 22.185742699245417,
103
+ ('sub_no-matrix', 1): 15.289384584900025,
104
+ ('sub_no-matrix', 2): 53.93652737134243,
105
+ ('sub_no-matrix', 3): 19.43915835312633,
106
+ ('sub_no-matrix', 4): 36.4595598203003,
107
+ ('sub_no-matrix', 5): 5.707732355645454},
108
+ {('no-sub_matrix', 1): 23.543723213902986,
109
+ ('no-sub_matrix', 2): 31.967972102825854,
110
+ ('no-sub_matrix', 3): 29.159572978411727,
111
+ ('no-sub_matrix', 4): 36.61365345925747,
112
+ ('no-sub_matrix', 5): 44.576591305970545,
113
+ ('no-sub_no-matrix', 1): 23.543723213902986,
114
+ ('no-sub_no-matrix', 2): 31.967972102825854,
115
+ ('no-sub_no-matrix', 3): 29.159572978411727,
116
+ ('no-sub_no-matrix', 4): 36.61365345925747,
117
+ ('no-sub_no-matrix', 5): 3.2813457388593714,
118
+ ('sub_matrix', 1): 27.118410129310597,
119
+ ('sub_matrix', 2): 33.909617362987866,
120
+ ('sub_matrix', 3): 28.791166362258743,
121
+ ('sub_matrix', 4): 37.24960609010374,
122
+ ('sub_matrix', 5): 31.660933798006262,
123
+ ('sub_no-matrix', 1): 27.118410129310597,
124
+ ('sub_no-matrix', 2): 33.909617362987866,
125
+ ('sub_no-matrix', 3): 28.791166362258743,
126
+ ('sub_no-matrix', 4): 37.24960609010374,
127
+ ('sub_no-matrix', 5): 7.3613541428239015},
128
+ {('no-sub_matrix', 1): 14.22171869610082,
129
+ ('no-sub_matrix', 2): 30.270423022911977,
130
+ ('no-sub_matrix', 3): 25.973276891204705,
131
+ ('no-sub_matrix', 4): 28.43856735947716,
132
+ ('no-sub_matrix', 5): 57.39887418731055,
133
+ ('no-sub_no-matrix', 1): 14.22171869610082,
134
+ ('no-sub_no-matrix', 2): 30.270423022911977,
135
+ ('no-sub_no-matrix', 3): 25.973276891204705,
136
+ ('no-sub_no-matrix', 4): 28.43856735947716,
137
+ ('no-sub_no-matrix', 5): 1.7127059109344136,
138
+ ('sub_matrix', 1): 16.39289784951447,
139
+ ('sub_matrix', 2): 31.5671111565765,
140
+ ('sub_matrix', 3): 24.54307828171008,
141
+ ('sub_matrix', 4): 29.249645624130757,
142
+ ('sub_matrix', 5): 53.59155769093577,
143
+ ('sub_no-matrix', 1): 16.39289784951447,
144
+ ('sub_no-matrix', 2): 31.5671111565765,
145
+ ('sub_no-matrix', 3): 24.54307828171008,
146
+ ('sub_no-matrix', 4): 29.249645624130757,
147
+ ('sub_no-matrix', 5): 7.225276653947023},
148
+ {('no-sub_matrix', 1): 13.729688714733188,
149
+ ('no-sub_matrix', 2): 36.018118127225165,
150
+ ('no-sub_matrix', 3): 28.232055923783275,
151
+ ('no-sub_matrix', 4): 44.44634394296659,
152
+ ('no-sub_matrix', 5): 38.277975147059344,
153
+ ('no-sub_no-matrix', 1): 13.729688714733188,
154
+ ('no-sub_no-matrix', 2): 36.018118127225165,
155
+ ('no-sub_no-matrix', 3): 28.232055923783275,
156
+ ('no-sub_no-matrix', 4): 44.44634394296659,
157
+ ('no-sub_no-matrix', 5): 3.0318996942908414,
158
+ ('sub_matrix', 1): 16.93528744674245,
159
+ ('sub_matrix', 2): 36.545024814326574,
160
+ ('sub_matrix', 3): 26.279603445823692,
161
+ ('sub_matrix', 4): 46.501226364074995,
162
+ ('sub_matrix', 5): 32.155418057793035,
163
+ ('sub_no-matrix', 1): 16.93528744674245,
164
+ ('sub_no-matrix', 2): 36.545024814326574,
165
+ ('sub_no-matrix', 3): 26.279603445823692,
166
+ ('sub_no-matrix', 4): 46.501226364074995,
167
+ ('sub_no-matrix', 5): 4.4581122618864155},
168
+ {('no-sub_matrix', 1): 15.598113737151568,
169
+ ('no-sub_matrix', 2): 56.12543415244172,
170
+ ('no-sub_matrix', 3): 29.755667770007285,
171
+ ('no-sub_matrix', 4): 51.689282097269995,
172
+ ('no-sub_matrix', 5): 45.575230324010775,
173
+ ('no-sub_no-matrix', 1): 15.598113737151568,
174
+ ('no-sub_no-matrix', 2): 56.12543415244172,
175
+ ('no-sub_no-matrix', 3): 29.755667770007285,
176
+ ('no-sub_no-matrix', 4): 51.68928424705313,
177
+ ('no-sub_no-matrix', 5): 1.235207173694806,
178
+ ('sub_matrix', 1): 18.909088991066888,
179
+ ('sub_matrix', 2): 57.753410746636746,
180
+ ('sub_matrix', 3): 28.677667873674363,
181
+ ('sub_matrix', 4): 51.99410775929489,
182
+ ('sub_matrix', 5): 35.754144966112236,
183
+ ('sub_no-matrix', 1): 18.909088991066888,
184
+ ('sub_no-matrix', 2): 57.753410746636746,
185
+ ('sub_no-matrix', 3): 28.677667873674363,
186
+ ('sub_no-matrix', 4): 51.9941480032352,
187
+ ('sub_no-matrix', 5): 5.033266273930268},
188
+ {('no-sub_matrix', 1): 14.859413855165633,
189
+ ('no-sub_matrix', 2): 34.54519231993284,
190
+ ('no-sub_matrix', 3): 24.26528519671309,
191
+ ('no-sub_matrix', 4): 35.42343514121054,
192
+ ('no-sub_matrix', 5): 55.85308623165151,
193
+ ('no-sub_no-matrix', 1): 14.859413855165633,
194
+ ('no-sub_no-matrix', 2): 34.54519231993284,
195
+ ('no-sub_no-matrix', 3): 24.26528519671309,
196
+ ('no-sub_no-matrix', 4): 35.42343514121054,
197
+ ('no-sub_no-matrix', 5): 2.3309861205259734,
198
+ ('sub_matrix', 1): 17.053809634549854,
199
+ ('sub_matrix', 2): 33.66637542056656,
200
+ ('sub_matrix', 3): 23.26181234829638,
201
+ ('sub_matrix', 4): 35.61438567264568,
202
+ ('sub_matrix', 5): 48.48551986050014,
203
+ ('sub_no-matrix', 1): 17.053809634549854,
204
+ ('sub_no-matrix', 2): 33.66637542056656,
205
+ ('sub_no-matrix', 3): 23.26181234829638,
206
+ ('sub_no-matrix', 4): 35.61438704850689,
207
+ ('sub_no-matrix', 5): 2.969309360231736},
208
+ {('no-sub_matrix', 1): 13.708973748402064,
209
+ ('no-sub_matrix', 2): 31.147590264691182,
210
+ ('no-sub_matrix', 3): 30.495597241955565,
211
+ ('no-sub_matrix', 4): 34.65164493728535,
212
+ ('no-sub_matrix', 5): 35.87510990950117,
213
+ ('no-sub_no-matrix', 1): 13.708973748402064,
214
+ ('no-sub_no-matrix', 2): 31.147590264691182,
215
+ ('no-sub_no-matrix', 3): 30.495597241955565,
216
+ ('no-sub_no-matrix', 4): 34.65164493728535,
217
+ ('no-sub_no-matrix', 5): 3.232032121481573,
218
+ ('sub_matrix', 1): 17.681722076468287,
219
+ ('sub_matrix', 2): 33.77225997922327,
220
+ ('sub_matrix', 3): 29.435808932487806,
221
+ ('sub_matrix', 4): 34.354368969668016,
222
+ ('sub_matrix', 5): 20.802733205442486,
223
+ ('sub_no-matrix', 1): 17.681722076468287,
224
+ ('sub_no-matrix', 2): 33.77225997922327,
225
+ ('sub_no-matrix', 3): 29.435808932487806,
226
+ ('sub_no-matrix', 4): 34.354368969668016,
227
+ ('sub_no-matrix', 5): 3.7902066303710424},
228
+ {('no-sub_matrix', 1): 15.72185319065555,
229
+ ('no-sub_matrix', 2): 45.25539814380218,
230
+ ('no-sub_matrix', 3): 24.94273362957689,
231
+ ('no-sub_matrix', 4): 40.81704901026569,
232
+ ('no-sub_matrix', 5): 42.898794519499596,
233
+ ('no-sub_no-matrix', 1): 15.72185319065555,
234
+ ('no-sub_no-matrix', 2): 45.25539814380218,
235
+ ('no-sub_no-matrix', 3): 24.94273362957689,
236
+ ('no-sub_no-matrix', 4): 40.81704901026569,
237
+ ('no-sub_no-matrix', 5): 2.6826901255924644,
238
+ ('sub_matrix', 1): 17.565795106862403,
239
+ ('sub_matrix', 2): 46.9371803702329,
240
+ ('sub_matrix', 3): 23.887805807796486,
241
+ ('sub_matrix', 4): 39.058599411828766,
242
+ ('sub_matrix', 5): 32.234453544910295,
243
+ ('sub_no-matrix', 1): 17.565795106862403,
244
+ ('sub_no-matrix', 2): 46.9371803702329,
245
+ ('sub_no-matrix', 3): 23.887805807796486,
246
+ ('sub_no-matrix', 4): 39.058599411828766,
247
+ ('sub_no-matrix', 5): 4.214674259243127},
248
+ {('no-sub_matrix', 1): 13.910878628792588,
249
+ ('no-sub_matrix', 2): 33.45626834359109,
250
+ ('no-sub_matrix', 3): 16.127584513594687,
251
+ ('no-sub_matrix', 4): 32.59623120264939,
252
+ ('no-sub_matrix', 5): 29.87568851789407,
253
+ ('no-sub_no-matrix', 1): 13.910878628792588,
254
+ ('no-sub_no-matrix', 2): 33.45626834359109,
255
+ ('no-sub_no-matrix', 3): 16.127584513594687,
256
+ ('no-sub_no-matrix', 4): 32.59623120264939,
257
+ ('no-sub_no-matrix', 5): 2.3891779982892625,
258
+ ('sub_matrix', 1): 17.18981661053988,
259
+ ('sub_matrix', 2): 36.38883326650068,
260
+ ('sub_matrix', 3): 13.081088737716442,
261
+ ('sub_matrix', 4): 33.419732612590224,
262
+ ('sub_matrix', 5): 22.665485632721676,
263
+ ('sub_no-matrix', 1): 17.18981661053988,
264
+ ('sub_no-matrix', 2): 36.38883326650068,
265
+ ('sub_no-matrix', 3): 13.081088737716442,
266
+ ('sub_no-matrix', 4): 33.419732612590224,
267
+ ('sub_no-matrix', 5): 6.155199912348024},
268
+ {('no-sub_matrix', 1): 18.196771699177763,
269
+ ('no-sub_matrix', 2): 35.624058750852136,
270
+ ('no-sub_matrix', 3): 23.746554392851053,
271
+ ('no-sub_matrix', 4): 29.44669921790574,
272
+ ('no-sub_matrix', 5): 39.72412918901379,
273
+ ('no-sub_no-matrix', 1): 18.196771699177763,
274
+ ('no-sub_no-matrix', 2): 35.624058750852136,
275
+ ('no-sub_no-matrix', 3): 23.746554392851053,
276
+ ('no-sub_no-matrix', 4): 29.44669921790574,
277
+ ('no-sub_no-matrix', 5): 2.870123353843486,
278
+ ('sub_matrix', 1): 20.38619930823735,
279
+ ('sub_matrix', 2): 36.29781144853154,
280
+ ('sub_matrix', 3): 22.13637404741934,
281
+ ('sub_matrix', 4): 29.68729899086184,
282
+ ('sub_matrix', 5): 36.993790238103884,
283
+ ('sub_no-matrix', 1): 20.38619930823735,
284
+ ('sub_no-matrix', 2): 36.29781144853154,
285
+ ('sub_no-matrix', 3): 22.13637404741934,
286
+ ('sub_no-matrix', 4): 29.68729899086184,
287
+ ('sub_no-matrix', 5): 7.650303570399713},
288
+ {('no-sub_matrix', 1): 11.992867568477442,
289
+ ('no-sub_matrix', 2): 26.44083030170154,
290
+ ('no-sub_matrix', 3): 27.574921221726136,
291
+ ('no-sub_matrix', 4): 28.94213565689118,
292
+ ('no-sub_matrix', 5): 46.973469397495556,
293
+ ('no-sub_no-matrix', 1): 11.992867568477442,
294
+ ('no-sub_no-matrix', 2): 26.44083030170154,
295
+ ('no-sub_no-matrix', 3): 27.574921221726136,
296
+ ('no-sub_no-matrix', 4): 28.94213565689118,
297
+ ('no-sub_no-matrix', 5): 3.354326576753004,
298
+ ('sub_matrix', 1): 14.434047100994839,
299
+ ('sub_matrix', 2): 26.76571524620116,
300
+ ('sub_matrix', 3): 25.83488399989926,
301
+ ('sub_matrix', 4): 30.263621195061678,
302
+ ('sub_matrix', 5): 36.822532494114455,
303
+ ('sub_no-matrix', 1): 14.434047100994839,
304
+ ('sub_no-matrix', 2): 26.76571524620116,
305
+ ('sub_no-matrix', 3): 25.83488399989926,
306
+ ('sub_no-matrix', 4): 30.263621195061678,
307
+ ('sub_no-matrix', 5): 6.748976893757906},
308
+ {('no-sub_matrix', 1): 16.27614914680276,
309
+ ('no-sub_matrix', 2): 41.35282905624703,
310
+ ('no-sub_matrix', 3): 25.173115913245226,
311
+ ('no-sub_matrix', 4): 52.876981987369014,
312
+ ('no-sub_matrix', 5): 49.49767321075167,
313
+ ('no-sub_no-matrix', 1): 16.27614914680276,
314
+ ('no-sub_no-matrix', 2): 41.35282905624703,
315
+ ('no-sub_no-matrix', 3): 25.173115913245226,
316
+ ('no-sub_no-matrix', 4): 52.876981987369014,
317
+ ('no-sub_no-matrix', 5): 1.5962803636236758,
318
+ ('sub_matrix', 1): 18.735912436641787,
319
+ ('sub_matrix', 2): 43.36213985849511,
320
+ ('sub_matrix', 3): 24.582800598631913,
321
+ ('sub_matrix', 4): 53.1616607417586,
322
+ ('sub_matrix', 5): 41.2664433745972,
323
+ ('sub_no-matrix', 1): 18.735912436641787,
324
+ ('sub_no-matrix', 2): 43.36213985849511,
325
+ ('sub_no-matrix', 3): 24.582800598631913,
326
+ ('sub_no-matrix', 4): 53.16165799003619,
327
+ ('sub_no-matrix', 5): 6.4917878462822305},
328
+ {('no-sub_matrix', 1): 14.036280122634507,
329
+ ('no-sub_matrix', 2): 53.72802368862095,
330
+ ('no-sub_matrix', 3): 18.940766131564004,
331
+ ('no-sub_matrix', 4): 40.74964840745327,
332
+ ('no-sub_matrix', 5): 39.57008490907742,
333
+ ('no-sub_no-matrix', 1): 14.036280122634507,
334
+ ('no-sub_no-matrix', 2): 53.72802368862095,
335
+ ('no-sub_no-matrix', 3): 18.940766131564004,
336
+ ('no-sub_no-matrix', 4): 40.74964840745327,
337
+ ('no-sub_no-matrix', 5): 2.1275557540222967,
338
+ ('sub_matrix', 1): 19.641722357026286,
339
+ ('sub_matrix', 2): 52.709120728751486,
340
+ ('sub_matrix', 3): 17.976257844509426,
341
+ ('sub_matrix', 4): 42.51851542500959,
342
+ ('sub_matrix', 5): 28.25018664655579,
343
+ ('sub_no-matrix', 1): 19.641722357026286,
344
+ ('sub_no-matrix', 2): 52.709120728751486,
345
+ ('sub_no-matrix', 3): 17.976257844509426,
346
+ ('sub_no-matrix', 4): 42.51851267328718,
347
+ ('sub_no-matrix', 5): 5.409622788119386},
348
+ {('no-sub_matrix', 1): 16.961927903326398,
349
+ ('no-sub_matrix', 2): 38.5455951142925,
350
+ ('no-sub_matrix', 3): 25.122316709729276,
351
+ ('no-sub_matrix', 4): 35.90131439006518,
352
+ ('no-sub_matrix', 5): 41.65886977570029,
353
+ ('no-sub_no-matrix', 1): 16.961927903326398,
354
+ ('no-sub_no-matrix', 2): 38.5455951142925,
355
+ ('no-sub_no-matrix', 3): 25.122316709729276,
356
+ ('no-sub_no-matrix', 4): 35.90131439006518,
357
+ ('no-sub_no-matrix', 5): 3.2679255886472447,
358
+ ('sub_matrix', 1): 20.247934372024154,
359
+ ('sub_matrix', 2): 40.408716019775625,
360
+ ('sub_matrix', 3): 23.782735071043668,
361
+ ('sub_matrix', 4): 37.00513584758997,
362
+ ('sub_matrix', 5): 29.22700479607527,
363
+ ('sub_no-matrix', 1): 20.247934372024154,
364
+ ('sub_no-matrix', 2): 40.408716019775625,
365
+ ('sub_no-matrix', 3): 23.782735071043668,
366
+ ('sub_no-matrix', 4): 37.00513584758997,
367
+ ('sub_no-matrix', 5): 4.780011845541033},
368
+ {('no-sub_matrix', 1): 12.109815771064152,
369
+ ('no-sub_matrix', 2): 38.32406752938649,
370
+ ('no-sub_matrix', 3): 25.987801084044044,
371
+ ('no-sub_matrix', 4): 40.40950903177875,
372
+ ('no-sub_matrix', 5): 52.86522525335603,
373
+ ('no-sub_no-matrix', 1): 12.109815771064152,
374
+ ('no-sub_no-matrix', 2): 38.32406752938649,
375
+ ('no-sub_no-matrix', 3): 25.987801084044044,
376
+ ('no-sub_no-matrix', 4): 40.40950903177875,
377
+ ('no-sub_no-matrix', 5): 3.61917194787979,
378
+ ('sub_matrix', 1): 15.130341564722832,
379
+ ('sub_matrix', 2): 37.89719334728088,
380
+ ('sub_matrix', 3): 24.65681032273433,
381
+ ('sub_matrix', 4): 40.731610867030774,
382
+ ('sub_matrix', 5): 37.566910985257906,
383
+ ('sub_no-matrix', 1): 15.130341564722832,
384
+ ('sub_no-matrix', 2): 37.89719334728088,
385
+ ('sub_no-matrix', 3): 24.65681032273433,
386
+ ('sub_no-matrix', 4): 40.731610867030774,
387
+ ('sub_no-matrix', 5): 9.39736249989602},
388
+ {('no-sub_matrix', 1): 16.25058564557851,
389
+ ('no-sub_matrix', 2): 37.20405682898803,
390
+ ('no-sub_matrix', 3): 30.5107090995129,
391
+ ('no-sub_matrix', 4): 44.537084655292894,
392
+ ('no-sub_matrix', 5): 46.50046620075818,
393
+ ('no-sub_no-matrix', 1): 16.25058564557851,
394
+ ('no-sub_no-matrix', 2): 37.20405682898803,
395
+ ('no-sub_no-matrix', 3): 30.5107090995129,
396
+ ('no-sub_no-matrix', 4): 44.537084655292894,
397
+ ('no-sub_no-matrix', 5): 1.8752506698658238,
398
+ ('sub_matrix', 1): 18.440281483079957,
399
+ ('sub_matrix', 2): 38.54769605435544,
400
+ ('sub_matrix', 3): 30.510800250317864,
401
+ ('sub_matrix', 4): 44.99740645329493,
402
+ ('sub_matrix', 5): 39.55738177603457,
403
+ ('sub_no-matrix', 1): 18.440281483079957,
404
+ ('sub_no-matrix', 2): 38.54769605435544,
405
+ ('sub_no-matrix', 3): 30.510800250317864,
406
+ ('sub_no-matrix', 4): 44.99740645329493,
407
+ ('sub_no-matrix', 5): 2.6233048602148386},
408
+ {('no-sub_matrix', 1): 16.324447378609865,
409
+ ('no-sub_matrix', 2): 30.87308462806543,
410
+ ('no-sub_matrix', 3): 22.765564836381643,
411
+ ('no-sub_matrix', 4): 38.337445027901204,
412
+ ('no-sub_matrix', 5): 40.98815076599078,
413
+ ('no-sub_no-matrix', 1): 16.324447378609865,
414
+ ('no-sub_no-matrix', 2): 30.87308462806543,
415
+ ('no-sub_no-matrix', 3): 22.765564836381643,
416
+ ('no-sub_no-matrix', 4): 38.337445027901204,
417
+ ('no-sub_no-matrix', 5): 1.4796406979126138,
418
+ ('sub_matrix', 1): 17.9623592385626,
419
+ ('sub_matrix', 2): 32.36568198294609,
420
+ ('sub_matrix', 3): 22.438215466486483,
421
+ ('sub_matrix', 4): 40.900713840387546,
422
+ ('sub_matrix', 5): 33.396627340011634,
423
+ ('sub_no-matrix', 1): 17.9623592385626,
424
+ ('sub_no-matrix', 2): 32.36568198294609,
425
+ ('sub_no-matrix', 3): 22.438215466486483,
426
+ ('sub_no-matrix', 4): 40.900713840387546,
427
+ ('sub_no-matrix', 5): 6.609518913895668},
428
+ {('no-sub_matrix', 1): 14.033258731424148,
429
+ ('no-sub_matrix', 2): 28.37206528002418,
430
+ ('no-sub_matrix', 3): 27.043658386061033,
431
+ ('no-sub_matrix', 4): 36.167049513436204,
432
+ ('no-sub_matrix', 5): 52.280797076864395,
433
+ ('no-sub_no-matrix', 1): 14.033258731424148,
434
+ ('no-sub_no-matrix', 2): 28.37206528002418,
435
+ ('no-sub_no-matrix', 3): 27.043658386061033,
436
+ ('no-sub_no-matrix', 4): 36.167049513436204,
437
+ ('no-sub_no-matrix', 5): 1.9358795417918389,
438
+ ('sub_matrix', 1): 16.606623097498794,
439
+ ('sub_matrix', 2): 29.98729916366884,
440
+ ('sub_matrix', 3): 24.737985875967603,
441
+ ('sub_matrix', 4): 34.93154214402433,
442
+ ('sub_matrix', 5): 42.35241303296243,
443
+ ('sub_no-matrix', 1): 16.606623097498794,
444
+ ('sub_no-matrix', 2): 29.98729916366884,
445
+ ('sub_no-matrix', 3): 24.737985875967603,
446
+ ('sub_no-matrix', 4): 34.931551775052775,
447
+ ('sub_no-matrix', 5): 7.151971456773863},
448
+ {('no-sub_matrix', 1): 10.482293039084738,
449
+ ('no-sub_matrix', 2): 52.67861788579445,
450
+ ('no-sub_matrix', 3): 21.665543335527666,
451
+ ('no-sub_matrix', 4): 23.53727708917033,
452
+ ('no-sub_matrix', 5): 32.2645584918966,
453
+ ('no-sub_no-matrix', 1): 10.482293039084738,
454
+ ('no-sub_no-matrix', 2): 52.67861788579445,
455
+ ('no-sub_no-matrix', 3): 21.665543335527666,
456
+ ('no-sub_no-matrix', 4): 23.53727708917033,
457
+ ('no-sub_no-matrix', 5): 2.5207572809328243,
458
+ ('sub_matrix', 1): 11.523882918360123,
459
+ ('sub_matrix', 2): 57.336257883871156,
460
+ ('sub_matrix', 3): 21.647716645835132,
461
+ ('sub_matrix', 4): 23.491483569694733,
462
+ ('sub_matrix', 5): 24.264706351480406,
463
+ ('sub_no-matrix', 1): 11.523882918360123,
464
+ ('sub_no-matrix', 2): 57.336257883871156,
465
+ ('sub_no-matrix', 3): 21.647716645835132,
466
+ ('sub_no-matrix', 4): 23.491462243846026,
467
+ ('sub_no-matrix', 5): 9.714244661694366},
468
+ {('no-sub_matrix', 1): 11.992867568477442,
469
+ ('no-sub_matrix', 2): 28.861638231250264,
470
+ ('no-sub_matrix', 3): 24.222607873884137,
471
+ ('no-sub_matrix', 4): 41.28280460012173,
472
+ ('no-sub_matrix', 5): 56.6084264455065,
473
+ ('no-sub_no-matrix', 1): 11.992867568477442,
474
+ ('no-sub_no-matrix', 2): 28.861638231250264,
475
+ ('no-sub_no-matrix', 3): 24.222607873884137,
476
+ ('no-sub_no-matrix', 4): 41.28280460012173,
477
+ ('no-sub_no-matrix', 5): 2.4980576348107437,
478
+ ('sub_matrix', 1): 14.531057698832324,
479
+ ('sub_matrix', 2): 31.280393934821902,
480
+ ('sub_matrix', 3): 20.756528260470358,
481
+ ('sub_matrix', 4): 42.15937712589425,
482
+ ('sub_matrix', 5): 52.45767194621365,
483
+ ('sub_no-matrix', 1): 14.531057698832324,
484
+ ('sub_no-matrix', 2): 31.280393934821902,
485
+ ('sub_no-matrix', 3): 20.756528260470358,
486
+ ('sub_no-matrix', 4): 42.15937712589425,
487
+ ('sub_no-matrix', 5): 4.819862633503057}]
488
+
489
+
490
+ def test_gpt_subordination_region_totals():
491
+ """
492
+ Check region-level surprisals against the original syntaxgym-core
493
+ implementation, using the same underlying `gpt2` model.
494
+ """
495
+ reference = ... # TODO
496
+
497
+ # TODO work out references
498
+ dataset = datasets.load_dataset("./syntaxgym.py", "subordination_src-src")
499
+ metric = datasets.load_metric("./syntaxgym.py")
500
+ result = metric.compute(suite=dataset["test"], model_id="gpt2")
501
+
502
+ from pprint import pprint
503
+ pprint(result["region_totals"][0])
504
+ pprint(GPT2_SUBORDINATION_SRC_REFERENCE[0])
505
+
506
+ keys = result["region_totals"][0].keys()
507
+ assert set(keys) == set(GPT2_SUBORDINATION_SRC_REFERENCE[0].keys())
508
+
509
+ result_ndarray = np.concatenate([np.array([region_totals[key] for key in keys])
510
+ for region_totals in result["region_totals"]])
511
+ reference_ndarray = np.concatenate([np.array([region_totals[key] for key in keys])
512
+ for region_totals in GPT2_SUBORDINATION_SRC_REFERENCE])
513
+ pprint(sorted(zip(keys, np.abs(result_ndarray - reference_ndarray)),
514
+ key=lambda x: -x[1]))
515
+ np.testing.assert_allclose(result_ndarray, reference_ndarray, atol=1e-3)