agents.coopgame_agent

Collection of agents participating in cooperative goal-based conversational games. One such game, named Task n’ Talk is described in the paper “Natural Language Does Not Emerge ‘Naturally’ in Multi-Agent Dialog (Kottur et al. 2017)”. General properties of such cooperative games are:

  • Two agents: Questioner and Answerer, occasionally may be more.
  • Information Asymmetry:
    • Answerer agent has information about visual content (real/synthetic image), but doesn’t know the goal of conversation.
    • Questioner agent is blind and has a goal unknown to the answerer agent. It asks questions in order to accomplish the goal. At the end of dialog episode, it makes a prediction.
  • Same reward: Both the agents can observe their own, as well as others’ actions. At the end of dialog episode, both agents are given same reward based on questioner’s prediction. Hence both must cooperate to maximize the reward.

Specifically for Task n’ Talk (taken from Kottur et al. 2017):

_images/taskntalk.png

Information Asymmetry: Answerer has an image described by attributes. Questioner cannot see the image, and has a task of finding two attributes of the image.

Building-block Modules

These are set of modules essential for agents in cooperative and goal-based conversational games. These agents use following modules, each module can be subclassed and replaced in agent according to need. All modules are extended from torch.nn.Module.

parlai.agents.coopgame_agent.modules.xavier_init(module)

Xavier initializer for module parameters.

class parlai.agents.coopgame_agent.modules.ImgNet(feature_size, input_size=None)

Module to embed the visual information. Used by answerer agent. In forward: Embed image attributes and concatenate them together.

Note: parlai.core.image_featurizers.ImageLoader can also be used instead.

__init__(feature_size, input_size=None)

Initialize self. See help(type(self)) for accurate signature.

forward(image)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class parlai.agents.coopgame_agent.modules.ListenNet(in_size, embed_size)

Module for listening the sequence spoken by other agent. In forward: Generate token embeddings.

__init__(in_size, embed_size)

Initialize self. See help(type(self)) for accurate signature.

forward(text_tokens)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class parlai.agents.coopgame_agent.modules.StateNet(embed_size, state_size)

Module for containing the state update mechanism for an agent. In forward: Update states by passing the embeddings through LSTMCell.

__init__(embed_size, state_size)

Initialize self. See help(type(self)) for accurate signature.

forward(states, embeds)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class parlai.agents.coopgame_agent.modules.SpeakNet(state_size, out_size)

Module for speaking a token based on current state. In forward: Return a probability distribution of utterances of tokens.

__init__(state_size, out_size)

Initialize self. See help(type(self)) for accurate signature.

forward(state)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class parlai.agents.coopgame_agent.modules.PredictNet(embed_size, state_size, out_size)

Module to make a prediction as per goal. Used by questioner agent. In forward: Return a probability distribution of utterances of tokens.

__init__(embed_size, state_size, out_size)

Initialize self. See help(type(self)) for accurate signature.

forward(task_embeds, states)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.