asuglia commited on
Commit
9ea5b68
0 Parent(s):

First dialog-babi version

Browse files
Files changed (5) hide show
  1. .gitignore +2 -0
  2. LICENSE.txt +325 -0
  3. README.md +36 -0
  4. dataset_infos.json +1 -0
  5. dialog_babi.py +159 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv/
2
+ .python-version
LICENSE.txt ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CC License
2
+
3
+ Dialog bAbI tasks data
4
+
5
+ Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
6
+
7
+ Creative Commons Legal Code
8
+
9
+ Attribution 3.0 Unported
10
+
11
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
12
+ LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
13
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
14
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
15
+ REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
16
+ DAMAGES RESULTING FROM ITS USE.
17
+
18
+ License
19
+
20
+ THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
21
+ COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
22
+ COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
23
+ AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
24
+
25
+ BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
26
+ TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
27
+ BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
28
+ CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
29
+ CONDITIONS.
30
+
31
+ 1. Definitions
32
+
33
+ a. "Adaptation" means a work based upon the Work, or upon the Work and
34
+ other pre-existing works, such as a translation, adaptation,
35
+ derivative work, arrangement of music or other alterations of a
36
+ literary or artistic work, or phonogram or performance and includes
37
+ cinematographic adaptations or any other form in which the Work may be
38
+ recast, transformed, or adapted including in any form recognizably
39
+ derived from the original, except that a work that constitutes a
40
+ Collection will not be considered an Adaptation for the purpose of
41
+ this License. For the avoidance of doubt, where the Work is a musical
42
+ work, performance or phonogram, the synchronization of the Work in
43
+ timed-relation with a moving image ("synching") will be considered an
44
+ Adaptation for the purpose of this License.
45
+ b. "Collection" means a collection of literary or artistic works, such as
46
+ encyclopedias and anthologies, or performances, phonograms or
47
+ broadcasts, or other works or subject matter other than works listed
48
+ in Section 1(f) below, which, by reason of the selection and
49
+ arrangement of their contents, constitute intellectual creations, in
50
+ which the Work is included in its entirety in unmodified form along
51
+ with one or more other contributions, each constituting separate and
52
+ independent works in themselves, which together are assembled into a
53
+ collective whole. A work that constitutes a Collection will not be
54
+ considered an Adaptation (as defined above) for the purposes of this
55
+ License.
56
+ c. "Distribute" means to make available to the public the original and
57
+ copies of the Work or Adaptation, as appropriate, through sale or
58
+ other transfer of ownership.
59
+ d. "Licensor" means the individual, individuals, entity or entities that
60
+ offer(s) the Work under the terms of this License.
61
+ e. "Original Author" means, in the case of a literary or artistic work,
62
+ the individual, individuals, entity or entities who created the Work
63
+ or if no individual or entity can be identified, the publisher; and in
64
+ addition (i) in the case of a performance the actors, singers,
65
+ musicians, dancers, and other persons who act, sing, deliver, declaim,
66
+ play in, interpret or otherwise perform literary or artistic works or
67
+ expressions of folklore; (ii) in the case of a phonogram the producer
68
+ being the person or legal entity who first fixes the sounds of a
69
+ performance or other sounds; and, (iii) in the case of broadcasts, the
70
+ organization that transmits the broadcast.
71
+ f. "Work" means the literary and/or artistic work offered under the terms
72
+ of this License including without limitation any production in the
73
+ literary, scientific and artistic domain, whatever may be the mode or
74
+ form of its expression including digital form, such as a book,
75
+ pamphlet and other writing; a lecture, address, sermon or other work
76
+ of the same nature; a dramatic or dramatico-musical work; a
77
+ choreographic work or entertainment in dumb show; a musical
78
+ composition with or without words; a cinematographic work to which are
79
+ assimilated works expressed by a process analogous to cinematography;
80
+ a work of drawing, painting, architecture, sculpture, engraving or
81
+ lithography; a photographic work to which are assimilated works
82
+ expressed by a process analogous to photography; a work of applied
83
+ art; an illustration, map, plan, sketch or three-dimensional work
84
+ relative to geography, topography, architecture or science; a
85
+ performance; a broadcast; a phonogram; a compilation of data to the
86
+ extent it is protected as a copyrightable work; or a work performed by
87
+ a variety or circus performer to the extent it is not otherwise
88
+ considered a literary or artistic work.
89
+ g. "You" means an individual or entity exercising rights under this
90
+ License who has not previously violated the terms of this License with
91
+ respect to the Work, or who has received express permission from the
92
+ Licensor to exercise rights under this License despite a previous
93
+ violation.
94
+ h. "Publicly Perform" means to perform public recitations of the Work and
95
+ to communicate to the public those public recitations, by any means or
96
+ process, including by wire or wireless means or public digital
97
+ performances; to make available to the public Works in such a way that
98
+ members of the public may access these Works from a place and at a
99
+ place individually chosen by them; to perform the Work to the public
100
+ by any means or process and the communication to the public of the
101
+ performances of the Work, including by public digital performance; to
102
+ broadcast and rebroadcast the Work by any means including signs,
103
+ sounds or images.
104
+ i. "Reproduce" means to make copies of the Work by any means including
105
+ without limitation by sound or visual recordings and the right of
106
+ fixation and reproducing fixations of the Work, including storage of a
107
+ protected performance or phonogram in digital form or other electronic
108
+ medium.
109
+
110
+ 2. Fair Dealing Rights. Nothing in this License is intended to reduce,
111
+ limit, or restrict any uses free from copyright or rights arising from
112
+ limitations or exceptions that are provided for in connection with the
113
+ copyright protection under copyright law or other applicable laws.
114
+
115
+ 3. License Grant. Subject to the terms and conditions of this License,
116
+ Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
117
+ perpetual (for the duration of the applicable copyright) license to
118
+ exercise the rights in the Work as stated below:
119
+
120
+ a. to Reproduce the Work, to incorporate the Work into one or more
121
+ Collections, and to Reproduce the Work as incorporated in the
122
+ Collections;
123
+ b. to create and Reproduce Adaptations provided that any such Adaptation,
124
+ including any translation in any medium, takes reasonable steps to
125
+ clearly label, demarcate or otherwise identify that changes were made
126
+ to the original Work. For example, a translation could be marked "The
127
+ original work was translated from English to Spanish," or a
128
+ modification could indicate "The original work has been modified.";
129
+ c. to Distribute and Publicly Perform the Work including as incorporated
130
+ in Collections; and,
131
+ d. to Distribute and Publicly Perform Adaptations.
132
+ e. For the avoidance of doubt:
133
+
134
+ i. Non-waivable Compulsory License Schemes. In those jurisdictions in
135
+ which the right to collect royalties through any statutory or
136
+ compulsory licensing scheme cannot be waived, the Licensor
137
+ reserves the exclusive right to collect such royalties for any
138
+ exercise by You of the rights granted under this License;
139
+ ii. Waivable Compulsory License Schemes. In those jurisdictions in
140
+ which the right to collect royalties through any statutory or
141
+ compulsory licensing scheme can be waived, the Licensor waives the
142
+ exclusive right to collect such royalties for any exercise by You
143
+ of the rights granted under this License; and,
144
+ iii. Voluntary License Schemes. The Licensor waives the right to
145
+ collect royalties, whether individually or, in the event that the
146
+ Licensor is a member of a collecting society that administers
147
+ voluntary licensing schemes, via that society, from any exercise
148
+ by You of the rights granted under this License.
149
+
150
+ The above rights may be exercised in all media and formats whether now
151
+ known or hereafter devised. The above rights include the right to make
152
+ such modifications as are technically necessary to exercise the rights in
153
+ other media and formats. Subject to Section 8(f), all rights not expressly
154
+ granted by Licensor are hereby reserved.
155
+
156
+ 4. Restrictions. The license granted in Section 3 above is expressly made
157
+ subject to and limited by the following restrictions:
158
+
159
+ a. You may Distribute or Publicly Perform the Work only under the terms
160
+ of this License. You must include a copy of, or the Uniform Resource
161
+ Identifier (URI) for, this License with every copy of the Work You
162
+ Distribute or Publicly Perform. You may not offer or impose any terms
163
+ on the Work that restrict the terms of this License or the ability of
164
+ the recipient of the Work to exercise the rights granted to that
165
+ recipient under the terms of the License. You may not sublicense the
166
+ Work. You must keep intact all notices that refer to this License and
167
+ to the disclaimer of warranties with every copy of the Work You
168
+ Distribute or Publicly Perform. When You Distribute or Publicly
169
+ Perform the Work, You may not impose any effective technological
170
+ measures on the Work that restrict the ability of a recipient of the
171
+ Work from You to exercise the rights granted to that recipient under
172
+ the terms of the License. This Section 4(a) applies to the Work as
173
+ incorporated in a Collection, but this does not require the Collection
174
+ apart from the Work itself to be made subject to the terms of this
175
+ License. If You create a Collection, upon notice from any Licensor You
176
+ must, to the extent practicable, remove from the Collection any credit
177
+ as required by Section 4(b), as requested. If You create an
178
+ Adaptation, upon notice from any Licensor You must, to the extent
179
+ practicable, remove from the Adaptation any credit as required by
180
+ Section 4(b), as requested.
181
+ b. If You Distribute, or Publicly Perform the Work or any Adaptations or
182
+ Collections, You must, unless a request has been made pursuant to
183
+ Section 4(a), keep intact all copyright notices for the Work and
184
+ provide, reasonable to the medium or means You are utilizing: (i) the
185
+ name of the Original Author (or pseudonym, if applicable) if supplied,
186
+ and/or if the Original Author and/or Licensor designate another party
187
+ or parties (e.g., a sponsor institute, publishing entity, journal) for
188
+ attribution ("Attribution Parties") in Licensor's copyright notice,
189
+ terms of service or by other reasonable means, the name of such party
190
+ or parties; (ii) the title of the Work if supplied; (iii) to the
191
+ extent reasonably practicable, the URI, if any, that Licensor
192
+ specifies to be associated with the Work, unless such URI does not
193
+ refer to the copyright notice or licensing information for the Work;
194
+ and (iv) , consistent with Section 3(b), in the case of an Adaptation,
195
+ a credit identifying the use of the Work in the Adaptation (e.g.,
196
+ "French translation of the Work by Original Author," or "Screenplay
197
+ based on original Work by Original Author"). The credit required by
198
+ this Section 4 (b) may be implemented in any reasonable manner;
199
+ provided, however, that in the case of a Adaptation or Collection, at
200
+ a minimum such credit will appear, if a credit for all contributing
201
+ authors of the Adaptation or Collection appears, then as part of these
202
+ credits and in a manner at least as prominent as the credits for the
203
+ other contributing authors. For the avoidance of doubt, You may only
204
+ use the credit required by this Section for the purpose of attribution
205
+ in the manner set out above and, by exercising Your rights under this
206
+ License, You may not implicitly or explicitly assert or imply any
207
+ connection with, sponsorship or endorsement by the Original Author,
208
+ Licensor and/or Attribution Parties, as appropriate, of You or Your
209
+ use of the Work, without the separate, express prior written
210
+ permission of the Original Author, Licensor and/or Attribution
211
+ Parties.
212
+ c. Except as otherwise agreed in writing by the Licensor or as may be
213
+ otherwise permitted by applicable law, if You Reproduce, Distribute or
214
+ Publicly Perform the Work either by itself or as part of any
215
+ Adaptations or Collections, You must not distort, mutilate, modify or
216
+ take other derogatory action in relation to the Work which would be
217
+ prejudicial to the Original Author's honor or reputation. Licensor
218
+ agrees that in those jurisdictions (e.g. Japan), in which any exercise
219
+ of the right granted in Section 3(b) of this License (the right to
220
+ make Adaptations) would be deemed to be a distortion, mutilation,
221
+ modification or other derogatory action prejudicial to the Original
222
+ Author's honor and reputation, the Licensor will waive or not assert,
223
+ as appropriate, this Section, to the fullest extent permitted by the
224
+ applicable national law, to enable You to reasonably exercise Your
225
+ right under Section 3(b) of this License (right to make Adaptations)
226
+ but not otherwise.
227
+
228
+ 5. Representations, Warranties and Disclaimer
229
+
230
+ UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
231
+ OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
232
+ KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
233
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
234
+ FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
235
+ LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
236
+ WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
237
+ OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
238
+
239
+ 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
240
+ LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
241
+ ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
242
+ ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
243
+ BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
244
+
245
+ 7. Termination
246
+
247
+ a. This License and the rights granted hereunder will terminate
248
+ automatically upon any breach by You of the terms of this License.
249
+ Individuals or entities who have received Adaptations or Collections
250
+ from You under this License, however, will not have their licenses
251
+ terminated provided such individuals or entities remain in full
252
+ compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
253
+ survive any termination of this License.
254
+ b. Subject to the above terms and conditions, the license granted here is
255
+ perpetual (for the duration of the applicable copyright in the Work).
256
+ Notwithstanding the above, Licensor reserves the right to release the
257
+ Work under different license terms or to stop distributing the Work at
258
+ any time; provided, however that any such election will not serve to
259
+ withdraw this License (or any other license that has been, or is
260
+ required to be, granted under the terms of this License), and this
261
+ License will continue in full force and effect unless terminated as
262
+ stated above.
263
+
264
+ 8. Miscellaneous
265
+
266
+ a. Each time You Distribute or Publicly Perform the Work or a Collection,
267
+ the Licensor offers to the recipient a license to the Work on the same
268
+ terms and conditions as the license granted to You under this License.
269
+ b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
270
+ offers to the recipient a license to the original Work on the same
271
+ terms and conditions as the license granted to You under this License.
272
+ c. If any provision of this License is invalid or unenforceable under
273
+ applicable law, it shall not affect the validity or enforceability of
274
+ the remainder of the terms of this License, and without further action
275
+ by the parties to this agreement, such provision shall be reformed to
276
+ the minimum extent necessary to make such provision valid and
277
+ enforceable.
278
+ d. No term or provision of this License shall be deemed waived and no
279
+ breach consented to unless such waiver or consent shall be in writing
280
+ and signed by the party to be charged with such waiver or consent.
281
+ e. This License constitutes the entire agreement between the parties with
282
+ respect to the Work licensed here. There are no understandings,
283
+ agreements or representations with respect to the Work not specified
284
+ here. Licensor shall not be bound by any additional provisions that
285
+ may appear in any communication from You. This License may not be
286
+ modified without the mutual written agreement of the Licensor and You.
287
+ f. The rights granted under, and the subject matter referenced, in this
288
+ License were drafted utilizing the terminology of the Berne Convention
289
+ for the Protection of Literary and Artistic Works (as amended on
290
+ September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
291
+ Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
292
+ and the Universal Copyright Convention (as revised on July 24, 1971).
293
+ These rights and subject matter take effect in the relevant
294
+ jurisdiction in which the License terms are sought to be enforced
295
+ according to the corresponding provisions of the implementation of
296
+ those treaty provisions in the applicable national law. If the
297
+ standard suite of rights granted under applicable copyright law
298
+ includes additional rights not granted under this License, such
299
+ additional rights are deemed to be included in the License; this
300
+ License is not intended to restrict the license of any rights under
301
+ applicable law.
302
+
303
+
304
+ Creative Commons Notice
305
+
306
+ Creative Commons is not a party to this License, and makes no warranty
307
+ whatsoever in connection with the Work. Creative Commons will not be
308
+ liable to You or any party on any legal theory for any damages
309
+ whatsoever, including without limitation any general, special,
310
+ incidental or consequential damages arising in connection to this
311
+ license. Notwithstanding the foregoing two (2) sentences, if Creative
312
+ Commons has expressly identified itself as the Licensor hereunder, it
313
+ shall have all rights and obligations of Licensor.
314
+
315
+ Except for the limited purpose of indicating to the public that the
316
+ Work is licensed under the CCPL, Creative Commons does not authorize
317
+ the use by either party of the trademark "Creative Commons" or any
318
+ related trademark or logo of Creative Commons without the prior
319
+ written consent of Creative Commons. Any permitted use will be in
320
+ compliance with Creative Commons' then-current trademark usage
321
+ guidelines, as may be published on its website or otherwise made
322
+ available upon request from time to time. For the avoidance of doubt,
323
+ this trademark restriction does not form part of this License.
324
+
325
+ Creative Commons may be contacted at https://creativecommons.org/.
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dialog bAbI tasks data
2
+ In this directory is the set of 6 tasks for testing end-to-end dialog systems in the restaurant domain as described in the paper "Learning End-to-End Goal-Oriented Dialog" by Bordes & Weston (http://arxiv.org/abs/1605.07683). The aim is that each task tests a unique aspect of dialog. Tasks are designed to complement the set of 20 bAbI tasks for story understanding already released with the paper "Towards AI Complete Question Answering: A Set of Prerequisite Toy Tasks" by Weston et al. (http://arxiv.org/abs/1502.05698).
3
+
4
+
5
+ ## Data
6
+ For each task, there are 1000 dialogs for training, 1000 for development and 1000 for testing. For tasks 1-5, we also include a second test set (with suffix -OOV.txt) that contains dialogs including entities not present in training and development sets.
7
+
8
+ The file format for each task is as follows:
9
+ `ID user_utterance [tab] bot_utterances`
10
+
11
+ The IDs for a given dialog start at 1 and increase. When the IDs in a file reset back to 1 you can consider the following sentences as a new dialog. When the bot speaks two times in a row, we used the special token "<SILENCE>" to fill in for the missing user utterance.
12
+
13
+ For example (for task 1):
14
+ ```
15
+ 1 hi hello what can i help you with today
16
+ 2 can you make a restaurant reservation with italian cuisine for six people in a cheap price range i'm on it
17
+ 3 <SILENCE> where should it be
18
+ 4 rome please ok let me look into some options for you
19
+ 5 <SILENCE> api_call italian rome six cheap
20
+ ```
21
+
22
+ The goal of the tasks is to predict the bot utterances, that can be sentences or API calls (sentences starting with the special token "api_call").
23
+
24
+ Along with the train, dev and test sets, we also include a knowledge base file (dialog-babi-kb-all.txt) that contain all entities appearing in dialogs for tasks 1-5. We also include a file containing the candidates to select the answer from (dialog-babi-candidates.txt) for tasks 1-5, that is simply made of all the bot utterances in train, dev, test for these tasks.
25
+
26
+ Task 6 is a bit different since its data comes from the Dialog State Tracking Challenge 2 (http://camdial.org/~mh521/dstc/), which we modified to convert it into the same format as the other tasks. There is no OOV test set associated with this task and the knowledge base (dialog-babi-task6-dstc2-kb.txt) is imperfect. This task has its own candidates file (dialog-babi-task6-dstc2-candidates.txt).
27
+
28
+
29
+ ## License
30
+ This dataset is released under Creative Commons Attribution 3.0 Unported license. A copy of this license is included with the data.
31
+
32
+
33
+ ## Contact
34
+ The author of this porting is Alessandro Suglia and he has only made available the dataset via
35
+ Huggingface datasets.
36
+ For more details on the dataset and baselines, see the paper "Learning End-to-End Goal-Oriented Dialog" by Antoine Bordes and Jason Weston (http://arxiv.org/abs/1605.07683). For any information, contact Antoine Bordes : abordes (at) fb (dot) com .
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {".": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "text", "config_name": ".", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 20543, "num_examples": 325, "dataset_name": "text"}}, "download_checksums": {"/Users/as2180/workspace/Heriot-WattUniversity/dialog-babi/LICENSE.txt": {"num_bytes": 19568, "checksum": "ae7c5f7078ce6b7c38f0e40da66e4f8c6aa45d933eb9e899997b0104f63ac2fe"}}, "download_size": 19568, "post_processing_size": null, "dataset_size": 20543, "size_in_bytes": 40111}, "task1-API-calls": {"description": "This section presents the set of 6 tasks for testing end-to-end dialog systems in the restaurant domain described in the paper:\n\nAntoine Bordes, Y-Lan Boureau, Jason Weston, Learning End-to-End Goal-Oriented Dialog, arxiv:1605.07683.\n\nEach task tests a unique aspect of dialog. Tasks are designed to complement the set of 20 bAbI tasks for story understanding of the previous section.\n\nFor each task, there are 1000 dialogs for training, 1000 for development and 1000 for testing. For tasks 1-5, we also include a second test set (with suffix -OOV.txt) that contains dialogs including entities not present in training and development sets.\n\n", "citation": "@article{bordes2016learning,\n title={Learning end-to-end goal-oriented dialog},\n author={Bordes, Antoine and Boureau, Y-Lan and Weston, Jason},\n journal={arXiv preprint arXiv:1605.07683},\n year={2016}\n}\n", "homepage": "https://research.facebook.com/downloads/babi/", "license": "data/LICENSE.txt", "features": {"user_turns": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "system_turns": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "dialog_babi", "config_name": "task1-API-calls", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 361576, "num_examples": 1000, "dataset_name": "dialog_babi"}, "validation": {"name": "validation", "num_bytes": 360432, "num_examples": 1000, "dataset_name": "dialog_babi"}, "test": {"name": "test", "num_bytes": 357713, "num_examples": 1000, "dataset_name": "dialog_babi"}, "TESTOOV": {"name": "TESTOOV", "num_bytes": 362595, "num_examples": 1000, "dataset_name": "dialog_babi"}}, "download_checksums": {"https://www.dropbox.com/s/20rgyj8rryvos9l/dialog-bAbI-tasks-1_6.zip?dl=1": {"num_bytes": 3059899, "checksum": "0c100e40ab68c635dbdc915dad71d134f464f570ea1d580b0a16640696c6e389"}}, "download_size": 3059899, "post_processing_size": null, "dataset_size": 1442316, "size_in_bytes": 4502215}}
dialog_babi.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ # Dataset license is specified in the folder data/LICENSE.txt
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import os
17
+ from unicodedata import name
18
+
19
+ import datasets
20
+
21
+ _CITATION = """\
22
+ @article{bordes2016learning,
23
+ title={Learning end-to-end goal-oriented dialog},
24
+ author={Bordes, Antoine and Boureau, Y-Lan and Weston, Jason},
25
+ journal={arXiv preprint arXiv:1605.07683},
26
+ year={2016}
27
+ }
28
+ """
29
+
30
+ _DESCRIPTION = """\
31
+ This section presents the set of 6 tasks for testing end-to-end dialog systems in the restaurant domain described in the paper:
32
+
33
+ Antoine Bordes, Y-Lan Boureau, Jason Weston, Learning End-to-End Goal-Oriented Dialog, arxiv:1605.07683.
34
+
35
+ Each task tests a unique aspect of dialog. Tasks are designed to complement the set of 20 bAbI tasks for story understanding of the previous section.
36
+
37
+ For each task, there are 1000 dialogs for training, 1000 for development and 1000 for testing. For tasks 1-5, we also include a second test set (with suffix -OOV.txt) that contains dialogs including entities not present in training and development sets.
38
+
39
+ """
40
+
41
+ _HOMEPAGE = "https://research.facebook.com/downloads/babi/"
42
+
43
+ _LICENSE = "data/LICENSE.txt"
44
+
45
+ DIALOG_BABI_ARCHIVE_URL = "https://www.dropbox.com/s/20rgyj8rryvos9l/dialog-bAbI-tasks-1_6.zip?dl=1"
46
+
47
+
48
+ class DialogBabiDataset(datasets.GeneratorBasedBuilder):
49
+ """Facebook's dataset 'dialog-babi' for end-to-end dialogue learning."""
50
+
51
+ VERSION = datasets.Version("1.0.0")
52
+
53
+ BUILDER_CONFIGS = [
54
+ datasets.BuilderConfig(name="task1-API-calls", version=VERSION, description="Issuing API calls"),
55
+ datasets.BuilderConfig(name="task2-API-refine", version=VERSION, description="Updating API calls"),
56
+ datasets.BuilderConfig(name="task3-options", version=VERSION, description="Displaying options"),
57
+ datasets.BuilderConfig(name="task4-phone-address", version=VERSION, description="Providing extra information"),
58
+ datasets.BuilderConfig(name="task5-full-dialogs", version=VERSION, description="Conducting full dialogs"),
59
+ datasets.BuilderConfig(name="task6-dstc2", version=VERSION, description="2nd Dialog State Tracking Challenge (Henderson et al., 2014a)"),
60
+ ]
61
+
62
+ DEFAULT_CONFIG_NAME = "task1-API-calls"
63
+
64
+ def _info(self):
65
+ if self.config.name == "task1-API-calls":
66
+ features = datasets.Features(
67
+ {
68
+ "user_turns": datasets.Sequence(datasets.Value("string")),
69
+ "system_turns": datasets.Sequence(datasets.Value("string"))
70
+ }
71
+ )
72
+ else:
73
+ features = datasets.Features(
74
+ {
75
+ "user_turns": datasets.Sequence(datasets.Value("string")),
76
+ "system_turns": datasets.Sequence(datasets.Value("string"))
77
+ }
78
+ )
79
+ return datasets.DatasetInfo(
80
+ description=_DESCRIPTION,
81
+ features=features,
82
+ homepage=_HOMEPAGE,
83
+ license=_LICENSE,
84
+ citation=_CITATION,
85
+ )
86
+
87
+ def _split_generators(self, dl_manager):
88
+ data_dir = dl_manager.download_and_extract(DIALOG_BABI_ARCHIVE_URL)
89
+ task_data_dir = os.path.join(data_dir, "dialog-bAbI-tasks-1_6", self.config.name)
90
+
91
+ return [
92
+ datasets.SplitGenerator(
93
+ name=datasets.Split.TRAIN,
94
+ # These kwargs will be passed to _generate_examples
95
+ gen_kwargs={
96
+ "filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-trn.txt"),
97
+ "split": f"{self.config.name}-train",
98
+ },
99
+ ),
100
+ datasets.SplitGenerator(
101
+ name=datasets.Split.VALIDATION,
102
+ # These kwargs will be passed to _generate_examples
103
+ gen_kwargs={
104
+ "filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-dev.txt"),
105
+ "split": f"{self.config.name}-dev",
106
+ },
107
+ ),
108
+ datasets.SplitGenerator(
109
+ name=datasets.Split.TEST,
110
+ # These kwargs will be passed to _generate_examples
111
+ gen_kwargs={
112
+ "filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-tst.txt"),
113
+ "split": f"{self.config.name}-test"
114
+ },
115
+ ),
116
+ datasets.SplitGenerator(
117
+ name=datasets.Split("TESTOOV"),
118
+ gen_kwargs={
119
+ "filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-tst-OOV.txt"),
120
+ "split": f"{self.config.name}-test-OOV"
121
+ },
122
+ )
123
+ ]
124
+
125
+ def _generate_examples(self, filepath, split):
126
+ with open(filepath, encoding="utf-8") as f:
127
+ dialogue_rows = []
128
+ dialogue_id = 1
129
+
130
+ for row in f:
131
+ turn = row.strip()
132
+ if not turn:
133
+ yield self._format_dialogue(dialogue_id,split, dialogue_rows)
134
+ dialogue_rows.clear()
135
+ dialogue_id += 1
136
+ else:
137
+ dialogue_rows.append(turn)
138
+
139
+ if dialogue_rows:
140
+ yield self._format_dialogue(dialogue_id, split, dialogue_rows)
141
+
142
+ def _format_dialogue(self, dialogue_id, split, dialogue_rows):
143
+
144
+ user_turns = []
145
+ system_turns = []
146
+
147
+ for turn in dialogue_rows:
148
+ rest_turn, sys_turn = turn.split("\t")
149
+ _, user_turn = rest_turn.split(" ", 1)
150
+ user_turns.append(user_turn)
151
+ system_turns.append(sys_turn)
152
+
153
+
154
+ example_key = f"{split}-{dialogue_id}"
155
+ return example_key, {
156
+ "user_turns": user_turns,
157
+ "system_turns": system_turns
158
+ }
159
+