Torchagent flags
* Add two flags to TorchAgent to enable access to existing features:
use-reply to use either labels or model's own previous replies;
add-p1-after-newln to move the __p1__ token to the last newline
@@ -183,6 +183,17 @@ class TorchAgent(Agent):
'text and __p2__ in front of past labels when available or '
'past utterances generated by the model. these are added to '
'the dictionary during initialization.')
+ agent.add_argument(
+ '--use-reply', default='label', hidden=True,
+ choices=['label', 'model'],
+ help='Which previous replies to use as history. If label, use '
+ 'gold dataset replies. If model, use model\'s own replies.')
+ agent.add_argument(
+ '--add-p1-after-newln', type='bool', default=False, hidden=True,
+ help='Add the other speaker token before the last newline in the '
+ 'input instead of at the beginning of the input. this is '
+ 'useful for tasks that include some kind of context before '
+ 'the actual utterance (e.g. squad, babi, personachat).')
# GPU arguments
# these gpu options are all mutually exclusive, and should error if the
# user tries to present multiple of them
@@ -785,9 +796,11 @@ class TorchAgent(Agent):
This includes remembering the past history of the conversation.
"""
- reply = self.last_reply()
+ reply = self.last_reply(
+ use_label=(self.opt.get('use_reply', 'label') == 'label'))
self.observation = self.get_dialog_history(
- observation, reply=reply, add_person_tokens=self.add_person_tokens)
+ observation, reply=reply, add_person_tokens=self.add_person_tokens,
+ add_p1_after_newln=self.opt.get('add_p1_after_newln', False))
return self.vectorize(self.observation, truncate=self.truncate)
def save(self, path=None):
