Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
dialogue-modeling
Languages:
English
Size:
10K - 100K
ArXiv:
License:
nouhadziri
commited on
Commit
•
fcee47c
1
Parent(s):
6271874
First version of FaithDial
Browse files
FaithDial.py
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor (Nouha Dziri).
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
"""FaithDial: A Faithful Benchmark for Information-Seeking Dialogue"""
|
15 |
+
|
16 |
+
|
17 |
+
import json
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
23 |
+
_CITATION = """\
|
24 |
+
@article{dziri2022faithdial,
|
25 |
+
title={FaithDial: A Faithful Benchmark for Information-Seeking Dialogue},
|
26 |
+
author={Dziri, Nouha and Kamalloo, Ehsan and Milton, Sivan and Zaiane, Osmar and Yu, Mo and Ponti, Edoardo and Reddy, Siva},
|
27 |
+
journal={arXiv preprint, arXiv:2204.xxxxx},
|
28 |
+
year={2022},
|
29 |
+
url={https://arxiv.org/abs/2204.xxxxx}
|
30 |
+
}
|
31 |
+
"""
|
32 |
+
|
33 |
+
# TODO: Add description of the dataset here
|
34 |
+
# You can copy an official description
|
35 |
+
_DESCRIPTION = """\
|
36 |
+
FaithDial is a new benchmark for hallucination-free dialogues, created by manually editing hallucinated and uncooperative responses in Wizard of Wikipedia.
|
37 |
+
"""
|
38 |
+
|
39 |
+
_HOMEPAGE = "https://mcgill-nlp.github.io/FaithDial/"
|
40 |
+
|
41 |
+
_LICENSE = "MIT"
|
42 |
+
|
43 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
44 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
45 |
+
_URLS = {
|
46 |
+
"train": "data/train.json",
|
47 |
+
"valid": "data/valid.json",
|
48 |
+
"valid_random_split": "data/valid_random_split.json",
|
49 |
+
"valid_topic_split": "data/valid_topic_split.json",
|
50 |
+
"test": "data/test.json",
|
51 |
+
"test_random_split": "data/test_random_split.json",
|
52 |
+
"test_topic_split": "data/test_topic_split.json",
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
class FaithDialDataset(datasets.GeneratorBasedBuilder):
|
57 |
+
"""FaithDial is a new benchmark for hallucination-free dialogues."""
|
58 |
+
|
59 |
+
VERSION = datasets.Version("1.0.0")
|
60 |
+
|
61 |
+
# This is an example of a dataset with multiple configurations.
|
62 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
63 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
64 |
+
|
65 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
66 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
67 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
68 |
+
|
69 |
+
# You will be able to load one or the other configurations in the following list with
|
70 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
71 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
72 |
+
BUILDER_CONFIGS = [
|
73 |
+
datasets.BuilderConfig(name="plain_text", version=VERSION, description="Plain text"),
|
74 |
+
]
|
75 |
+
|
76 |
+
DEFAULT_CONFIG_NAME = (
|
77 |
+
"plain_text" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
78 |
+
)
|
79 |
+
|
80 |
+
def _info(self):
|
81 |
+
features = datasets.Features(
|
82 |
+
{
|
83 |
+
"dialog_idx": datasets.Value("int32"),
|
84 |
+
"response": datasets.Value("string"),
|
85 |
+
"original_response": datasets.Value("string"),
|
86 |
+
"history": datasets.features.Sequence(datasets.Value("string")),
|
87 |
+
"knowledge": datasets.Value("string"),
|
88 |
+
"BEGIN": datasets.features.Sequence(datasets.Value("string")),
|
89 |
+
"VRM": datasets.features.Sequence(datasets.Value("string")),
|
90 |
+
}
|
91 |
+
)
|
92 |
+
|
93 |
+
return datasets.DatasetInfo(
|
94 |
+
# This is the description that will appear on the datasets page.
|
95 |
+
description=_DESCRIPTION,
|
96 |
+
# This defines the different columns of the dataset and their types
|
97 |
+
features=features, # Here we define them above because they are different between the two configurations
|
98 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
99 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
100 |
+
# supervised_keys=("sentence", "label"),
|
101 |
+
# Homepage of the dataset for documentation
|
102 |
+
homepage=_HOMEPAGE,
|
103 |
+
# License for the dataset if available
|
104 |
+
license=_LICENSE,
|
105 |
+
# Citation for the dataset
|
106 |
+
citation=_CITATION,
|
107 |
+
)
|
108 |
+
|
109 |
+
def _split_generators(self, dl_manager):
|
110 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
111 |
+
|
112 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
113 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
114 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
115 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
116 |
+
|
117 |
+
split_dict = {
|
118 |
+
"train": datasets.Split.TRAIN,
|
119 |
+
"valid": datasets.Split.VALIDATION,
|
120 |
+
"test": datasets.Split.TEST,
|
121 |
+
}
|
122 |
+
|
123 |
+
return [
|
124 |
+
datasets.SplitGenerator(
|
125 |
+
name=split_dict.get(split, split),
|
126 |
+
# These kwargs will be passed to _generate_examples
|
127 |
+
gen_kwargs={
|
128 |
+
"filepath": downloaded_file,
|
129 |
+
"split": split,
|
130 |
+
},
|
131 |
+
)
|
132 |
+
for split, downloaded_file in sorted(downloaded_files.items(), key=lambda x: x[0])
|
133 |
+
]
|
134 |
+
|
135 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
136 |
+
def _generate_examples(self, filepath, split):
|
137 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
138 |
+
with open(filepath, encoding="utf-8") as f:
|
139 |
+
data = json.load(f)
|
140 |
+
key = 0
|
141 |
+
for dialogue in data:
|
142 |
+
for utterance in dialogue["utterances"]:
|
143 |
+
yield key, {
|
144 |
+
"dialog_idx": dialogue["dialog_idx"],
|
145 |
+
"response": utterance["response"],
|
146 |
+
"original_response": utterance["original_response"],
|
147 |
+
"history": utterance["history"],
|
148 |
+
"knowledge": utterance["knowledge"],
|
149 |
+
"BEGIN": utterance["BEGIN"],
|
150 |
+
"VRM": utterance["VRM"],
|
151 |
+
}
|
152 |
+
key += 1
|
data/dummy/plain_text/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7d44546ee0397c1634eadfc40f347c0f24d5c5950570cb349b4bf234214ec56a
|
3 |
+
size 28210
|
data/dummy/plain_text/1.0.0/dummy_data.zip.lock
ADDED
File without changes
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"plain_text": {"description": "FaithDial is a new benchmark for hallucination-free dialogues, created by manually editing hallucinated and uncooperative responses in Wizard of Wikipedia.\n", "citation": "@article{dziri2022faithdial,\n title={FaithDial: A Faithful Benchmark for Information-Seeking Dialogue},\n author={Dziri, Nouha and Kamalloo, Ehsan and Milton, Sivan and Zaiane, Osmar and Yu, Mo and Ponti, Edoardo and Reddy, Siva},\n journal={arXiv preprint, arXiv:2204.xxxxx},\n year={2022},\n url={https://arxiv.org/abs/2204.xxxxx}\n}\n", "homepage": "https://mcgill-nlp.github.io/FaithDial/", "license": "MIT", "features": {"dialog_idx": {"dtype": "int32", "id": null, "_type": "Value"}, "response": {"dtype": "string", "id": null, "_type": "Value"}, "original_response": {"dtype": "string", "id": null, "_type": "Value"}, "history": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "knowledge": {"dtype": "string", "id": null, "_type": "Value"}, "BEGIN": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "VRM": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "faith_dial_dataset", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 2770907, "num_examples": 3539, "dataset_name": "faith_dial_dataset"}, "test_random_split": {"name": "test_random_split", "num_bytes": 1356913, "num_examples": 1716, "dataset_name": "faith_dial_dataset"}, "test_topic_split": {"name": "test_topic_split", "num_bytes": 1416547, "num_examples": 1823, "dataset_name": "faith_dial_dataset"}, "train": {"name": "train", "num_bytes": 14393919, "num_examples": 18357, "dataset_name": "faith_dial_dataset"}, "validation": {"name": "validation", "num_bytes": 2703363, "num_examples": 3417, "dataset_name": "faith_dial_dataset"}, "valid_random_split": {"name": "valid_random_split", "num_bytes": 1346226, "num_examples": 1666, "dataset_name": "faith_dial_dataset"}, "valid_topic_split": {"name": "valid_topic_split", "num_bytes": 1358013, "num_examples": 1751, "dataset_name": "faith_dial_dataset"}}, "download_checksums": {"data/train.json": {"num_bytes": 19499858, "checksum": "51eff8212d804b1954b7eefa8987265750f0412b0b18b534ed2dbe636e524512"}, "data/valid.json": {"num_bytes": 3650206, "checksum": "0f4da554dc07a2f5a14b96d6997f6e21358c6e7c159161526fc55a7f39751d5f"}, "data/valid_random_split.json": {"num_bytes": 1808271, "checksum": "1ca3a70c71fc212f399679b8090d8edad733c2c7d2672a2f1960bec466de596f"}, "data/valid_topic_split.json": {"num_bytes": 1842813, "checksum": "e3b161e6bd1a83bb8cabe0ff07530649473f485cd61c76048bf12cfa5ebbb751"}, "data/test.json": {"num_bytes": 3749121, "checksum": "acae13df566cdb2bf28274465a9b314dd0f66211fb9d40781c3c6922df33f674"}, "data/test_random_split.json": {"num_bytes": 1831274, "checksum": "6b8779a7442e5c60378b4a6ac7ce0681fc0923dc8a3189ec804abd9cad8b916b"}, "data/test_topic_split.json": {"num_bytes": 1920402, "checksum": "ee966f854b52688810209b2d93afba223151fa3f6d8e2df311cd88ac86ff5f4d"}}, "download_size": 34301945, "post_processing_size": null, "dataset_size": 25345888, "size_in_bytes": 59647833}}
|