|
|
|
|
|
|
|
"""mindgames datasets""" |
|
|
|
from __future__ import absolute_import, division, print_function |
|
|
|
import json |
|
import os |
|
import textwrap |
|
import six |
|
import datasets |
|
|
|
|
|
CITATION = r""" |
|
@article{sileo2023mindgames, |
|
title={MindGames: Targeting Theory of Mind in Large Language Models with Dynamic Epistemic Modal Logic}, |
|
author={Sileo, Damien and Lernould, Antoine}, |
|
journal={arXiv preprint arXiv:2305.03353}, |
|
year={2023} |
|
} |
|
""" |
|
|
|
DESCRIPTION = """\ |
|
mindgames json tasks |
|
""" |
|
|
|
CONFIGS=['forehead','forehead_mirror','explicit','internal','all'] |
|
_URLs = {(x,y):f'https://huggingface.co/datasets/sileod/mindgames/resolve/main/data/{x}-{y}.jsonl' for x in ['train','validation','test'] for y in CONFIGS} |
|
files = ['-'.join(x) for x in _URLs] |
|
|
|
|
|
|
|
|
|
class mindgamesConfig(datasets.BuilderConfig): |
|
citation=CITATION |
|
|
|
class mindgames(datasets.GeneratorBasedBuilder): |
|
DEFAULT_CONFIG_NAME = "all" |
|
BUILDER_CONFIGS = [ |
|
mindgamesConfig( |
|
name=n, |
|
data_dir=n |
|
) for n in CONFIGS |
|
] |
|
|
|
def _split_generators(self, dl_manager: datasets.DownloadManager): |
|
data_file = dl_manager.download(_URLs) |
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_file['train',self.config.data_dir]}), |
|
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_file['validation',self.config.data_dir]}), |
|
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_file['test',self.config.data_dir]}), |
|
|
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo() |
|
def _generate_examples(self, filepath): |
|
print(filepath) |
|
"""Yields examples.""" |
|
with open(filepath, "r", encoding="utf-8") as f: |
|
for id_, line in enumerate(f): |
|
line_dict = json.loads(line) |
|
line_dict['label']=['not_entailment','entailment'][line_dict['label']] |
|
yield id_, line_dict |