maximedb commited on
Commit
2bf0a42
·
1 Parent(s): 30b5a6e

add json files

Browse files
.gitattributes CHANGED
@@ -26,3 +26,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
  train.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
  train.json filter=lfs diff=lfs merge=lfs -text
29
+ data/test_random_split.json filter=lfs diff=lfs merge=lfs -text
30
+ data/test_topic_split.json filter=lfs diff=lfs merge=lfs -text
31
+ data/train.json filter=lfs diff=lfs merge=lfs -text
32
+ data/valid_random_split.json filter=lfs diff=lfs merge=lfs -text
33
+ data/valid_topic_split.json filter=lfs diff=lfs merge=lfs -text
data/test_random_split.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c06598ad489f7d28776138f3e6a784be9ab541424ab861495e30f0c4fc9d593
3
+ size 132231958
data/test_topic_split.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b80cb980c339b1480d6ceb8af0749a8bc7c0661eecbf1e2676ddf2ba6ab5341
3
+ size 131659028
data/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2167678c63b044fa2cdd8dcac833cb2f7a68a1eb2cb33b16af89becb71e53ea3
3
+ size 993493566
data/valid_random_split.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d8626482fc4914946a89675d128b7839d9aada14bbc1d277bd3c69ad1f591ff
3
+ size 135744699
data/valid_topic_split.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d46c5d50b817fceeae394b201540bcf62a24eccd0ca322a96ccb2d3845f526d
3
+ size 133570056
wow.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import datasets
4
+
5
+
6
+ _DESCRIPTION = """In open-domain dialogue intelligent agents should exhibit the use of knowledge, however there are few convincing demonstrations of this to date. The most popular sequence to sequence models typically "generate and hope" generic utterances that can be memorized in the weights of the model when mapping from input utterance(s) to output, rather than employing recalled knowledge as context. Use of knowledge has so far proved difficult, in part because of the lack of a supervised learning benchmark task which exhibits knowledgeable open dialogue with clear grounding. To that end we collect and release a large dataset with conversations directly grounded with knowledge retrieved from Wikipedia. We then design architectures capable of retrieving knowledge, reading and conditioning on it, and finally generating natural responses. Our best performing dialogue models are able to conduct knowledgeable discussions on open-domain topics as evaluated by automatic metrics and human evaluations, while our new benchmark allows for measuring further improvements in this important research direction."""
7
+ _HOMEPAGE = "https://arxiv.org/abs/1811.01241"
8
+ _CITATION = """@article{dinan2018wizard,
9
+ title={Wizard of wikipedia: Knowledge-powered conversational agents},
10
+ author={Dinan, Emily and Roller, Stephen and Shuster, Kurt and Fan, Angela and Auli, Michael and Weston, Jason},
11
+ journal={arXiv preprint arXiv:1811.01241},
12
+ year={2018}
13
+ }"""
14
+
15
+
16
+ class WOWConfig(datasets.BuilderConfig):
17
+ def __init__(self, *args, split="random", **kwargs):
18
+ assert split in ["random", "topic"]
19
+ super().__init__(
20
+ *args,
21
+ name=f"{split}",
22
+ **kwargs,
23
+ )
24
+ self.split = split
25
+
26
+
27
+ class WOW(datasets.GeneratorBasedBuilder):
28
+
29
+ BUILDER_CONFIGS = [WOWConfig(split="random"), WOWConfig(split="topic")]
30
+ BUILDER_CONFIG_CLASS = WOWConfig
31
+
32
+ def _info(self):
33
+ features = {
34
+ "chosen_topic": datasets.Value("string"),
35
+ "persona": datasets.Value("string"),
36
+ "wizard_eval": datasets.Value("int32"),
37
+ "dialog": [{
38
+ "speaker": datasets.Value("string"),
39
+ "text": datasets.Value("string"),
40
+ "checked_sentence_value": datasets.Value("string"),
41
+ "checked_sentence_key": datasets.Value("string"),
42
+ "checked_passage_value": datasets.Value("string"),
43
+ "checked_passage_key": datasets.Value("string"),
44
+ "retrieved_passages": [{
45
+ "key": datasets.Value("string"),
46
+ "values": [datasets.Value("string")]
47
+ }],
48
+ "retrieved_topics": [datasets.Value("string")]
49
+ }]
50
+ }
51
+ return datasets.DatasetInfo(
52
+ description=_DESCRIPTION,
53
+ features=datasets.Features(features),
54
+ supervised_keys=None,
55
+ homepage=_HOMEPAGE,
56
+ citation=_CITATION,
57
+ )
58
+
59
+ def _split_generators(self, dl_manager):
60
+ return [
61
+ datasets.SplitGenerator(
62
+ name=datasets.Split.TRAIN,
63
+ gen_kwargs={"filename": "data/train.json"},
64
+ ),
65
+ datasets.SplitGenerator(
66
+ name=datasets.Split.VALIDATION,
67
+ gen_kwargs={"filename": f"data/valid_{self.config.split}_split.json"},
68
+ ),
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.TEST,
71
+ gen_kwargs={"filename": f"data/test_{self.config.split}_split.json"},
72
+ )
73
+ ]
74
+
75
+ def _generate_examples(self, filename):
76
+ with open(filename) as f:
77
+ for i, line in enumerate(f):
78
+ line = json.loads(line)
79
+ history = []
80
+ for j, turn in enumerate(line["dialog"]):
81
+ retrieved_passages = []
82
+ for passage in turn["retrieved_passages"]:
83
+ key = list(passage.keys())[0]
84
+ values = list(passage.values())[0]
85
+ retrieved_passages.append({
86
+ "key": key,
87
+ "values": values
88
+ })
89
+ if turn["speaker"] == "0_Wizard":
90
+ checked_sentence = list(turn.get("checked_sentence", {}).items())
91
+ checked_passage = list(turn.get("checked_passage", {}).items())
92
+ history.append({
93
+ "speaker": turn["speaker"],
94
+ "text": turn["text"],
95
+ "checked_sentence_key": "" if len(checked_sentence) == 0 else checked_sentence[0][0],
96
+ "checked_sentence_value": "" if len(checked_sentence) == 0 else checked_sentence[0][1],
97
+ "checked_passage_key": "" if len(checked_passage) == 0 else checked_passage[0][0],
98
+ "checked_passage_value": "" if len(checked_passage) == 0 else checked_passage[0][1],
99
+ "retrieved_passages": retrieved_passages,
100
+ "retrieved_topics": line["retrieved_topics"] if "retrieved_topics" in line else []
101
+ })
102
+ else:
103
+ history.append({
104
+ "speaker": turn["speaker"],
105
+ "text": turn["text"],
106
+ "checked_sentence_key": "",
107
+ "checked_sentence_value": "",
108
+ "checked_passage_key": "",
109
+ "checked_passage_value": "",
110
+ "retrieved_passages": [],
111
+ "retrieved_topics": []
112
+ })
113
+ yield f"{i}_{j}", {
114
+ "chosen_topic": line["chosen_topic"],
115
+ "persona": line["persona"],
116
+ "wizard_eval": line["wizard_eval"],
117
+ "dialog": history
118
+ }
119
+