Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[Poly-encoder] Fixes for DSTC7 Task #2314

Merged
merged 3 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions parlai/tasks/dstc7/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,28 @@ def __init__(self, opt, shared=None):
filepath = os.path.join(
basedir, 'ubuntu_%s_subtask_1%s.json' % (self.split, self.get_suffix())
)
with open(filepath, 'r') as f:
self.data = json.loads(f.read())

# special case of test set
if self.split == "test":
id_to_res = {}
with open(
os.path.join(basedir, "ubuntu_responses_subtask_1.tsv"), 'r'
) as f:
for line in f:
splited = line[0:-1].split("\t")
id_ = splited[0]
id_res = splited[1]
res = splited[2]
id_to_res[id_] = [{"candidate-id": id_res, "utterance": res}]
for sample in self.data:
sample["options-for-correct-answers"] = id_to_res[
str(sample["example-id"])
]
if shared is not None:
self.data = shared['data']
else:
with open(filepath, 'r') as f:
self.data = json.loads(f.read())

# special case of test set
if self.split == "test":
id_to_res = {}
with open(
os.path.join(basedir, "ubuntu_responses_subtask_1.tsv"), 'r'
) as f:
for line in f:
splited = line[0:-1].split("\t")
id_ = splited[0]
id_res = splited[1]
res = splited[2]
id_to_res[id_] = [{"candidate-id": id_res, "utterance": res}]
for sample in self.data:
sample["options-for-correct-answers"] = id_to_res[
str(sample["example-id"])
]

super().__init__(opt, shared)
self.reset()
Expand Down Expand Up @@ -96,6 +99,17 @@ def share(self):
return shared


class DSTC7TeacherAugmented(DSTC7Teacher):
"""
Augmented.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more detail in this docstring? what does augmented mean? what is the difference between augmented and augmented sampled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest, @samhumeau would have a better idea of what exactly this means. I will consult him offline (unless he wants to comment here 😄)

"""

def get_suffix(self):
if self.split != "train":
return ""
return "_augmented"


class DSTC7TeacherAugmentedSampled(DSTC7Teacher):
"""
The dev and test set are the same, but the training set has been augmented using the
Expand All @@ -107,7 +121,7 @@ class DSTC7TeacherAugmentedSampled(DSTC7Teacher):
def get_suffix(self):
if self.split != "train":
return ""
return "_augmented"
return "_sampled"

def get_nb_cands(self):
return 16
Expand Down
8 changes: 4 additions & 4 deletions parlai/tasks/dstc7/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

RESOURCES = [
DownloadableFile(
'http://parl.ai/downloads/dstc7/dstc7.tar.gz',
'dstc7.tar.gz',
'aa3acec0aedb660f1549cdd802f01e5bc9c5b9dc06f10764c5e20686aa4d5571',
'http://parl.ai/downloads/dstc7/dstc7_v2.tgz',
'dstc7_v2.tgz',
'cc8fd830f9894768ab4f7b104cddd4105456812ab614041337ec12c5a3a56685',
)
]


def build(opt):
dpath = os.path.join(opt['datapath'], 'dstc7')
version = None
version = '2.0'

if not build_data.built(dpath, version_string=version):
print('[building data: ' + dpath + ']')
Expand Down