The named concepts and compositional operators present in natural language provide a rich source of information about the abstractions humans use to navigate the world. Can this linguistic background knowledge improve the generality and efficiency of learned classifiers and control policies? This paper aims to show that using the space of natural language strings as a parameter space is an effective way to capture natural task structure. In a pretraining phase, we learn a language interpretation model that transforms inputs (e.g. images) into outputs (e.g. labels) given natural language descriptions. To learn a new concept (e.g. a classifier), we search directly in the space of descriptions to minimize the interpreter's loss on training examples. Crucially, our models do not require language data to learn these concepts: language is used only in pretraining to impose structure on subsequent learning. Results on image classification, text editing, and reinforcement learning show that, in all settings, models with a linguistic parameterization outperform those without. 1 1 Introduction The structure of natural language reflects the structure of the world. For example, the fact that it is easy for humans to communicate the concept left of the circle but comparatively difficult to communicate mean saturation of the first five pixels in the third column reveals something about the abstractions we find useful for interpreting and navigating our environment (Gopnik and Meltzoff, 1987). In machine learning, efficient automatic discovery of reusable abstract structure remains a major challenge. This paper investigates whether 1 Code and data are available at https://github.com/ jacobandreas/l3 . background knowledge from language can provide a useful scaffold for acquiring it. We specifically propose to use language as a latent parameter space for few-shot learning problems of all kinds, including classification, transduction and policy search. We aim to show that this linguistic parameterization produces models that are both more accurate and more interpretable than direct approaches to few-shot learning. Like many recent frameworks for multitask-and meta-learning, our approach consists of three phases: a pretraining phase, a concept-learning phase, and an evaluation phase. Here, the product of pretraining is a language interpretation model that maps from descriptions to predictors (e.g. image classifiers or reinforcement learners). Our thesis is that language learning is a powerful, general-purpose kind of pretraining, even for tasks that do not directly involve language. New concepts are learned by searching directly in the space of natural language strings to mini-2166 ? mize the loss incurred by the language interpretation model (Figure 1). Especially on tasks that require the learner to model high-level compositional structure shared by training examples, natural language hypotheses serve a threefold purpose: they make it easier to discover these compositional concepts, harder to overfit to few examples, and easier for humans to understand inferred patterns. Our approach can be implemented using a standard kit of neural components, and is simple and general. In a variety of settings, we find that the structure imposed by a natural-language parameterization is helpful for efficient learning and exploration. The approach outperforms both multitaskand meta-learning approaches that map directly from training examples to outputs by way of a real-valued parameterization, as well as approaches that make use of natural language annotations as an additional supervisory signal rather than an explicit latent parameter. The natural language concept descriptions inferred by our approach often agree with human annotations when they are correct, and provide an interpretable debugging signal when incorrect. In short, by equipping models with the ability to think out loud when learning, they become both more comprehensible and more accurate. Suppose we wish to solve an image classification problem like the one shown in Figure 2bc, mapping from images x to binary labels y . One straightforward way to do this is to solve a learning problem of the following form: arg min   HX ( x,y ) L ( f ( x ;  ) , y ) , (1) where L is a loss function and f is a richly-parameterized class of models (e.g. convolutional networks) indexed by  (e.g. weight matrices) that map from images to labels. Given a new image x 0 , f ( x 0 ;  ) can be used to predict its label. In the present work, we are particularly interested in few-shot learning problems where the number of ( x, y ) pairs is smallon the order of five or ten examples. Under these conditions, directly solving Equation 1 is a risky proposition any model class powerful enough to capture the true relation between inputs and outputs is also likely to overfit. For few-shot learning to be successful, extra structure must be supplied to the learner. Existing approaches obtain this structure by either carefully structuring the hypothesis space or providing the learner with alternative training data. The approach we present in this paper combines elements of both, so we begin with a review of existing work. (Inductive) program synthesis approaches (e.g. Gulwani, 2011) reduce the effective size of the hypothesis class H by moving the optimization problem out of the continuous space of weight vectors and into a discrete space of formal program descriptors (e.g. regular expressions or Pro-log queries). Domain-specific structure like version space algebras (Lau et al., 2003) or type systems (Kitzelmann and Schmid, 2006) can be brought to bear on the search problem, and the bias inherent in the syntax of the formal language provides a strong prior. But while program synthesis techniques are powerful, they are also limited in their application: a human designer must hand-engineer the computational primitives necessary to compactly describe every learnable hypothesis. While reasonable for some applications (like string editing), this is challenging or impossible for others (like computer vision). An alternative class of multitask learning approaches (Caruana, 1998) import the relevant structure from other learning problems rather than defining it manually (Figure 2a, top). Since we may not know a priori what set of learning problems we ultimately wish to evaluate on, it is useful to think of learning as taking places in three phases: 2167 1. a pretraining (or meta-training) phase that makes use of various different datasets i with examples { ( x ( i ) 1 , y ( i ) 1 ) , . . . , ( x ( i ) n , y ( i ) n ) } (Figure 2a) 2. a concept-learning phase in which the pretrained model is adapted to fit data { ( x ( c ) 1 , y ( c ) 1 ) , . . . , ( x ( c ) n , y ( c ) n ) } for a specific new task (Figure 2b) 3. an evaluation phase in which the learned concept is applied to a new input x ( e ) to predict y ( e ) (Figure 2c) In these approaches, learning operates over two collections of parameters: shared parameters  and task-specific parameters  . In pretraining, multitask approaches find: arg min   R a ,  ( i )  R b X i,j L (cid:0) f ( x ( i ) j ; ,  ( i ) ) , y ( i ) j (cid:1) . (2) At concept learning time, they solve for: arg min  ( c )  R b X j L (cid:0) f ( x ( c ) j ; ,  ( c ) ) , y ( c ) j (cid:1) (3) on the new dataset, then make predictions for new inputs using f ( x ( e ) ; ,  ( c ) ) . Closely related meta-learning approaches (e.g. Schmidhuber, 1987; Santoro et al., 2016; Vinyals et al., 2016) make use of the same data, but collapse the inner optimization over  ( c ) and prediction of y ( e ) into a single learned model. 3 Learning with Language In this work, we are interested in developing a learning method that enjoys the benefits of both approaches. In particular, we seek an intermediate language of task representations that, like in program synthesis, is both expressive and compact, but like in multitask approaches is learnable directly from training data without domain engineering. We propose to use natural language as this intermediate representation. We call our approach learning with latent language (L 3 ). Natural language shares many structural advantages with the formal languages used in synthesis approaches: it is discrete, has a rich set of compositional operators, and comes equipped with a natural description length prior. But it also has a considerably more flexible semantics. And crucially, plentiful annotated data exists for learning this semantics: we cannot hand-write a computer program to recognize a small dog , but we can learn how to do it from image captions. More basically, the set of primitive operators available in language provides a strong prior about the kinds of abstractions that are useful for natural learning problems. Concretely, we replace the pretraining phase above with a language-learning phase. We assume that at language-learning time we have access to natural-language descriptions w ( i ) (Fig-ure 2a, bottom). We use these w as parameters , in place of the task-specific parameters  that is, we learn a language interpretation model f ( x ; , w ) that uses shared parameters  to turn a description w into a function from inputs to outputs. For the example in Figure 2, f might be an image rating model (Socher et al., 2014) that outputs a scalar judgment y of how well an image x matches a caption w . Because these natural language parameters are observed at language-learning time, we need only learn the real-valued shared parameters  used for their interpretation (e.g. the weights of a neural network that implements the image rating model): arg min   R a X i,j L (cid:0) f ( x ( i ) j ; , w ( i ) ) , y ( i ) j (cid:1) . (4) At concept-learning time, conversely, we solve only the part of the optimization problem over natural language strings: arg min w ( c )    X j L (cid:0) f ( x ( c ) j ; , w ( c ) ) , y ( c ) j (cid:1) . (5) This last step presents something of a challenge. When solving the corresponding optimization problem, synthesis techniques can exploit the algebraic structure of the formal language, while end-to-end learning approaches take advantage of differentiability. Here we can't do eitherthe language of strings is discrete, and any structure in the interpretation function is wrapped up inside the black box of f . Inspired by related techniques aimed at making synthesis more efficient (Devlin et al., 2017), we use learning to help us develop an effective optimization procedure for natural language parameters. In particular, we simply use the language-learning datasets, consisting of pairs ( x ( i ) j , y ( i ) j ) and descriptions w i , to fit a reverse proposal model, estimating: arg max  P i log q ( w i | x ( i ) 1 , y ( i ) 1 , . . . , x ( i ) n , y ( i ) n ;  ) 2168 true a white shape is left of a yellow semicircle true true true true Figure 3: The few-shot image classification task. where q provides a (suitably normalized) approximation to the distribution of descriptions given task data. In the running example, this proposal distribution is essentially an image captioning model (Donahue et al., 2015). By sampling from q , we expect to obtain candidate descriptions that are likely to obtain small loss. But our ultimate inference criterion is still the true model f : at evaluation time we perform the minimization in Equation 5 by drawing a fixed number of samples, selecting the hypothesis w ( c ) that obtains the lowest loss, and using f ( x ( e ) ; , w ( c ) ) to make predictions. What we have described so far is a generic procedure for equipping collections of related learning problems with a natural language hypothesis space. In Sections 4 and 5, we describe how this procedure can be turned into a concrete algorithm for supervised classification and sequence prediction. In Section 6, we describe how to extend these techniques to reinforcement learning. We begin by investigating whether natural language can be used to support high-dimensional few-shot classification. Our focus is on visual reasoning tasks like the one shown in Figure 3. In these problems, the learner is presented with four images, all positive examples of some visual concept like a blue shape near a yellow triangle , and must decide whether a fifth, held-out image matches the same concept. These kinds of reasoning problems have been well-studied in visual question answering settings (Johnson et al., 2017; Suhr et al., 2017). Our version of the problem, where the input and output feature no text data, but an explanation must be inferred, is similar to the visual reasoning problems proposed by Raven (1936) and Bongard (1968). To apply the recipe in Section 2, we need to specify an implementation of the interpretation model f and the proposal model q . We begin by computing representations of input images x . We start with a pre-trained 16-layer VGGNet (Si-monyan and Zisserman, 2014). Because spatial information is important for these tasks, we extract a feature representation from the final convolutional layer of the network. This initial featurization is passed through two fully-connected layers to form a final image representation, as follows: x VGG-16 FC ReLU FC rep( ) x We define interpretation and proposal models: 2 f ( x ; w ) =  (cid:0) rnn-encode ( w ) > rep ( x ) (cid:1) q ( w | { x j } ) = rnn-decode (cid:0) w | 1 n P j rep ( x j ) (cid:1) The interpretation model f outputs the probability that x is assigned a positive class label, and is trained to maximize log-likelihood. Because only positive examples are provided in each language learning set, the proposal model q can be defined in terms of inputs alone. Details regarding training hyperparameters, RNN implementations, etc. may be found in Appendix A. Our evaluation aims to answer two questions. First, does the addition of language to the learning process provide any benefit over ordinary multitask or meta-learning? Second, is it specifically better to use language as a hypothesis space for concept learning rather than just an additional signal for pretraining? We use several baselines to answer these questions: 1. Multitask : a multitask baseline in which the definition of f above is replaced by  (  > i rep ( x )) for task-specific parameters  i that are optimized during both pretraining and concept-learning. 2. Meta : a meta-learning baseline in which f is defined by  ([ 1 n P j rep ( x j )] > rep ( x )) . 3 2 Suppressing shared parameters  and  for clarity. 3 Many state-of-the-art approaches to meta-learning for classification (e.g. Snell et al., 2017) are not well-defined for possibly-overlapping evaluation classes with only positive examples provideded. Here we have attempted to provide a robust implementation that is as close as possible to the other systems under evaluation. 3. Meta+Joint : as in Meta , but the pretraining objective includes an additional term for predicting q (discarded for concept learning). We report results on a dataset derived from the ShapeWorld corpus of Kuhnle and Copestake (2017). In this dataset the held-out image matches the target concept 50% of the time. In the validation and test folds, half of learning problems feature a concept that also appears in the language learning set (but with different exemplar images), while the other half feature both new images and a new concept. Images contain two or three dis-tractor shapes unrelated to the objects that define the target concept. Captions in this dataset were generated from DMRS representations using an HPS grammar (Copestake et al., 2016). (Our remaining experiments use human annotators.) The dataset contains a total of 9000 pretraining tasks and 1000 of each validation and test tasks. More dataset statistics are provided in Appendix B. Results are shown in Table 1. It can be seen that L 3 provides consistent improvements over the baselines, and that these improvements are present both when identifying new instances of previously-learned concepts and when discovering new ones. Some example model predictions are shown in Figure 4. The model often succeeds in making correct predictions, even though its inferred descriptions rarely match the ground truth. Sometimes this is because of inherent ambiguity in the description language (Figure 4a), and sometimes because the model is able to rule out candidates on the basis of partial captions alone (Fig-ure 4b, where it is sufficient to recognize that the Model Val (old) Val (new) Val Test Random 50 50 50 50 Multitask 64 49 57 59 Meta 63 62 62 64 Meta+Joint 63 69 66 64 L 3 (ours) 70 72 71 70 L 3 (oracle) 77 80 79 78 Table 1: Evaluation on image classification. target concept involves a circle ). More examples are provided in Appendix C. 5 Programming by Demonstration Next we explore whether the same technique can be applied to tasks that involve more than binary similarity judgments. We focus on structured prediction: specifically a family of string processing tasks. In these tasks, the model is presented with examples of five strings transformed according to some rule; it must then apply an appropriate transformation to a sixth (Figure 5). Learning proceeds as in the previous section, with: rep ( x, y ) = rnn-encode ([ x, y ]) f ( y | x ; w ) = rnn-decode (cid:0) y | [ rnn-encode ( x ) , rnn-encode ( w )] (cid:1) q ( w | { ( x j , y j ) } ) = rnn-decode (cid:0) w | 1 n P j rep ( x j , y j ) (cid:1) Baselines are analogous to those for classification. While string editing tasks of the kind shown in Figure 5 are popular in both the programming by demonstration literature (Singh and Gulwani, 2012) and the semantic parsing literature (Kush-man and Barzilay, 2013), we are unaware of any datasets that support both learning paradigms at the same time. We have thus created a new dataset of string editing tasks by (1) sampling random regular transducers, (2) applying these transducers to collections of dictionary words, and (3) showing the collected examples to Mechanical Turk users a blue cross is above a pentagon a cyan pentagon is to the right of a magenta shape false true (c) examples true description true label pred. label a square is above a red cross a red cross is below a square true true a circle is above a yellow circle a cyan circle is to the left of a rectangle false false Figure 4: Example predictions for image classification. The model achieves high accuracy even though predicted descriptions rarely match the ground truth. High-level structure like the presence of certain shapes or spatial relations is consistently recovered. and asking them to provide a natural language explanation with their best guess about the underlying rule. The dataset thus features both multi-example learning problems, as well as structured and unstructured annotations for each target concept. There are 3000 tasks for language learning and 500 tasks for each of validation and testing (Appendix B). Annotations are included in the code release for this paper. Results are shown in Table 2. In these experiments, all models that use descriptions have been trained on the natural language supplied by human annotators. While we did find that the Meta+Joint model converges considerably faster than all the others, its final performance is somewhat lower than the baseline Meta model. As before, L 3 outperforms alternative approaches for learning directly from examples with or without descriptions. Because all of the transduction rules in this dataset were generated from known formal descriptors, these tasks provide an opportunity to perform additional analysis comparing natural language to more structured forms of annotation (since we have access to ground-truth regular expressions) and more conventional synthesis-based methods (since we have access to a ground-truth regular expression execution engine). We additionally investigate the effect of the number of warding curved uranium pedaled drum warying curved uranium peyaled drum replace d before a vowel with y s/d([aeiou])/y\1/g chided chiyed Figure 5: Example string editing task. plummest bereaving eddied plummesti bereavinti eddieti replace the last letter of the word with t i mistrials Figure 6: Example predictions for string editing. samples drawn from the proposal model. These results are shown in Table 3. A few interesting facts stand out. Under the ordinary evaluation condition (with no ground-truth annotations provided), language-learning with natural language data is actually better than language-learning with regular expressions. This might be because the extra diversity helps the model determine the relevant axes of variation and avoid overfitting to individual strings. Allowing the model to do its own inference is also better than providing ground-truth natural language descriptions, suggesting that it is actually better at generalizing from the relevant concepts than our human annotators (who occasionally write things like I have no idea for the inferred rule). Unsurprisingly, with ground truth REs (which unlike the human data are always correct) we can do better than any of the models that require inference. Coupling our inference procedure with an oracle RE evaluator, we essentially recover the synthesis-based approach of Devlin et al. (2017). Our find-ings are consistent with theirs: when an exact execution engine is available, there is no reason not to use it. But we can get almost 90% of the way there Annotations Samples Oracle 1 100 Ann. The previous two sections examined supervised settings where the learning signal comes from few examples but is readily accessible. In this section, we move to a set of reinforcement learning problems, where the learning signal is instead sparse and time-consuming to obtain. We evaluate on a collection of 2-D treasure hunting tasks. These tasks require the agent to discover a rule that determines the location of buried treasure in a large collection of environments of the kind shown in Figure 7. To recover the treasure, the agent must navigate (while avoiding water) to its goal location, then perform a DIG action. At this point the episode ends; if the treasure is located in the agent's current position, it receives a reward, otherwise it does not. In every task, the treasure has consistently been buried at a fixed position relative to some landmark (in Figure 7 a heart). Both the offset and the identity of the target landmark are unknown to the agent, and the location of the landmark varies across maps. Indeed, there is nothing about the agent's observations or action space to suggest that landmarks and offsets are even the relevant axes of variation across tasks: only the language reveals this structure. The interaction between language and learning in these tasks is rather different from the supervised settings. In the supervised case, language serves mostly as a guard against overfitting, and Figure 7: Example treasure hunting task: the agent is placed in a random environment and must collect a reward that has been hidden at a consistent offset with respect to some landmark. can be generated conditioned on a set of preprovided concept-learning observations. Here, agents are free to interact with the environment as much as they need, but receive observations only during interaction. Thus our goal here will be to build agents that can adapt quickly to new environments, rather than requiring them to immediately perform well on held-out data. Why should we expect L 3 to help in this setting? In reinforcement learning, we typically encourage our models to explore by injecting randomness into either the agent's action space or its underlying parameterization. But most random policies exhibit nonsensical behaviors; as a result, it is in-efficient both to sample in the space of network weights and to perform policy optimization from a random starting point. Our hope is that when parameters are chosen from within a structured family, a stochastic search in this structured space will only ever consider behaviors corresponding to a reasonable final policy, and in this way discover good behavior faster than ordinary RL. Here the interpretation model f describes a policy that chooses actions conditioned on the current environment state and a linguistic parameterization. As the agent initially has no observations at all, we simply design the proposal model to generate unconditional samples from a prior over descriptions. Taking x to be an agent's current observation of the environment state, we define a state representation network and models: x FC tanh FC rep( ) x tanh f ( a | x ; w )  rnn-encode ( w ) > W a rep ( x ) q ( w ) = rnn-decode ( w ) This parameterization assumes a discrete action space, and assigns to each action a probability proportional to a bilinear function of the encoded description and world state. f is an instruction following model of a kind well-studied in natural language processing (Branavan et al., 2009); the proposal model allows it to generate its own instructions without external direction. To learn, we sample a fixed number of descriptions w from q . For each description, we sample multiple rollouts of the policy it induces to obtain an estimate of its average reward. Finally, we take the highest-scoring description and fine-tune its induced policy. The multitask model we compare to replaces these descriptions with trainable task embeddings. 4 The learner is trained from task-specific expert policies using DAgger (Ross et al., 2011) during the language-learning phase, and adapts to individual environments using vanilla policy gradient (Williams, 1992) during the concept learning phase. The environment implementation and linguistic annotations are in this case adapted from a natural language navigation dataset originally introduced by Janner et al. (2017). In our version of the problem (Figure 7), the agent begins each episode in a random position on a randomly-chosen map and must attempt to obtain the treasure. Relational concepts describing target locations are reused between language learning and concept-learning phases, but the environments themselves are distinct. For language learning the agent has access to 250 tasks, and is evaluated on an additional 50. Averaged learning curves for held-out tasks are shown in Figure 8. As expected, reward for the L 3 model remains low during the initial exploration period, but once a description is chosen the score 4 In RL, the contribution of L 3 is orthogonal to that of meta-learningone could use a technique like RL 2 (Duan et al., 2016) to generate candidate descriptions more efficiently, or MAML (Finn et al., 2017) rather than zero-shot reward as the training criterion for the interpretation model. improves rapidly. Immediately L 3 achieves better reward than the multitask baseline, though it is not perfect; this suggests that the interpretation model is somewhat overfit to the pretraining environments. After fine-tuning even better results are rapidly obtained. Example rollouts are visualized in Appendix E. These results show that the model has used the structure provided by language to learn a better representation space for policies one that facilitates sampling from a distribution over interesting and meaningful behaviors. This is the first approach we are aware of to frame a general learning problem as optimization over a space of natural language strings. However, many closely related ideas have been explored in the literature. String-valued latent variables are widely used in language processing tasks ranging from morphological analysis (Dreyer and Eisner, 2009) to sentence compression (Miao and Blunsom, 2016). Natural language annotations have been used in conjunction with training examples to guide the discovery of logical descriptions of concepts (Ling et al., 2017; Srivastava et al., 2017), and used as an auxiliary loss for training (Frome et al., 2013), analogously to the Meta+Joint baseline in this paper. Structured language-like annotations have been used to improve learning of generalizable structured policies (Oh et al., 2017; Andreas et al., 2017; Denil et al., 2017). Finally, natural language instructions available at concept-learning time (rather than language-learning time) have been used to provide side information to reinforcement learners about high-level strategy (Branavan et al., 2011), environments (Narasimhan et al., 2017) and exploration (Harrison et al., 2017). We have presented an approach for learning in a space parameterized by natural language. Using simple models for representation and search in this space, we demonstrated that our approach outperforms standard baselines on classification, structured prediction and reinforcement learning tasks. We believe that these results suggest the following general conclusions: Language encourages compositional generalization . Standard deep learning architectures are good at recognizing new instances of familiar 2173 concepts, but not always at generalizing to new ones. By forcing decisions to pass through a linguistic bottleneck in which the underlying compositional structure of concepts is explicitly expressed, stronger generalization becomes possible. Language simplifies structured exploration . Natural language scaffolding provides dramatic advantages in problems like reinforcement learning that require exploration: models with latent linguistic parameterizations can limit exploration to a class of behaviors that are likely a priori to be goal-directed and interpretable. And generally, language can help learning . In multitask settings, it can even improve learning on tasks for which no language data is available at training or test time. While some of these advantages are also provided by techniques built on top of formal languages, natural language is at once more expressive and easier to obtain than formal supervision. We believe this work hints at broader opportunities for using naturally-occurring language data to improve machine learning for tasks of all kinds. JA is supported by a Facebook graduate fellowship.
abstain abstain objective method objective method abstain abstain objective abstain other abstain objective objective abstain abstain objective abstain abstain abstain method result abstain method abstain objective other other abstain other other other method other other other other other other abstain method other other abstain abstain abstain abstain objective abstain abstain abstain abstain method method method method method abstain abstain abstain abstain method abstain abstain abstain method abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain other abstain abstain method abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain method method abstain method abstain method method abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain objective other other method other other method objective result abstain abstain abstain abstain abstain abstain abstain result other