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

[WoW] Update teachers to use DialogTeacher #4284

Merged
merged 9 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions parlai/core/teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ def __init__(self, opt, data_loader=None, cands=None, shared=None, **kwargs):
self.reset_data = shared['reset']
# Share datafile and data_loader for computing num_exs and num_eps
self.datafile = shared['datafile']
self.length_datafile = opt.get('length_datafile', None)
self.data_loader = shared['data_loader']
if 'lock' in shared:
self.lock = shared['lock']
Expand All @@ -1078,6 +1079,7 @@ def __init__(self, opt, data_loader=None, cands=None, shared=None, **kwargs):
ERROR_MESSAGE_NO_DATAFILE.format(class_name=self.__class__.__name__)
)
self.datafile = opt['datafile']
self.length_datafile = opt.get('length_datafile', None)
self.reset_data = None
self.is_reset = True
self.entry_idx = 0
Expand Down Expand Up @@ -1137,8 +1139,13 @@ def load_length(self):
Note that this can take some time for large datasets. Episode and entry indexes
cannot be specified during streaming.
"""
datafiles = self.datafile if type(self.datafile) is tuple else [self.datafile]
length_file = datafiles[0] + ".lengths"
if self.length_datafile:
length_file = self.length_datafile
else:
datafiles = (
self.datafile if type(self.datafile) is tuple else [self.datafile]
)
length_file = datafiles[0] + ".lengths"
if not PathManager.exists(length_file):
num_eps = 0
num_exs = 0
Expand Down
4 changes: 2 additions & 2 deletions parlai/tasks/blended_skill_talk/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def __init__(self, opt, shared=None):
)
super().__init__(opt, shared=shared)

def get(self, episode_idx, entry_idx=None):
gotten = super().get(episode_idx, entry_idx=entry_idx)
def _format_example(self, episode_idx, entry_idx=None):
gotten = super()._format_example(episode_idx, entry_idx)
if entry_idx == 0:
modified_text = self.persona_topicifier.get_modified_text(gotten['text'])
gotten.force_set('text', modified_text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ acts:
realization tomorrow...

'
label_candidates: []
labels:
- I think science fiction is an amazing genre for anything. Future science, technology,
time travel, FTL travel, they're all such interesting concepts.
Expand Down Expand Up @@ -238,7 +237,6 @@ acts:
most exist within the city built by the Ancients known as Atlantis.

'
label_candidates: []
labels:
- Awesome! I really love how sci-fi storytellers focus on political/social/philosophical
issues that would still be around even in the future. Makes them relatable.
Expand Down Expand Up @@ -471,7 +469,6 @@ acts:
and Michael Giacchino, respectively.

'
label_candidates: []
labels:
- It's not quite sci-fi, but my favorite version of time travel is in Harry Potter
and the Prisoner of Azkaban. Breaks zero logical rules.
Expand Down Expand Up @@ -697,7 +694,6 @@ acts:
Harry Potter, Ron Weasley, and Hermione Granger.

'
label_candidates: []
labels:
- If you really want a look at the potential negative consequences of scientific
innovation, what you should check out is the TV show Fringe. Incredibly well
Expand Down Expand Up @@ -836,7 +832,6 @@ acts:
assumed or defined as requirements.

'
label_candidates: []
labels:
- No I could not! I couldn't imagine living when internet access was rare and
very few people had it!
Expand Down
Loading