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

Commit

Permalink
[WoW] Update teachers to use DialogTeacher (#4284)
Browse files Browse the repository at this point in the history
* update teachers to use dialog teacher

* finalize changes

* remove commented code

* bst update

* remove shared
  • Loading branch information
klshuster committed Mar 30, 2022
1 parent 42e5773 commit 8e718b0
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 161 deletions.
11 changes: 9 additions & 2 deletions parlai/core/teachers.py
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
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
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

0 comments on commit 8e718b0

Please sign in to comment.