Datasets:
Create mindgames.py
Browse files- mindgames.py +117 -0
mindgames.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
|
3 |
+
# Lint as: python3
|
4 |
+
"""mindgames datasets"""
|
5 |
+
|
6 |
+
from __future__ import absolute_import, division, print_function
|
7 |
+
|
8 |
+
import json
|
9 |
+
import os
|
10 |
+
import textwrap
|
11 |
+
import six
|
12 |
+
import datasets
|
13 |
+
|
14 |
+
|
15 |
+
CITATION = r"""
|
16 |
+
@article{sileo2023mindgames,
|
17 |
+
title={MindGames: Targeting Theory of Mind in Large Language Models with Dynamic Epistemic Modal Logic},
|
18 |
+
author={Sileo, Damien and Lernould, Antoine},
|
19 |
+
journal={arXiv preprint arXiv:2305.03353},
|
20 |
+
year={2023}
|
21 |
+
}
|
22 |
+
"""
|
23 |
+
|
24 |
+
DESCRIPTION = """\
|
25 |
+
mindgames json tasks
|
26 |
+
"""
|
27 |
+
|
28 |
+
DATA_URL = "https://www.dropbox.com/s/yamo3jsgzdhkim8/mindgames.zip?dl=1"
|
29 |
+
|
30 |
+
CONFIGS=['internal','forehead','forehead-mirror','explicit']
|
31 |
+
|
32 |
+
class mindgames_Config(datasets.BuilderConfig):
|
33 |
+
"""BuilderConfig for mindgames."""
|
34 |
+
|
35 |
+
def __init__(
|
36 |
+
self,
|
37 |
+
text_features,
|
38 |
+
label_classes=None,
|
39 |
+
**kwargs,
|
40 |
+
):
|
41 |
+
"""BuilderConfig for mindgames.
|
42 |
+
Args:
|
43 |
+
text_features: `dict[string, string]`, map from the name of the feature
|
44 |
+
dict for each text field to the name of the column in the tsv file
|
45 |
+
data_url: `string`, url to download the zip file from
|
46 |
+
data_dir: `string`, the path to the folder containing the tsv files in the
|
47 |
+
downloaded zip
|
48 |
+
citation: `string`, citation for the data set
|
49 |
+
url: `string`, url for information about the data set
|
50 |
+
"""
|
51 |
+
|
52 |
+
super(mindgames_Config, self).__init__(
|
53 |
+
version=datasets.Version("1.0.0", ""), **kwargs
|
54 |
+
)
|
55 |
+
|
56 |
+
self.text_features = text_features
|
57 |
+
self.data_url = DATA_URL
|
58 |
+
self.data_dir = self.name#os.path.join("", self.name)
|
59 |
+
self.citation = textwrap.dedent(CITATION)
|
60 |
+
self.description = ""
|
61 |
+
|
62 |
+
|
63 |
+
class mindgames(datasets.GeneratorBasedBuilder):
|
64 |
+
|
65 |
+
"""The General Language Understanding Evaluation (mindgames) benchmark."""
|
66 |
+
|
67 |
+
BUILDER_CONFIG_CLASS = mindgames_Config
|
68 |
+
|
69 |
+
BUILDER_CONFIGS = [
|
70 |
+
mindgames_Config(
|
71 |
+
name=name,
|
72 |
+
text_features={"inputs": "inputs"},
|
73 |
+
) for name in CONFIGS
|
74 |
+
]
|
75 |
+
|
76 |
+
def _info(self):
|
77 |
+
|
78 |
+
#features["idx"] = datasets.Value("int32")
|
79 |
+
return datasets.DatasetInfo(
|
80 |
+
description=DESCRIPTION,
|
81 |
+
#features=datasets.Features(features),
|
82 |
+
citation=self.config.citation + "\n" + CITATION,
|
83 |
+
)
|
84 |
+
|
85 |
+
def _split_generators(self, dl_manager):
|
86 |
+
data_dir = dl_manager.download_and_extract(self.config.data_url)
|
87 |
+
|
88 |
+
return [
|
89 |
+
datasets.SplitGenerator(
|
90 |
+
name=datasets.Split.TRAIN,
|
91 |
+
gen_kwargs={
|
92 |
+
"data_file": f"{data_dir}/train-{self.config.name}.jsonl",
|
93 |
+
"split": "train",
|
94 |
+
},
|
95 |
+
),
|
96 |
+
datasets.SplitGenerator(
|
97 |
+
name=datasets.Split.VALIDATION,
|
98 |
+
gen_kwargs={
|
99 |
+
"data_file": f"{data_dir}/validation-{self.config.name}.jsonl",
|
100 |
+
"split": "test",
|
101 |
+
},
|
102 |
+
),
|
103 |
+
datasets.SplitGenerator(
|
104 |
+
name=datasets.Split.TEST,
|
105 |
+
gen_kwargs={
|
106 |
+
"data_file": f"{data_dir}/test-{self.config.name}.jsonl",
|
107 |
+
"split": "validation",
|
108 |
+
},
|
109 |
+
),
|
110 |
+
]
|
111 |
+
|
112 |
+
def _generate_examples(self, data_file,split):
|
113 |
+
"""Yields examples."""
|
114 |
+
with open(data_file, "r", encoding="utf-8") as f:
|
115 |
+
for id_, line in enumerate(f):
|
116 |
+
line_dict = json.loads(line)
|
117 |
+
yield id_, line_dict
|