google-research-datasets/coached_conv_pref
A dataset consisting of 502 English dialogs with 12,000 annotated utterances between a user and an assistant discussing movie preferences in natural language. It was collected using a Wizard-of-Oz methodology between two paid crowd-workers, where one worker plays the role of an 'assistant', while the other plays the role of a 'user'. The 'assistant' elicits the 'user’s' preferences about movies following a Coached Conversational Preference Elicitation (CCPE) method. The assistant asks questions designed to minimize the bias in the terminology the 'user' employs to convey his or her preferences as much as possible, and to obtain these preferences in natural language. Each dialog is annotated with entity mentions, preferences expressed about entities, descriptions of entities provided, and other statements of entities.
1# coding=utf-82# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.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 at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# 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 and14# limitations under the License.15"""Coached Conversational Preference Elicitation Dataset to Understanding Movie Preferences"""16 17 18import json19import os20 21import datasets22 23 24_CITATION = """\25@inproceedings{48414,26title = {Coached Conversational Preference Elicitation: A Case Study in Understanding Movie Preferences},27author = {Filip Radlinski and Krisztian Balog and Bill Byrne and Karthik Krishnamoorthi},28year = {2019},29booktitle = {Proceedings of the Annual SIGdial Meeting on Discourse and Dialogue}30}31"""32 33_DESCRIPTION = """\34A dataset consisting of 502 English dialogs with 12,000 annotated utterances between a user and an assistant discussing35movie preferences in natural language. It was collected using a Wizard-of-Oz methodology between two paid crowd-workers,36where one worker plays the role of an 'assistant', while the other plays the role of a 'user'. The 'assistant' elicits37the 'user’s' preferences about movies following a Coached Conversational Preference Elicitation (CCPE) method. The38assistant asks questions designed to minimize the bias in the terminology the 'user' employs to convey his or her39preferences as much as possible, and to obtain these preferences in natural language. Each dialog is annotated with40entity mentions, preferences expressed about entities, descriptions of entities provided, and other statements of41entities."""42 43_HOMEPAGE = "https://research.google/tools/datasets/coached-conversational-preference-elicitation/"44 45_LICENSE = "https://creativecommons.org/licenses/by-sa/4.0/"46 47_URLs = {"dataset": "https://storage.googleapis.com/dialog-data-corpus/CCPE-M-2019/data.json"}48 49 50class CoachedConvPrefConfig(datasets.BuilderConfig):51 """BuilderConfig for DialogRE"""52 53 def __init__(self, **kwargs):54 """BuilderConfig for DialogRE.55 Args:56 **kwargs: keyword arguments forwarded to super.57 """58 super(CoachedConvPrefConfig, self).__init__(**kwargs)59 60 61class CoachedConvPref(datasets.GeneratorBasedBuilder):62 """Coached Conversational Preference Elicitation Dataset to Understanding Movie Preferences"""63 64 VERSION = datasets.Version("1.1.0")65 66 BUILDER_CONFIGS = [67 CoachedConvPrefConfig(68 name="coached_conv_pref",69 version=datasets.Version("1.1.0"),70 description="Coached Conversational Preference Elicitation Dataset to Understanding Movie Preferences",71 ),72 ]73 74 def _info(self):75 return datasets.DatasetInfo(76 description=_DESCRIPTION,77 features=datasets.Features(78 {79 "conversationId": datasets.Value("string"),80 "utterances": datasets.Sequence(81 {82 "index": datasets.Value("int32"),83 "speaker": datasets.features.ClassLabel(names=["USER", "ASSISTANT"]),84 "text": datasets.Value("string"),85 "segments": datasets.Sequence(86 {87 "startIndex": datasets.Value("int32"),88 "endIndex": datasets.Value("int32"),89 "text": datasets.Value("string"),90 "annotations": datasets.Sequence(91 {92 "annotationType": datasets.features.ClassLabel(93 names=[94 "ENTITY_NAME",95 "ENTITY_PREFERENCE",96 "ENTITY_DESCRIPTION",97 "ENTITY_OTHER",98 ]99 ),100 "entityType": datasets.features.ClassLabel(101 names=[102 "MOVIE_GENRE_OR_CATEGORY",103 "MOVIE_OR_SERIES",104 "PERSON",105 "SOMETHING_ELSE",106 ]107 ),108 }109 ),110 }111 ),112 }113 ),114 }115 ),116 supervised_keys=None,117 homepage=_HOMEPAGE,118 license=_LICENSE,119 citation=_CITATION,120 )121 122 def _split_generators(self, dl_manager):123 """Returns SplitGenerators."""124 125 data_dir = dl_manager.download_and_extract(_URLs)126 127 # Dataset is a single corpus (does not contain any split)128 return [129 datasets.SplitGenerator(130 name=datasets.Split.TRAIN,131 gen_kwargs={132 "filepath": os.path.join(data_dir["dataset"]),133 "split": "train",134 },135 ),136 ]137 138 def _generate_examples(self, filepath, split):139 """Yields examples."""140 141 # Empty Segment list with annotations dictionary142 # First prompt of a conversation does not contain the segment dictionary143 # We are setting it to None values144 segments_empty = [145 {146 "startIndex": 0,147 "endIndex": 0,148 "text": "",149 "annotations": [],150 }151 ]152 153 with open(filepath, encoding="utf-8") as f:154 dataset = json.load(f)155 156 for id_, data in enumerate(dataset):157 conversationId = data["conversationId"]158 159 utterances = data["utterances"]160 for utterance in utterances:161 if "segments" not in utterance:162 utterance["segments"] = segments_empty.copy()163 164 yield id_, {165 "conversationId": conversationId,166 "utterances": utterances,167 }168 