SlowGuess/NAACL_2021_OCR huggingface dataset:
Athul Paul Jacob
apjacob@mit.edu
When intelligent agents communicate to accomplish shared goals, how do these goals shape the agents' language? We study the dynamics of learning in latent language policies (LLPs), in which instructor agents generate natural-language subgoal descriptions and executor agents map these descriptions to low-level actions. LLPs can solve challenging long-horizon reinforcement learning problems and provide a rich model for studying task-oriented language use. But previous work has found that LLP training is prone to semantic drift (use of messages in ways inconsistent with their original natural language meanings). Here, we demonstrate theoretically and empirically that multitask training is an effective counter to this problem: we prove that multitask training eliminates semantic drift in a well-studied family of signaling games, and show that multitask training of neural LLPs in a complex strategy game reduces drift and while improving sample efficiency.
A major goal in the study of artificial and natural intelligence is to understand how language can scaffold more general problem-solving skills (e.g. Spelke, 2017), and how these skills in turn shape language itself (e.g. Gibson et al., 2017). In NLP and machine learning, latent language policies (LLPs; Andreas et al., 2018) provide a standard framework for studying these questions. An LLP consists of instructor and executor subpolicies: the instructor generates natural language messages (e.g. high-level commands or subgoals), and the executor maps these messages to sequences of low-level actions (Fig. 1). LLPs have been used to construct interactive agents capable of complex reasoning (e.g. programming by demonstration) and planning over long horizons (e.g. in strategy games; Hu et al., 2019). They promise an effective and interpretable interface between planning and control.
Figure 1: In latent language policies, instructor agents (a) send natural-language commands (b) to executor agents (c), which execute them in an interactive environment (d). Jointly trained instructor-executor pairs learn to use messages in ways inconsistent with their natural language meanings (top shows a real message-action pair from a model described in Section 4). We show that multitask training with a population of task-specific instructors stabilizes message semantics and in some cases improves model performance.
However, they present a number of challenges for training. As LLPs employ a human-specified space of high-level commands, they must be initialized with human supervision, typically obtained by pretraining the executor. On its own, this training paradigm restricts the quality of the learned executor policy to that exhibited in (possibly suboptimal) human supervision. For tasks like the real-time strategy game depicted in Fig. 1, we would like to study LLPs trained via reinforcement learning (RL), jointly learning from a downstream reward signal, and optimizing both instructors and executors for task success rather than fidelity to human teachers.
Training LLPs via RL has proven difficult. Past work has identified two main challenges: primarily, the LLP-specific problem of semantic drift, in which agents come to deploy messages in ways
Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5351-5366 June 6-11, 2021. ©2021 Association for Computational Linguistics
inconsistent with their original (natural language) meanings (Lewis et al., 2017; Lee et al., 2019); secondarily, the general problem of sample inefficiency in RL algorithms (Kakade et al., 2003; Brunskill and Li, 2013). Model-free deep RL is particularly notorious for requiring enormous amounts of interaction with the environment (Munos et al., 2016; Mnih et al., 2013b). For LLPs to meet their promise as flexible, controllable, and understandable tools for deep learning, better approaches are needed to limit semantic drift and perhaps improve sample efficiency.
While semantic change is a constant and well-documented feature of human languages (McMahon and April, 1994), (human) word meanings are on the whole remarkably stable relative to the rate of change in the tasks for which words are deployed (Karjus et al., 2020). In particular, disappearance of lexical items is mitigated by increased population size (Bromham et al., 2015) and increased frequency of use (Pagel et al., 2007). Drawing on these facts about stabilizing factors in human language, we hypothesize that training of machine learning models with latent language variables can be made more robust by incorporating a population of instructors with diverse communicative needs that exercise different parts of the lexicon.
We describe a multitask LLP training scheme in which task-specific instructors communicate with a shared executor. We show that complex long-horizon LLPs can be effectively tuned via joint reinforcement learning of instructors and executors using multitask training:
- Section 3 presents a formal analysis of LLP training as an iterated Lewis signalling game (Lewis, 1969). By modeling learning in this game as a dynamical system, we completely characterize a class of simple policies that are subject to semantic drift. We show that a particular multitask training scheme eliminates the set of initializations that undergo semantic drift.
- Section 4 evaluates the empirical effectiveness of multitask learning in a real-time strategy game featuring rich language, complex complex dynamics, and LLPs implemented with deep neural networks. Again, we show that multitask training reduces semantic drift (and improves sample efficiency) of LLPs in multiple game variants.
Together, these results show that diverse shared
goals and communicative needs can facilitate (and specifically stabilize) learning of communication strategies.
Deep reinforcement learning (DRL) has recently made impressive progress on many challenging domains such as games (Mnih et al., 2013a; Silver et al., 2016), locomotion (Schulman et al., 2015) and dexterous manipulation tasks (Gu et al., 2016; Rajeswaran et al., 2017). However, even state-of-the-art approaches to reinforcement struggle with tasks involving complex goals, sparse rewards, and long time horizons. A variety of models and algorithms for hierarchical reinforcement learning have been proposed to address this challenge (Dayan and Hinton, 1993; Dietterich, 2000; Richard et al., 1999; Bacon et al., 2017) via supervised or unsupervised training of a fixed, discrete set of sub-policies.
Language can express arbitrary goals, and has compositional structure that allows generalization across commands. Building on this intuition, several recent papers have explored hierarchical RL in which natural language is used to parameterize the space of high-level actions (Oh et al., 2017; Andreas et al., 2017; Shu et al., 2018; Jiang et al., 2019; Hu et al., 2019). While there are minor implementation differences between all these approaches, we will refer to them collectively as latent language policies (LLPs). Like other hierarchical agents, an LLP consists of a pair of subpolicies: an instructor  $I(m \mid o)$  and an executor  $E(a \mid m, o)$ . An LLP takes actions by first sampling a string-valued message  $m \sim I$  from the instructor, and then an action  $a \sim E$  from the executor. For these messages to correspond to natural language, rather than arbitrary strings, policies need some source of information about what human language users think they mean. This is typically accomplished by pretraining executors via human demonstrations or reinforcement learning; here we focus on the ingredients of effective joint RL of instructors and executors.
Reinforcement learning has been widely used to improve supervised language generation policies, particularly for dialogue (Li et al., 2016; Lewis et al., 2017), translation (Ranzato et al., 2015; Wu et al., 2016) and summarization (Stiennon et al., 2020). Here, we instead focus on models where language is a latent variable as part of a hierarchical policy for a non-linguistic task.
Figure 2: A signaling game with two possible observations, two possible messages, and two possible actions. The instructor observes either a triangle or a square, then sends a message to a executor, who pushes either the red or blue buttons. The players' reward depends on the observation and the action but not the message. Two possible reward functions,  $R$  and  $R'$ , are shown at right.
As noted in Section 1, an observed shortcoming of reinforcement learning in all these settings is its susceptibility to semantic drift. In the literature on human language change (Blank, 1999), semantic drift refers to a variety of phenomena, including specific terms becoming more general, general terms becoming specific, and parts coming to refer to wholes. In machine learning, it refers broadly to the use of messages inconsistent with their natural language meanings in language-generation policies (Lazaridou et al., 2020).
Lee et al. (2019) mitigate semantic drift in pivot-based machine translation by using visual grounding, whereas Lu et al. (2020) periodically update a student model on data generated by an RL teacher. Work in emergent communication has found that reinforcement learning tends not to learn policies with natural language-like properties (Kottur et al., 2017), although population-based training has been found to be helpful (Gupta et al., 2019). Most relatedly to our work, Lazaridou et al. (2020) train speaker-listener agents jointly in a visual referential communication task and introduce auxiliary loss functions for stabilizing training. Our work focuses on a more general setting where the interactions are temporally extended, have large action spaces and is partially observable. Agarwal et al. (2019) use populations of agents to reduce semantic drift in visual dialogue. We view the current paper's analysis of multitask learning as complementary to these approaches from the emergent communication literature; future work might consider ways of combining the two.
A great deal of recent work in both RL (e.g. Jaderberg et al., 2016; Shelhamer et al., 2016) and language processing (e.g. Clark et al., 2019; Gururangan et al., 2020) has observed that carefully designed training objectives can serve as a source of model-agnostic inductive bias. Our results bring these two lines of work together: multitask train
ing improves the faithfulness and adaptability of learned language understanding models, even when optimizing for a downstream reward.
3 Multitask Communication in Theory: Lewis Signaling Games
We begin our analysis with the simple signaling game depicted in Fig. 2. In this game, one agent receives an observation, then sends a message to another agent, which then performs an action. Signaling games like this one are widely studied in NLP as models of reference resolution and language generation (Frank and Goodman, 2012). The instructor-executor pair may together be viewed as the simplest LLP of the kind described in Section 2.
Formally, a (2-observation, 2-message) Lewis signalling game is defined by:
- a set of observations  $O = \{o_1, o_2\}$
- a set of messages  $M = \{m_1, m_2\}$
- a set of actions  $A = \{a_1, a_2\}$
- a reward function  $R: O \times A \to \mathbb{R}$
The game is played between two agents: a instructor (with parameters  $\theta_{I}$ ), which receives an observation and samples an observation-specific message from a distribution  $I(m \mid o; \theta_{I})$ ; and a executor (with parameters  $\theta_{E}$ ), which receives the instructor's message and uses it to sample an action from a distribution  $E(a \mid m; \theta_{E})$ . The agents then receive a reward  $R(o, a)$  that depends on the observation and action but not on the message sent. This policy's expected reward is given by:
$$
\sum_{\substack{o\in O\\ m\in M\\ a\in A}}p(o)I(m  |  o;\theta_{I})E(a  |  m;\theta_{E})R(o,a)  .  (1)
$$
Gradient ascent on Eq. (1) with respect to  $\theta_{I}$  and  $\theta_{E}$  (e.g. using a policy gradient algorithm; Williams, 1992) can be used to improve the expected reward obtained by an LLP.
As an example, the right portion of Fig. 2 shows two reward functions  $R$  and  $R'$ . In both, each observation is paired with a single action, and the executor must take the action corresponding to the observation to receive a positive reward. For  $R$ , two strategies obtain the optimal expected reward of 1: one in which  $I(m_1 \mid \triangle) = 1$  and  $E(\text{red} \mid m_1) = 1$ , and one in which  $I(m_1 \mid \square) = 1$  and  $E(\text{blue} \mid m_1) = 1$ . Almost every initialization of  $\theta_E$  and  $\theta_I$  (excluding a set of pooling equilibria; see e.g. Huttegger et al., 2010) converges to one of these two strategies when agents are jointly trained to optimize Eq. (1).
Semantic drift Suppose, as shown in Fig. 2, the messages  $m_{1}$  and  $m_{2}$  are not arbitrary symbols, but correspond to the natural language expressions  $m_{1} = \text{push red}$  and  $m_{2} = \text{push blue}$ . In this case, only of the policies described above corresponds to the semantics of natural language—namely, the one in which  $E(a_{1} \mid m_{1}) = E(\text{red} \mid \text{push red}) = 1$ . What is needed to ensure that a pair of agents playing converge to the natural language strategy?
In the analysis that follows, we will consider instructor and executor agents (each with a single scalar parameter  $\in [0,1]$ ):
$$
\begin{array}{l} I \left(m _ {j} \mid o _ {i}; \theta_ {I}\right) = \left\{ \begin{array}{l l} \theta_ {I} & i = j \\ 1 - \theta_ {I} & \text {o t h e r w i s e} \end{array} \right. (2) \\ E \left(a _ {j} \mid m _ {i}\right) = \left\{ \begin{array}{l l} \theta_ {E} & i = j \\ 1 - \theta_ {E} & \text {o t h e r w i s e} \end{array} \right. (3) \\ \end{array}
$$
For the game depicted in Fig. 2, we would like to avoid any outcome in which, after training,  $\theta_{E} = E(\text{red} \mid \text{push red}) < \frac{1}{2}$ . More generally, let us assume that we have an initial set of executor parameters that are possibly suboptimal but correspond to natural language semantics in the sense that  $E(a \mid m_i; \theta_E^{(0)}) > \frac{1}{2}$  if and only if the meaning of  $m$  is do  $a$ . In this case, we will say that a parameter initialization  $(\theta_I^{(0)}, \theta_E^{(0)})$  undergoes executor semantic drift if, after training, any such  $E(a \mid m_i; \theta_E) = \theta_E < \frac{1}{2}$ .
To analyze semantic drift in this game, we consider the final values of the parameters  $(\theta_I,\theta_E)$  when optimized from an initialization  $(\theta_I^{(0)},\theta_E^{(0)})$  For the reward function  $R$  depicted in Fig. 2, we can perform gradient ascent on Eq. (1) with respect to  $\theta_{I}$  and  $\theta_{E}$  in this model by observing that:
$$
\frac {\partial J}{\partial \theta_ {I}} = \theta_ {E} - \frac {1}{2} \quad \frac {\partial J}{\partial \theta_ {E}} = \theta_ {I} - \frac {1}{2} \tag {4}
$$
By considering the limiting behavior of gradient ascent as step size goes to zero (a gradient flow; see Appendix A), it is possible to give a closed-form expression for the value of these parameters as a function of time:
Proposition 1. Suppose  $\theta_E^{(0)} + \theta_I^{(0)} < 1$ . Then two agents optimizing Eq. (1) via Eq. (4) undergo semantic drift (converging to  $\theta_E = 0$ ).
Proof is given in Appendix A. Note in particular that semantic drift will occur whenever  $\theta_I^{(0)} < 1 - \theta_E^{(0)}$ , which can occur even assuming a well-initialized executor with  $\theta_E > \frac{1}{2}$ . Fig. 5 in the appendix provides a visualization of learning dynamics and these drift-susceptible initializations. However, we will next show that this drift can be eliminated via multitask training.
Multitask signaling games Consider a multitask version of this game with the two reward functions  $R$  and  $R^{\prime}$  depicted in Fig. 2. As discussed in the introduction and depicted in Fig. 1, our approach to multitask training focuses on sharing a single executor  $E(a\mid m;\theta_{E})$  between multiple task-specific instructors, here  $I(m\mid o;\theta_{I1})$  and  $I(m\mid o;\theta_{I2})$ , both parameterized as in Eq. (2). As above, we train  $(\theta_{I1},\theta_{I2},\theta_E)$  jointly to optimize:
$$
\begin{array}{l} \sum_ {o, m, a} p (o) I (m | o; \theta_ {I 1}) E (a | m; \theta_ {E}) R (o, a) \\ + \sum_ {o, m, a} p (o) I (m | o; \theta_ {I 2}) E (a | m; \theta_ {E}) R ^ {\prime} (o, a) \tag {5} \\ \end{array}
$$
We assume that the two instructors share the same initialization, with  $\theta_{I1}^{(0)} = \theta_{I2}^{(0)} = \theta_I^{(0)}$ . In this case, the following is true:
Proposition 2. Suppose  $\theta_E^{(0)} > \frac{1}{2}$  and  $\theta_{I1}^{(0)} = \theta_{I2}^{(0)}$ . Then three agents optimizing Eq. (5) via its gradient flow do not undergo semantic drift. In fact, the eventual executor parameter  $\theta_E^{(t)}$  is independent of the initial speaker parameters  $\theta_{I1}^{(0)}$  and  $\theta_{I2}^{(0)}$ .
Proof is again given in Appendix A. It is important to emphasize that these results concern the simplest possible policies for the signaling games considered here: agents with a single parameter which already "bake in" the assumption that different signals should trigger different behaviors. We leave generalization of this formal analysis to general signaling games with more complex agents and message spaces for future work, noting that—at least in this simple case—we have succeeded in constructing a concrete multitask objective that
reduces (indeed eliminates) the set of initial model parameters subject to semantic drift.
4 Multitask Communication in Practice: The MiniRTS Environment
We next verify whether this result extends to the complex LLP-learning tasks discussed in Section 2. Our focus in this section is the MINIRTS environment of Hu et al. (2019) (depicted in Fig. 1), in which agents must build and control an army of units like archers, spearmen, swordman, cavalry, and dragons, each with specialized abilities, with the goal of destroying the opponent's town center. Using this game, Hu et al. (2019) crowdsourced a dataset of high-level instructions (like attack with dragon and send idle peasant to mine) paired with low-level action sequences (Fig. 1). They showed that an LLP trained on this supervised data via behavior cloning significantly outperformed a flat policy trained with imitation learning directly on low-level action sequences.
Here we investigate (1) whether these policy-cloned LLP can be further improved via reinforcement learning directly on a sparse win-loss signal from the game, (2) whether we can improve sample efficiency during reinforcement learning by jointly training executor models on multiple game variants simultaneously through multitask learning, and (3) whether semantic drift can be avoided during multi-task training. Below, Section 4.1, Section 4.2 and Section 4.3 provide more detail about the task, model, and training procedure. Section 4.4 reports experimental results.
4.1 Task and Training Data
MINIRTS is a partially-observable real-time strategy game environment, in which the actions of a large number of units must be coordinated on long time scales to defeat an opposing player. In a typical episode, a player must use its initial units to gather resources, use resources to build specialized structures for producing other units, and finally deploy these units to attack the opposing player's base. This involves challenging problems in both low-level tactics (controlling the placement of individual units for resource-gathering and combat) and high-level strategy (deciding which unit types to build, and when to deploy them).
MINIRTS additionally features a dataset collected from pairs of humans playing collaboratively against rule-based opponents. One human, the in
structor, designs high-level strategies and describes them in natural language. The other human, the executor observes the environment state as well as the natural language strategy descriptions from the instructor and selects appropriate low-level actions. The dataset consists of 5,392 games, with a total of 76,045 (instruction, execution) pairs.
Hu et al. (2019) use the labeled data to train an LLP for the MINIRTS environment. Our experiments use the same model architecture (Fig. 3), which we briefly review here; see the original for details.
Observation encoder The instructor and executor models condition on a fixed-sized representation of the current game state which are constructed using different encoders for various aspects of the game state (Fig. 3):
- Spatial input encoder: The spatial information of the map is encoded using a convolutional neural network.
- Non-spatial input encoder: The non-spatial attributes and internal state of game objects are encoded using a simple MLP. These include attributes like the number of enemy units, the agent's units, and resource locations.
- Instruction encoder: The current instruction is encoded with a recurrent neural network.
- Auxiliary encoder: Global variables, such as the total number of resources collected, are additionally encoded with an MLP.
Instructor model The instructor takes in the game state from the observation encoder and produces instructions. The 500 instructions appearing most frequently in the training set are encoded with an RNN into a fixed-sized vector. The score for each instruction is proportional to its dot product with the game state encoding. This instructor model achieved the best performance on several metrics in the original work (Hu et al., 2019). By restricting the instructor to the most frequent 500 well-formed natural language strings, we are able to focus our attention on semantic drift. A generative model free to generate arbitrary strings might also be subject to syntactic drift.
Executor model The executor predicts an action for every unit controlled by the agent based on of the current observation as encoded by the various encoders. The executor then predicts an action
Figure 3: State representations for the MINIRTS environment. The model encodes the spatial observations, non-spatial observations, instructions, and auxiliary information about environment state at each timestep. These features are used by both the instructor and executor models. Reproduced with permission from Hu et al. (2019).
based on these features. In particular, for each unit, it predicts one of the 7 action types (IDLE, CONTINUE, GATHER, ATTACK, TRAIN UNIT, BUILD BUILDING, MOVE), an action target location (for the MOVE, ATTACK, GATHER and BUILD BUILDING actions) and a unit type (for the TRAIN UNIT and BUILD BUILDING actions). Taking the product of the factorized action and location arguments across all units, the action space for the executor can be enormous, with as many as  $10^{24}$  distinct actions available on a single turn.
As mentioned above, the original work of Hu et al. (2019) (and other work on learning LLPs) focused on behavior cloning or independent supervision of the instructor and executor. In the current paper, we are interested in the dynamics of joint reinforcement learning of LLPs in both single- and multitask settings. Experiments in Section 4.4 make use of models trained with all three strategies.
Rule-based opponent pool Agents are trained against a similar pool of rule-based bots (see Hu et al., 2019) used to collect the human data. These bots follow a randomly selected, unit-specific strategy, building a fixed number of SWORDMEN, SPEARMEN, CAVALRY, ARCHERS or DRAGONS and attacking as soon as they are constructed.
Behavior cloning Behavior-cloned models are trained using the supervised MINIRTS dataset. Given a collection of game observations  $o$ , each annotated with a high-level action  $m$  and a low-level action  $a$ , we maximize:
$$
\begin{array}{l} \max _ {\theta_ {I}, \theta_ {E}} \sum_ {o, m, a} \left[ \log I (m \mid o; \theta_ {I}) \right. \\ \left. + \log E (a \mid m, o; \theta_ {E}) \right]. \tag {6} \\ \end{array}
$$