|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""AirDialogue: A large dataset for goal oriented conversations.""" |
|
|
|
|
|
import json |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{wei-etal-2018-airdialogue, |
|
title = "{A}ir{D}ialogue: An Environment for Goal-Oriented Dialogue Research", |
|
author = "Wei, Wei and |
|
Le, Quoc and |
|
Dai, Andrew and |
|
Li, Jia", |
|
booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing", |
|
month = oct # "-" # nov, |
|
year = "2018", |
|
address = "Brussels, Belgium", |
|
publisher = "Association for Computational Linguistics", |
|
url = "https://www.aclweb.org/anthology/D18-1419", |
|
doi = "10.18653/v1/D18-1419", |
|
pages = "3844--3854", |
|
abstract = "Recent progress in dialogue generation has inspired a number of studies on dialogue systems that are capable of accomplishing tasks through natural language interactions. A promising direction among these studies is the use of reinforcement learning techniques, such as self-play, for training dialogue agents. However, current datasets are limited in size, and the environment for training agents and evaluating progress is relatively unsophisticated. We present AirDialogue, a large dataset that contains 301,427 goal-oriented conversations. To collect this dataset, we create a context-generator which provides travel and flight restrictions. We then ask human annotators to play the role of a customer or an agent and interact with the goal of successfully booking a trip given the restrictions. Key to our environment is the ease of evaluating the success of the dialogue, which is achieved by using ground-truth states (e.g., the flight being booked) generated by the restrictions. Any dialogue agent that does not generate the correct states is considered to fail. Our experimental results indicate that state-of-the-art dialogue models can only achieve a score of 0.17 while humans can reach a score of 0.91, which suggests significant opportunities for future improvement.", |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
AirDialogue, is a large dataset that contains 402,038 goal-oriented conversations. To collect this dataset, we create a contextgenerator which provides travel and flight restrictions. Then the human annotators are asked to play the role of a customer or an agent and interact with the goal of successfully booking a trip given the restrictions. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://worksheets.codalab.org/worksheets/0xa79833f4b3c24f4188cee7131b120a59" |
|
|
|
|
|
_LICENSE = "cc-by-nc-4.0" |
|
|
|
|
|
|
|
|
|
_URL = "https://storage.googleapis.com/airdialogue/airdialogue_data.tar.gz" |
|
|
|
|
|
|
|
class AirDialogue(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("1.3.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name="air_dialogue_data", version=VERSION, description="This part of my dataset covers the dialog files" |
|
), |
|
datasets.BuilderConfig( |
|
name="air_dialogue_kb", version=VERSION, description="This part of my dataset covers the knowledge base" |
|
), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = ( |
|
"air_dialogue_data" |
|
) |
|
|
|
def _info(self): |
|
|
|
if ( |
|
self.config.name == "air_dialogue_data" |
|
): |
|
features = datasets.Features( |
|
{ |
|
"action": { |
|
"status": datasets.Value("string"), |
|
"name": datasets.Value("string"), |
|
"flight": datasets.features.Sequence(datasets.Value("int32")), |
|
}, |
|
"intent": { |
|
"return_month": datasets.Value("string"), |
|
"return_day": datasets.Value("string"), |
|
"max_price": datasets.Value("int32"), |
|
"departure_airport": datasets.Value("string"), |
|
"max_connections": datasets.Value("int32"), |
|
"departure_day": datasets.Value("string"), |
|
"goal": datasets.Value("string"), |
|
"departure_month": datasets.Value("string"), |
|
"name": datasets.Value("string"), |
|
"return_airport": datasets.Value("string"), |
|
}, |
|
"timestamps": datasets.features.Sequence(datasets.Value("int64")), |
|
"dialogue": datasets.features.Sequence(datasets.Value("string")), |
|
"expected_action": { |
|
"status": datasets.Value("string"), |
|
"name": datasets.Value("string"), |
|
"flight": datasets.features.Sequence(datasets.Value("int32")), |
|
}, |
|
"search_info": [ |
|
{ |
|
"button_name": datasets.Value("string"), |
|
"field_name": datasets.Value("string"), |
|
"field_value": datasets.Value("string"), |
|
"timestmamp": datasets.Value("int64"), |
|
}, |
|
], |
|
"correct_sample": datasets.Value("bool_"), |
|
} |
|
) |
|
else: |
|
features = datasets.Features( |
|
{ |
|
"kb": [ |
|
{ |
|
"airline": datasets.Value("string"), |
|
"class": datasets.Value("string"), |
|
"departure_airport": datasets.Value("string"), |
|
"departure_day": datasets.Value("string"), |
|
"departure_month": datasets.Value("string"), |
|
"departure_time_num": datasets.Value("int32"), |
|
"flight_number": datasets.Value("int32"), |
|
"num_connections": datasets.Value("int32"), |
|
"price": datasets.Value("int32"), |
|
"return_airport": datasets.Value("string"), |
|
"return_day": datasets.Value("string"), |
|
"return_month": datasets.Value("string"), |
|
"return_time_num": datasets.Value("int32"), |
|
}, |
|
], |
|
"reservation": datasets.Value("int32"), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
archive = dl_manager.download(_URL) |
|
if self.config.name == "air_dialogue_data": |
|
train = "airdialogue_data_1.3/airdialogue/train_data.json" |
|
dev = "airdialogue_data_1.3/airdialogue/dev_data.json" |
|
else: |
|
train = "airdialogue_data_1.3/airdialogue/train_kb.json" |
|
dev = "airdialogue_data_1.3/airdialogue/dev_kb.json" |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": train, |
|
"files": dl_manager.iter_archive(archive), |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": dev, |
|
"files": dl_manager.iter_archive(archive), |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath, files): |
|
"""Yields examples.""" |
|
|
|
|
|
|
|
|
|
for path, f in files: |
|
if path == filepath: |
|
for id_, row in enumerate(f): |
|
row = row.decode("utf-8") |
|
data = json.loads(row) |
|
if self.config.name == "air_dialogue_data": |
|
|
|
intent = { |
|
"return_month": data["intent"]["return_month"], |
|
"return_day": data["intent"]["return_day"], |
|
"max_price": data["intent"]["max_price"], |
|
"departure_airport": data["intent"]["departure_airport"], |
|
"max_connections": data["intent"].get("max_connections", -1), |
|
"departure_day": data["intent"]["departure_day"], |
|
"goal": data["intent"]["goal"], |
|
"departure_month": data["intent"]["departure_month"], |
|
"name": data["intent"]["name"], |
|
"return_airport": data["intent"]["return_airport"], |
|
} |
|
|
|
search_info = ( |
|
[] |
|
if "search_info" not in data |
|
else [ |
|
{ |
|
"button_name": search_info.get("button_name", ""), |
|
"field_name": search_info.get("field_name", ""), |
|
"field_value": search_info.get("field_value", ""), |
|
"timestmamp": search_info["timestmamp"], |
|
} |
|
for search_info in data["search_info"] |
|
] |
|
) |
|
|
|
yield id_, { |
|
"action": {key: data["action"][key] for key in data["action"]}, |
|
"intent": intent, |
|
"timestamps": data["timestamps"], |
|
"dialogue": data["dialogue"], |
|
"expected_action": {key: data["expected_action"][key] for key in data["expected_action"]}, |
|
"search_info": search_info, |
|
"correct_sample": data["correct_sample"], |
|
} |
|
|
|
else: |
|
|
|
kb = [ |
|
{ |
|
"airline": kb["airline"], |
|
"class": kb["class"], |
|
"departure_airport": kb["departure_airport"], |
|
"departure_day": kb["departure_day"], |
|
"departure_month": kb["departure_month"], |
|
"departure_time_num": kb["departure_time_num"], |
|
"flight_number": kb["flight_number"], |
|
"num_connections": kb["num_connections"], |
|
"price": kb["price"], |
|
"return_airport": kb["return_airport"], |
|
"return_day": kb["return_day"], |
|
"return_month": kb["return_month"], |
|
"return_time_num": kb["return_time_num"], |
|
} |
|
for kb in data["kb"] |
|
] |
|
|
|
yield id_, { |
|
"kb": kb, |
|
"reservation": data["reservation"], |
|
} |
|
break |
|
|