Steven Basart
commited on
Commit
β’
34a0a57
1
Parent(s):
d7416fa
Adding DNLI
Browse files- .gitattributes +5 -0
- dialogue_nli.py +118 -0
- {dnli β dialogue_nli}/dialogue_nli/README.txt +0 -0
- {dnli β dialogue_nli}/dialogue_nli/dialogue_nli_dev.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli/dialogue_nli_test.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli/dialogue_nli_train.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli/dialogue_nli_verified_test.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli/print_dtypes.py +0 -0
- {dnli β dialogue_nli}/dialogue_nli_extra/README.txt +0 -0
- {dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_dev.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_test.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_train.jsonl +0 -0
- {dnli β dialogue_nli}/dialogue_nli_extra/schema.json +0 -0
- dnli.zip +3 -0
.gitattributes
CHANGED
@@ -57,3 +57,8 @@ dnli/dialogue_nli/dialogue_nli_train.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
57 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_dev.jsonl filter=lfs diff=lfs merge=lfs -text
|
58 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_test.jsonl filter=lfs diff=lfs merge=lfs -text
|
59 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_train.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
57 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_dev.jsonl filter=lfs diff=lfs merge=lfs -text
|
58 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_test.jsonl filter=lfs diff=lfs merge=lfs -text
|
59 |
dnli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_train.jsonl filter=lfs diff=lfs merge=lfs -text
|
60 |
+
dnli.zip filter=lfs diff=lfs merge=lfs -text
|
61 |
+
dialogue_nli/dialogue_nli/dialogue_nli_train.jsonl filter=lfs diff=lfs merge=lfs -text
|
62 |
+
dialogue_nli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_dev.jsonl filter=lfs diff=lfs merge=lfs -text
|
63 |
+
dialogue_nli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_test.jsonl filter=lfs diff=lfs merge=lfs -text
|
64 |
+
dialogue_nli/dialogue_nli_extra/dialogue_nli_EXTRA_uu_train.jsonl filter=lfs diff=lfs merge=lfs -text
|
dialogue_nli.py
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import json
|
3 |
+
import logging as logger
|
4 |
+
import os
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
|
9 |
+
_CITATION = """\
|
10 |
+
@misc{welleck2019dialogue,
|
11 |
+
title={Dialogue Natural Language Inference},
|
12 |
+
author={Sean Welleck and Jason Weston and Arthur Szlam and Kyunghyun Cho},
|
13 |
+
year={2019},
|
14 |
+
eprint={1811.00671},
|
15 |
+
archivePrefix={arXiv},
|
16 |
+
primaryClass={cs.CL}
|
17 |
+
}
|
18 |
+
"""
|
19 |
+
|
20 |
+
_DESCRIPTION = """\
|
21 |
+
Dialogue NLI is a dataset that addresses the issue of consistency in dialogue models.
|
22 |
+
"""
|
23 |
+
|
24 |
+
_URL = "dnli.zip"
|
25 |
+
|
26 |
+
_HOMEPAGE = "https://wellecks.github.io/dialogue_nli/"
|
27 |
+
|
28 |
+
_LICENSE = "MIT"
|
29 |
+
|
30 |
+
class Dialogue_NLI(datasets.GeneratorBasedBuilder):
|
31 |
+
"""DNLI"""
|
32 |
+
|
33 |
+
VERSION = datasets.Version("1.0.0")
|
34 |
+
|
35 |
+
BUILDER_CONFIGS = [
|
36 |
+
datasets.BuilderConfig(name="dialogue_nli", version=VERSION, description="dnli"),
|
37 |
+
]
|
38 |
+
|
39 |
+
DEFAULT_CONFIG_NAME = "dialogue_nli" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
40 |
+
|
41 |
+
def _info(self):
|
42 |
+
return datasets.DatasetInfo(
|
43 |
+
description=_DESCRIPTION,
|
44 |
+
features=datasets.Features(
|
45 |
+
{
|
46 |
+
"id": datasets.Value("string"),
|
47 |
+
"label": datasets.Value("string"),
|
48 |
+
"premise": datasets.Value("string"),
|
49 |
+
"hypothesis": datasets.Value("string"),
|
50 |
+
# "triple1": datasets.Value("string"),
|
51 |
+
# "triple2": datasets.Value("string"),
|
52 |
+
"dtype": datasets.Value("string"),
|
53 |
+
}
|
54 |
+
),
|
55 |
+
# No default supervised_keys (as we have to pass both question
|
56 |
+
# and context as input).
|
57 |
+
supervised_keys=None,
|
58 |
+
homepage=_HOMEPAGE,
|
59 |
+
citation=_CITATION,
|
60 |
+
)
|
61 |
+
|
62 |
+
def _split_generators(self, dl_manager):
|
63 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
64 |
+
|
65 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
66 |
+
# 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.
|
67 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
68 |
+
data_dir = dl_manager.download_and_extract(_URL)
|
69 |
+
return [
|
70 |
+
datasets.SplitGenerator(
|
71 |
+
name=datasets.Split.TRAIN,
|
72 |
+
# These kwargs will be passed to _generate_examples
|
73 |
+
gen_kwargs={
|
74 |
+
"filepath": os.path.join(data_dir, "dnli/dialogue_nli/dialogue_nli_train.jsonl"),
|
75 |
+
"split": "train",
|
76 |
+
},
|
77 |
+
),
|
78 |
+
datasets.SplitGenerator(
|
79 |
+
name=datasets.Split.VALIDATION,
|
80 |
+
# These kwargs will be passed to _generate_examples
|
81 |
+
gen_kwargs={
|
82 |
+
"filepath": os.path.join(data_dir, "dnli/dialogue_nli/dialogue_nli_dev.jsonl"),
|
83 |
+
"split": "dev",
|
84 |
+
},
|
85 |
+
),
|
86 |
+
datasets.SplitGenerator(
|
87 |
+
name=datasets.Split.TEST,
|
88 |
+
# These kwargs will be passed to _generate_examples
|
89 |
+
gen_kwargs={
|
90 |
+
"filepath": os.path.join(data_dir, "dnli/dialogue_nli/dialogue_nli_test.jsonl"),
|
91 |
+
"split": "test"
|
92 |
+
},
|
93 |
+
),
|
94 |
+
]
|
95 |
+
|
96 |
+
def _generate_examples(self, filepath, split):
|
97 |
+
"""This function returns the examples in the raw (text) form."""
|
98 |
+
logger.info("generating examples from = %s", filepath)
|
99 |
+
with open(filepath) as f:
|
100 |
+
data = json.load(f)
|
101 |
+
# print(data)
|
102 |
+
for example in data:
|
103 |
+
label = example.get("label", "").strip()
|
104 |
+
id_ = example.get("id", "").strip()
|
105 |
+
hypothesis = example.get("sentence1", "").strip()
|
106 |
+
premise = example.get("sentence2", "").strip()
|
107 |
+
dtype = example.get("dtype", "").strip()
|
108 |
+
|
109 |
+
# Features currently used are "context", "question", and "answers".
|
110 |
+
# Others are extracted here for the ease of future expansions.
|
111 |
+
yield id_, {
|
112 |
+
"premise": premise,
|
113 |
+
"hypothesis": hypothesis,
|
114 |
+
"id": id_,
|
115 |
+
"label": label,
|
116 |
+
"dtype": dtype,
|
117 |
+
}
|
118 |
+
|
{dnli β dialogue_nli}/dialogue_nli/README.txt
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli/dialogue_nli_dev.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli/dialogue_nli_test.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli/dialogue_nli_train.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli/dialogue_nli_verified_test.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli/print_dtypes.py
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli_extra/README.txt
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_dev.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_test.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli_extra/dialogue_nli_EXTRA_uu_train.jsonl
RENAMED
File without changes
|
{dnli β dialogue_nli}/dialogue_nli_extra/schema.json
RENAMED
File without changes
|
dnli.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1164b0d9a0a1a6006891a6d4435a6a813464bc9b1e2f1ec5ce28c47267ad5e42
|
3 |
+
size 389584058
|