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

please clarify "xs" and "ys" names in seq2seq tutorial #1329

Closed
bionicles opened this issue Dec 27, 2018 · 5 comments
Closed

please clarify "xs" and "ys" names in seq2seq tutorial #1329

bionicles opened this issue Dec 27, 2018 · 5 comments

Comments

@bionicles
Copy link

bionicles commented Dec 27, 2018

Thank you for doing a great job in making it easier to get started.

Onboarding easier = more people cite this = more models and data = faster progress

One problem: Trying to make new models for genetic programming stuffs, but it isn't clear exactly what are the variables returned when we vectorize observations because the names are just 2 letters, xs and ys, -- how can ys be the labels if there's another "labels" ?

Would it be possible to adjust the seq2seq tutorial and code to clarify what "xs" and "ys" are exactly?

Thanks for any help,

Bion Howard, Founder at Bitpharma.com

@bionicles
Copy link
Author

text, targets, labels, valid_indices, is_training = vectorize(observations) ?

@bionicles
Copy link
Author

the batch_act method invokes PaddingUtils which is deprecated

@bionicles
Copy link
Author

Is torch_agent.match_batch the new method to use instead of PaddingUtils.map_predictions?

def match_batch(self, batch_reply, valid_inds, output=None):

https://github.com/facebookresearch/ParlAI/blob/master/parlai/core/torch_agent.py

@bionicles
Copy link
Author

bionicles commented Dec 27, 2018

We want to make one system which can do many different tasks including Parlai, OpenAI, custom biomolecular engineering stuff, so it's hard to make that a subclass of torch_agent;

maybe we could save re-implementation:
TorchAgent.init() method could accept a User Agent Module --> if that is a torch.nn module, we can just use it, if the user agent module is a python class then we could invoke the user's desired forward/compute function by string name? e.g.

def __init__(self, user_agent=None, custom_forward_name="compute"):  
  super().__init__(opt, shared)
  if user_agent = None:
     ... normal stuff ... 
  else:
     if user_agent.__class__.__name__ == "Torch Module":
         self.module = user_agent
     else:
        self.module = user_agent
        self.forward = get_attr(user_agent, custom_forward_name)      

so then when our trainer decides to run the Parlai task, it can just do

def run_dialog_test(nature, nurture):
    system = System(nature, nurture)
    parlai_system = DialogAgent(system)
    for dialog_task_name in nurture.dialog_task_names:
        parlai_teacher = DialogTeacher(dialog_task_name)
        reply, done = None, False
        for episode_number in nurture.episodes_per_dialog_task:
            while not done:
                batch, done = parlai_teacher.process(reply, nurture.batch_size)
                if done:
                    score = parlai_teacher.get_score()
                    nurture.scores[dialog_task_name].append(score)
                else:
                    reply = parlai_system.reply_to(batch)
    nature = update_graph_parameters(nature, parlai_system)
    return nature, nurture

@stephenroller
Copy link
Contributor

stephenroller commented Jan 10, 2019

Hi @bionicles,

Apologies for delays; this all came up on holiday break and I just rediscovered it.

  • There isn't a perfect correspondence between the seq2seq we use the most, and the example_seq2seq presented in the tutorial. The goal of the example is to present a more minimal example where you can see how all pieces work easily. We tend to recommend users building new agents consider inheriting from TorchAgent or TorchGeneratorAgent so that more boilerplate is done for them already. Please take a look at the newer example seq2seq which inherits from TorchAgent. The newer stuff has more explicit names for these variables.
  • match_batch and similar are done because the PyTorch LSTM requires the inputs to be sorted by length. This requires extra book keeping to match input batches to actual tensors, and then back again.
  • If you inherit from TorchAgent, you are required to implemented build_model, which creates a nn.Module. Custom forward names will not be implemented, but you can implement train_step and eval_step to call whatever you want.

Hope that helps! Please feel free to re-open this issue if you have any more questions!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants