|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@misc{esuli2024invalsi, |
|
title={The Invalsi Benchmark: measuring Language Models Mathematical and Language understanding in Italian}, |
|
author={Andrea Esuli and Giovanni Puccetti}, |
|
year={2024}, |
|
eprint={2403.18697}, |
|
archivePrefix={arXiv}, |
|
primaryClass={cs.CL} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
This new dataset is designed to measure Language Models mathematical and language understanding in Italian. |
|
""" |
|
|
|
_HOMEPAGE = "" |
|
|
|
_LICENSE = "CC BY 4.0" |
|
|
|
|
|
_URLS = { |
|
|
|
|
|
"mate": "./invalsi_mate_data/invalsi_mate_clean.csv", |
|
"ita": "./invalsi_ita_data/invalsi_ita_clean.csv", |
|
} |
|
|
|
|
|
class invalsi(datasets.GeneratorBasedBuilder): |
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="mate", version=VERSION, description="Mathematical Understanding"), |
|
datasets.BuilderConfig(name="ita", version=VERSION, description="Italian Understanding"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "mate" |
|
|
|
def _info(self): |
|
if self.config.name == "mate": |
|
features = datasets.Features( |
|
{ |
|
"domanda": datasets.Value("string"), |
|
"risposta": datasets.Value("string"), |
|
"immagine": datasets.Value("string"), |
|
"test_id": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "ita": |
|
features = datasets.Features( |
|
{ |
|
"testo": datasets.Value("string"), |
|
"domanda": datasets.Value("string"), |
|
"risposta": datasets.Value("string"), |
|
"immagine": datasets.Value("string"), |
|
"test_id": datasets.Value("string"), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
urls = _URLS[self.config.name] |
|
|
|
data_dir = "./" |
|
if self.config.name == "mate": |
|
data_file = "invalsi_mate_data/invalsi_mate_clean.csv" |
|
elif self.config.name == "ita": |
|
data_file = "invalsi_ita_data/invalsi_ita_clean.csv" |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir, data_file), |
|
"split": "val", |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath, split): |
|
ds = datasets.load_dataset("csv", data_files=filepath)["train"] |
|
for key, row in enumerate(ds): |
|
|
|
if self.config.name == "mate": |
|
|
|
out = { |
|
|
|
|
|
|
|
|
|
"domanda": row["domanda"], |
|
"risposta": row["risposta"], |
|
|
|
"test_id": row["test_id"], |
|
} |
|
if "image_file_names" in row: |
|
out["immagine"] = row["image_file_names"] |
|
|
|
yield key, out |
|
elif self.config.name == "ita": |
|
yield key, { |
|
|
|
|
|
|
|
|
|
|
|
"testo": row["testo"], |
|
"domanda": row["domanda"], |
|
"risposta": row["risposta"], |
|
"immagine": row["image_file_names"], |
|
"test_id": row["test_id"], |
|
} |
|
|