SlowGuess/ACL_2020_OCR huggingface dataset:
Rahma Chaabouni $^{1,2}$ , Eugene Kharitonov $^{1}$ , Diane Bouchacourt $^{1}$ , Emmanuel Dupoux $^{1,2}$ , and Marco Baroni $^{1,3}$
$^{1}$ Facebook AI Research
$^{2}$ Cognitive Machine Learning (ENS - EHESS - PSL Research University - CNRS - INRIA)  $^{3}$ ICREA
{rchaabouni, kharitonov, dianeb, dpx, mbaroni}@fb.com
Natural language allows us to refer to novel composite concepts by combining expressions denoting their parts according to systematic rules, a property known as compositionality. In this paper, we study whether the language emerging in deep multi-agent simulations possesses a similar ability to refer to novel primitive combinations, and whether it accomplishes this feat by strategies akin to human-language compositionality. Equipped with new ways to measure compositionality in emergent languages inspired by disentanglement in representation learning, we establish three main results. First, given sufficiently large input spaces, the emergent language will naturally develop the ability to refer to novel composite concepts. Second, there is no correlation between the degree of compositionality of an emergent language and its ability to generalize. Third, while compositionality is not necessary for generalization, it provides an advantage in terms of language transmission: The more compositional a language is, the more easily it will be picked up by new learners, even when the latter differ in architecture from the original agents. We conclude that compositionality does not arise from simple generalization pressure, but if an emergent language does chance upon it, it will be more likely to survive and thrive.
Most concepts we need to express are composite in some way. Language gives us the prodigious ability to assemble messages referring to novel composite concepts by systematically combining expressions denoting their parts. As interest raises in developing deep neural agents evolving a communication code to better accomplish cooperative tasks, the question arises of how the emergent code can be
endowed with the same desirable compositionality property (Kottur et al., 2017; Lazaridou et al., 2018; Mordatch and Abbeel, 2018; Cogswell et al., 2019; Li and Bowling, 2019). This in turn requires measures of how compositional an emergent language is (Andreas, 2019). Compositionality is a core notion in linguistics (Partee, 2004), but linguists' definitions assume full knowledge of primitive expressions and their combination rules, which we lack when analyzing emergent languages (Nefdt, 2020). Also, these definitions are categorical, whereas to compare emergent languages we need to quantify degrees of compositionality.
Some researchers equate compositionality with the ability to correctly refer to unseen composite inputs (e.g., Kottur et al., 2017; Cogswell et al., 2019). This approach measures the generalization ability of a language, but it does not provide any insights on how this ability comes about. Indeed, one of our main results below is that emergent languages can attain perfect generalization without abiding to intuitive notions of compositionality.
Topographic similarity has become the standard way to quantify the compositionality of emergent languages (e.g., Brighton and Kirby, 2006; Lazari-dou et al., 2018; Li and Bowling, 2019). This metric measures whether the distance between two meanings correlates with the distance between the messages expressing them. While more informative than generalization, topographic similarity is still rather agnostic about the nature of composition. For example, when using, as is standard practice, Levenshtein distance to measure message distance, an emergent language transparently concatenating symbols in a fixed order and one mixing deletion and insertion operations on free-ordered symbols can have the same topographic similarity.
We introduce here two more "opinionated" measures of compositionality that capture some intuitive properties of what we would expect to hap-
*Contributed equally.
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 4427-4442 July 5 - 10, 2020. ©2020 Association for Computational Linguistics
pen in a compositional emergent language. One possibility we consider is that order-independent juxtapositions of primitive forms could denote the corresponding union of meanings, as in English noun conjunctions: cats and dogs, dogs and cats. The second still relies on juxtaposition, but exploits order to denote different classes of meanings, as in English adjective-noun phrases: red triangle, blue square. Both strategies result in disentangled messages, where each primitive symbol (or symbol+position pair) univocally refers to a distinct primitive meaning independently of context. We consequently take inspiration from work on disentanglement in representation learning (Suter et al., 2019) to craft measures that quantify whether an emergent language follows one of the proposed composition strategies.
Equipped with these metrics, we proceed to ask the following questions. First, are neural agents able to generalize to unseen input combinations in a simple communication game? We find that generalizing languages reliably emerge when the input domain is sufficiently large. This somewhat expected result is important nevertheless, as failure-to-generalize claims in the recent literature are often based on very small input spaces. Second, we unveil a complex interplay between compositionality and generalization. On the one hand, there is no correlation between our compositionality metrics and the ability to generalize, as emergent languages successfully refer to novel composite concepts in inscrutably entangled ways. (Order-dependent) compositionality, however, if not necessary, turns out to be a sufficient condition for generalization. Finally, more compositional languages are easier to learn for new agents, including agents that are architecturally different from the ones that evolved the language. This suggests that, while composition might not be a "natural" outcome of the need to generalize, it is a highly desirable one, as compositional languages will more easily be adopted by a large community of different agents. We return to the implications of our findings in the discussion.
2.1 The game
We designed a variant of Lewis' signaling game (Lewis, 1969). The game proceeds as follows:
1. Sender network receives one input  $i$  and chooses a sequence of symbols from its vo
cabulary  $V = \{s_1,s_2\dots ,s_{c_{voc}}\}$  of size  $c_{voc}$  to construct a message  $m$  of fixed length  $c_{len}$ .
2. Receiver network consumes  $m$  and outputs  $\hat{\pmb{i}}$ .
3. Agents are successful if  $\hat{\pmb{i}} = \pmb{i}$ , that is, Receiver reconstructs Sender's input.
Each input  $i$  of the reconstruction game is comprised of  $i_{att}$  attributes, each with  $i_{val}$  possible values. We let  $i_{att}$  range from 2 to 4 and  $i_{val}$  from 4 to 100. We represent each attribute as a  $i_{val}$  one-hot vector. An input  $i$  is given by the concatenation of its attributes. For a given  $(i_{att}, i_{val})$ , the number of input samples  $|I| = i_{val}^{i_{att}}$ .
This environment, which can be seen as an extension of that of Kottur et al. (2017), is one of the simplest possible settings to study the emergence of reference to composite concepts (here, combinations of multiple attributes). Attributes can be seen as describing object properties such as color and shape, with their values specifying those properties for particular objects (red, round). Alternatively, they could be seen as slots in an abstract semantic tree (e.g., agent and action), with the values specifying their fillers (e.g., dog, barking). In the name of maximally simplifying the setup and easing interpretability, unlike Kottur et al. (2017), we consider a single-step game. We moreover focus on input reconstruction instead of discrimination of a target input among distractors as the latter option adds furtherx complications: for example, languages in that setup have been shown to be sensitive to the number and distribution of the distractors (Lazaridou et al., 2018).
For a fixed  $|I|$ , we endow Sender with large enough channel capacity  $|C| = c_{\text{voc}}^{c_{len}}$  ( $c_{\text{voc}} \in \{5, 10, 50, 100\}$  and  $c_{len} \in \{3, 4, 6, 8\}$ ) to express the whole input space (i.e.,  $|C| \geq |I|$ ). Unless explicitly mentioned, we run 10 different initializations per setting. See Appendix 8.1 for details about the range of tested settings. The game is implemented in EGG (Kharitonov et al., 2019).
2.2 Agent architecture
Both agents are implemented as single-layer GRU cells (Cho et al., 2014) with hidden states of size 500. Sender encodes  $i$  in a message  $m$  of fixed
1Code can be found at https://github.com/ facebookresearch/EGG/tree/master/egg/ zoo/compo_vs_generalization.
<sup>2</sup>Experiments with GRUs of different capacity are reported in the Appendix. We also informally replicated our main
4428
length  $c_{len}$  as follows. First, a linear layer maps the input vector into the initial hidden state of Sender. Next, the message is generated symbol-by-symbol by sampling from a Categorical distribution over the vocabulary  $c_{voc}$ , parameterized by a linear mapping from Sender's hidden state. The generated symbols are fed back to the cell. At test time, instead of sampling, symbols are selected greedily.
Receiver consumes the entire message  $m$ . Further, we pass its hidden state through a linear layer and consider the resulting vector as a concatenation of  $i_{att}$  probability vectors over  $i_{val}$  values each. As a loss, we use the average cross-entropy between these distributions and Sender's input.
Popular approaches for training with discrete communication include Gumbel-Softmax (Maddison et al., 2016; Jang et al., 2016), REINFORCE (Williams, 1992), and a hybrid in which the Receiver gradients are calculated via backpropagation and those of Sender via REINFORCE (Schulman et al., 2015). We use the latter, as recent work (e.g., Chaabouni et al., 2019) found it to converge more robustly. We apply standard tricks to improve convergence: (a) running mean baseline to reduce the variance of the gradient estimates (Williams, 1992), and (b) a term in the loss that favors higher entropy of Sender's output, thus promoting exploration. The obtained gradients are passed to the Adam optimizer (Kingma and Ba, 2014) with learning rate 0.001.
3 Measurements
Topographic similarity (topsim) (Brighton and Kirby, 2006) is commonly used in language emergence studies as a quantitative proxy for compositionality (e.g., Lazaridou et al., 2018; Li and Bowling, 2019). Given a distance function in the input space (in our case, attribute value overlap, as attributes are unordered, and values categorical) and a distance function in message space (in our case, following standard practice, minimum edit distance between messages), topsim is the (Spearman) correlation between pairwise input distances and the corresponding message distances. The measure can detect a tendency for messages with similar meanings to be similar in form, but it is relatively
agnostic about the type of similarity (as long as it is captured by minimum edit distance).
We complement topsim with two measures that probe for more specific types of compositionality, that we believe capture what deep-agent emergent-language researchers seek for, when interested in compositional languages. In most scenarios currently considered in this line of research, the composite inputs agents must refer to are sets or sequences of primitive elements: for example, the values of a set of attributes, as in our experiment. In this restricted setup, a compositional language is a language where symbols independently referring to primitive input elements can be juxtaposed to jointly refer to the input ensembles. Consider a language with a symbol  $r$  referring to input element color:red and another symbol  $l$  referring to weight:light, where  $r$  and  $l$  can be juxtaposed (possibly, in accordance with the syntactic rules of the language) to refer to the input set {color:red, weight:light}. This language is intuitively compositional. On the other hand, a language where both  $r$  and  $l$  refer to these two input elements, but only when used together, whereas other symbol combinations would refer to color:red and weight:light in other contexts, is intuitively not compositional. Natural languages support forms of compositionality beyond the simple juxtaposition of context-independent symbols to denote ensembles of input elements we are considering here (e.g., constructions that denote the application of functions to arguments). However, we believe that the proposed intuition is adequate for the current state of affairs in language emergence research.
The view of compositionality we just sketched is closely related to the idea of disentanglement in representation learning. Disentangled representations are expected to enable a consequent model to generalize on new domains and tasks (Bengio et al., 2013). Even if this claim has been challenged (Bozkurt et al., 2019; Locatello et al., 2019), several interesting metrics have been proposed to quantify disentanglement, as reviewed in Suter et al. (2019). We build in particular upon the Information Gap disentanglement measure of Chen et al. (2018), evaluating how well representations capture independence in the input sets.
Our positional disentanglement (posdis) metric measures whether symbols in specific positions tend to univocally refer to the values of a specific attribute. This order-dependent strategy is com
results with LSTMs, that were slower to converge. We were unable to adapt Transformers to successfully play our game.
4429
monly encountered in natural language structures (and it is a pre-condition for sophisticated syntactic structures to emerge). Consider English adjective-noun phrases with a fully intersective interpretation, such as yellow triangle. Here, the words in the first slot will refer to adjectival meanings, those in the second to nominal meanings. In our simple environment, it might be the case that the first symbol is used to discriminate among values of an attribute, and the second to discriminate among values of another attribute. Let's denote  $s_j$  the  $j$ -th symbol of a message and  $a_1^j$  the attribute that has the highest mutual information with  $s_j$ :  $a_1^j = \arg \max_a \mathcal{I}(s_j; a)$ . In turn,  $a_2^j$  is the second highest informative attribute,  $a_2^j = \arg \max_{a \neq a_1^j} \mathcal{I}(s_j; a)$ . Denoting  $\mathcal{H}(s_j)$  the entropy of  $j$ -th position (used as a normalizing term), we define posdis as:
$$
p o s d i s = 1 / c _ {l e n} \sum_ {j = 1} ^ {c _ {l e n}} \frac {\mathcal {I} (s _ {j} ; a _ {1} ^ {j}) - \mathcal {I} (s _ {j} ; a _ {2} ^ {j})}{\mathcal {H} (s _ {j})} (1)
$$
We ignore positions with zero entropy. Eq. 1 captures the intuition that, for a language to be compositional given our inputs, each position of the message should only be informative about a single attribute. However, unlike the related measure proposed by Resnick et al. (2019), it does not require knowing which set of positions encodes a particular attribute, which makes it computationally simpler (only linear in  $c_{len}$ ).
Posdis assumes that a language uses positional information to disambiguate symbols. However, we can easily imagine a language where symbols univocally refer to distinct input elements independently of where they occur, making order irrelevant.<sup>3</sup> Hence, we also introduce bag-of-symbols disentanglement (bosdis). The latter maintains the requirement for symbols to univocally refer to distinct meanings, but captures the intuition of a permutation-invariant language, where only symbol counts are informative. Denoting by  $n_j$  a counter of the  $j$ -th symbol in a message, bosdis is given by:
$$
b o s d i s = 1 / c _ {v o c} \sum_ {j = 1} ^ {c _ {v o c}} \frac {\mathcal {I} (n _ {j} ; a _ {1} ^ {j}) - \mathcal {I} (n _ {j} ; a _ {2} ^ {j})}{\mathcal {H} (n _ {j})} (2)
$$
In all experiments, the proposed measures topsim, posdis and bosdis are calculated on the train set.
In Appendix 8.2, we illustrate how the three metrics behave differently on three miniature languages. Across the languages of all converging runs in our simulations, their Spearman correlations are: topsim/posdis: 0.08; topsim/bosdis: 0.38; posdis/bosdis: 0.31. These correlations, while not extremely high, are statistically significant  $(p < 0.01)$ , which is reassuring as all metrics attempt to capture compositionality. It is also in line with reasonable expectations that the most "opinionated" posdis measure is the one that behaves most differently from topsim.
In our setup, generalization can be straightforwardly measured by splitting all possible distinct inputs so that the test set only contains inputs with attribute combinations that were not observed at training. Generalization is then simply quantified by test accuracy. In intuitive terms, at training time the agents are exposed to blue triangles and red circles, but blue circles only appear at test time. This requires Sender to generate new messages, and Receiver to correctly infer their meaning. If a blue circle is accurately reconstructed, then agents do generalize.
For all the considered settings, we split the possible distinct inputs into  $90\%$  train and  $10\%$  test items. This implies that the absolute training/test set sizes increase with input dimension (this issue is further discussed in Appendix 8.4).
Finally, we only evaluate generalization for runs that successfully converged, where convergence is operationalized as  $>99.9\%$  training-set accuracy.
4 Generalization emerges "naturally" if the input space is large
Fig. 1 shows that emergent languages are able to almost perfectly generalize to unseen combinations as long as input size  $|I|$  is sufficiently large (input size/test accuracy Spearman  $\rho = 0.86$ ,  $p \approx 0$ ). The figure also shows that the way in which a large input space is obtained (manipulating  $i_{att}$  or  $i_{val}$ ) does not matter (no significant accuracy difference between the bracketed runs, according to a set of t-tests with  $p > 0.01$ ). Moreover, the correlation is robust to varying agents' capacity (Appendix 8.3; see Resnick et al. (2019) for a thorough study of how agent capacity impacts generalization and compositionality). Importantly, the effect is not simply a product of larger input sizes coming with
3This is not unlike what happens in order-insensitive constructions such as English conjunctions: dogs and cats, cats and dogs.
Figure 1: Average accuracy on unseen combinations as a function of input size of successful runs. The x-axis is ordered by increasing input size  $|I|$ . Brackets denote  $(i_{att}, i_{val})$ . Vertical bars represent the standard error of the mean (SEM). Horizontal brackets group settings with same  $|I|$  but different  $(i_{att}, i_{val})$ .
larger training corpora, as we replicate it in Appendix 8.4 while keeping the number of distinct training examples fixed, but varying input combinatorial variety. What matters is that, in the training data, specific attribute values tend to occur with a large range of values from other attributes, providing a cue about the composite nature of the input.
That languages capable to generalize will only emerge when the input is varied enough might seem obvious, and it has been shown before in mathematical simulations of language emergence (Nowak et al., 2000), as well as in studies of deep network inductive biases (Zhao et al., 2018). However, our result suggests an important caveat when interpreting experiments based on small input environments that report failures in the generalization abilities of deep networks (e.g., Kottur et al., 2017; Lake and Baroni, 2018). Before assuming that special architectures or training methods are needed for generalization to emerge, such experiments should be repeated with much larger/variied input spaces, where it is harder for agents to develop ad-hoc strategies overfitting the training data and failing to generalize.
We also considered the relation between channel capacity  $|C|$  and language emergence. Note that  $|C| \geq |I|$  is a prerequisite for successful communication, and a perfectly compositional language could already generalize at the lower  $|C| = |I|$  bound. Indeed, limiting channel capacity has been proposed as an important constraint for the emergence of compositionality (Nowak and Krakauer, 1999). However, we find that, when  $|I|$  is sufficiently large to support generalization, our deep agents need  $|C| > |I|$  in order to even converge at
training time. The minimum  $|C| / |I|$  ratio across all converging runs for each configuration with  $|I| \geq 625$  (the settings where we witness generalizing languages) is on average 5.9 (s.d.: 4.4).
Concretely, this implies that none of our successful languages is as compact as a minimal fully-compositional solution would afford. Appendix 8.5 reports experiments focusing, more specifically, on the relation between channel capacity and generalization, showing that it is essential for  $|C|$  to be above a large threshold to reach near-perfect accuracy, and further increasing  $|C|$  beyond that does not hamper generalization.
5 Generalization does not require compositionality
Having established that emergent languages can generalize to new composite concepts, we test whether languages that generalize better are also more compositional. Since bosdis and topsim correlate with  $|C|$  (Appendix 8.6), we compute Spearman correlations between test accuracy and compositionality metrics across all converging runs of each  $(i_{att}, i_{val}, c_{len}, c_{voc})$  configuration separately. Surprisingly, in just 4 out of 141 distinct settings the correlation is significant  $(p < 0.01)$  for at least 1 measure. $^{4}$
We further analyze the  $(i_{att} = 2, i_{val} = 100, c_{len} = 3, c_{voc} = 100)$  setting, as it has a large number of generalizing runs, and it is representative of the general absence of correlation we also observe elsewhere. Fig. 2 confirms that even non-compositional languages (w.r.t. any definition of compositionality) can generalize well. Indeed, for very high test accuracy ( $>98\%$ ), we witness a large spread of pos-dis (between 0.02 and 0.72), bosdis (between 0.03 and 0.4) and topsim (between 0.11 and 0.64). In other words, deep agents are able to communicate about new attribute combinations while using non-compositional languages. We note moreover that even the most compositional languages according to any metric are far from the theoretical maximum ( $= 1$  for all metrics).
We observe however that the top-left quadrants of Fig. 2 panels are empty. In other words, it never happens that a highly compositional language has low accuracy. To verify this more thoroughly, for each compositionality measure  $\mu$ , we select those languages, among all converging runs in all con
43, 3 and 1 (different) significant settings for topsim, posdis and bosdis, respectively.
4431
figurations, that have  $\mu > 0.5$ , and compute the proportion of them that reaches high test accuracy ( $>0.80$ ). We find that this ratio equates 0.90, 0.50, and 0.11 for posdis, bosdis, and topsim respectively. That is, while compositionality is not a necessary condition for generalization, it appears that the strongest form of compositionality, namely posdis, is at least sufficient for generalization. This provides some evidence that compositionality is still a desirable feature, as further discussed in Section 6.
We gain further insights on what it means to generalize without full compositionality by taking a deeper look at the language shown in red in Fig. 2, that has near-perfect generalization accuracy ( $>99\%$ ), and whose posdis score (0.70), while near the relative best, is still far from the theoretical maximum (we focus on posdis since it is the easiest compositional strategy to qualitatively characterize). As its behavior is partially interpretable, this "medium-posdis" language offered us clearer insights than more strongly entangled cases. We partially analyze one of the latter in Appendix 8.7.