RFC: Data Mutators #3434
Replies: 6 comments 4 replies
-
One comment from viewer: we may wish to clarify when the best time is to create a new teacher vs a new mutator. |
Beta Was this translation helpful? Give feedback.
-
Example implementation of a turn shuffler @register_mutator("turn_shuffle")
class ShuffleMutator(EpisodeMutator):
def __init__(self, opt: Opt):
super().__init__(opt)
self.rng = random.Random(42)
def episode_mutation(self, episode: List[Message]) -> List[Message]:
self.rng.shuffle(episode)
return episode Example of a within-turn word shuffler: @register_mutator("word_shuffle")
class WordShuffleMutator(ExampleMutator):
def example_mutation(self, example: Message) -> List[Message]:
tokens = example['text'].split() # switch to a standard tokenizer here?
self.rng.shuffle(tokens)
retval = example.copy()
retval.force_set('text', ' '.join(tokens))
return retval Example of a flattener: @register_mutator("flatten")
class FlattenMutator(TeacherMutator):
def teacher_mutation(self, examples):
context = []
for message, is_new_episode in examples:
if is_new_episode:
context = []
context.append(message['text'])
m = message.copy()
m.force_set('text', '\n'.join(context))
yield m, True |
Beta Was this translation helpful? Give feedback.
-
Advantage of mutator over simple teacher changes is not clear to me. Would also like some clarification around when one would be better than another (e.g. when would you want to override setup_data or whatever vs. adding a custom abstract mutation). These days the most common "mutation" I perform to a teacher is adding control tokens -- would something like this be easily supported with this idea? Maybe a good idea to crowdsource other common ideas such that they can be explicitly supported. |
Beta Was this translation helpful? Give feedback.
-
Another possible mutator might be randomly sampling the data |
Beta Was this translation helpful? Give feedback.
-
Appreciate the granularity of EpisodeMutator, ExampleMutator. Would be also good to think about ways to add nontrivial mutators like synonym mutators, paraphrase mutators, ASR error proxy mutators, external knowledge retrieval mutators. |
Beta Was this translation helpful? Give feedback.
-
Implemented in #3448 |
Beta Was this translation helpful? Give feedback.
-
Proposal for Data mutators
We would like a way to do generic data transformations on ParlAI teachers, without requiring extending and overriding code a specific teacher.
Examples:
Existing solutions
Wrappers
-t wrapper
is used in place. There are some questions about how accurate this, and if it's compatible with arbitrary teachers, as it relies on get()Teacher overriding
Frequently we do this by subclassing a teacher and implementing. This depends quite a bit on what is the abstract class of the Teacher: ChunkTeacher, FixedDataTeacher or DataTeacher.
Requirements
--mutators shuffle_turns,flatten
Proposed UI
UI
Any time a teacher is used, the
--mutator
option is available. You can compose mutators.Examples:
Unanswered: what about multitasking?
Proposed API
Three separate abstract mutator classes are made available, with increasing complexity and power:
Beta Was this translation helpful? Give feedback.
All reactions