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

[WoW] WoW filter for examples with *only* no passages used #4418

Merged
merged 1 commit into from
Mar 14, 2022
Merged
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
22 changes: 20 additions & 2 deletions parlai/tasks/wizard_of_wikipedia/mutators.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,36 @@ class WowFilterNoPassageUsed(ManyEpisodeMutator):
on.
"""

def fails(self, sentences: str) -> bool:
"""
Return if checked sentence is filtered.
"""
return sentences == "no_passages_used"

def many_episode_mutation(self, episode):
out_episodes = []
for e in episode:
checked_sentences = e.get('checked_sentence')
checked_sentences = ' '.join(checked_sentences)
if checked_sentences == "no_passages_used":
if self.fails(checked_sentences):
pass
else:
out_episodes.append([e])
return out_episodes


@register_mutator("wow_only_no_passage_used")
class WowOnlyNoPassageUsed(WowFilterNoPassageUsed):
"""
Allows to filter such that only examples where no passage was selected are used.
"""

def fails(self, sentences: str) -> bool:
"""
Return if checked sentence is filtered.
"""
return sentences != "no_passages_used"


@register_mutator("wow_to_woi")
class WowToWoi(MessageMutator):
def message_mutation(self, message: Message) -> Message:
Expand Down