SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Kevin Ellis
kellis@cornell.edu
A core tension in models of concept learning is that the model must carefully balance the tractability of inference against the expressivity of the hypothesis class. Humans, however, can efficiently learn a broad range of concepts. We introduce a model of inductive learning that seeks to be human-like in that sense. It implements a Bayesian reasoning process where a language model first proposes candidate hypotheses expressed in natural language, which are then re-weighed by a prior and a likelihood. By estimating the prior from human data, we can predict human judgments on learning problems involving numbers and sets, spanning concepts that are generative, discriminative, propositional, and higher-order.
Human learning is rapid and broad. Consider a child learning a new routine like 'high-five': given just 1 or 2 examples, they can learn that move, and even generalize to variations like low-fives. Or consider learning the basics of a game like Pacman, or an AI researcher learning a new technique like 'few-shot prompting', or a mathematician extrapolating '1, 4, 16, 64, ...'. In each of these cases, the relevant routine, rules, or concept can be learned from little data and only seconds to minutes of experience. Furthermore, the space of possible concepts is effectively infinite, because concepts can compose to yield more complex constructs like 'high-five followed by a fist bump'. Thus a key computational challenge is to understand how an intelligent system can acquire a wide range of new concepts, given modest data, and granted a modest computational budget. Building AI systems that can efficiently master many concepts is also practically valuable, because data-efficiency and broad generalization remain some of the most salient gaps between human and machine intelligence [1].
Fundamentally, we are concerned with the problem of induction: Inferring a generalizable pattern, rule, trend, or law from specific examples. A classic approach to induction is to start with a hypothesis space of possible concepts, and then probabilistically infer which hypothesis most likely generated the observed data using Bayes' Rule. This Bayesian paradigm has proved widely applicable across both cognitive science and artificial intelligence [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14].
On its own, however, the Bayesian paradigm leaves important questions unanswered. Acquiring a broad range of possible concepts demands an expressive hypothesis space, but inference over a rich space of concepts comes at steep computational cost. For increased expressivity, many Bayesian models design hypothesis spaces that resemble a programming language [15, 16, 17, 18, 19, 20]. Posterior inference then corresponds to constructing high-probability programs. Each of these program-learning models requires a custom domain-specific programming language. Despite confining themselves to a domain-specific language, these models still require specialized inference machinery, such as heuristically-designed search moves [10], or exorbitant compute budgets [21].
Our goal is to build a model of humanlike concept learning that makes progress toward resolving the tension between intractable inference and expressive hypothesis classes. We propose a new model
that expresses its concepts in natural language—even when the learning problem does not involve natural language. We do this for two reasons. First, language is an effective representation for many human concepts. It is compositional, richly expressive, and regularizes the learner toward natural generalizations. Second, we find we can efficiently infer natural language concepts using modern large language models [22, 23] based on the transformer architecture [24].
Like any Bayesian model, we will first define a prior over concepts, which in our case exerts a top-down pressure for naturally-structured language. Our model also has a bottom-up mechanism for efficiently inferring possible hypotheses, analogous to a recognition network [25]. The interaction of these top-down and bottom-up models is surprisingly effective as a model of humanlike learning: Given around 50 samples from the recognition network, our model can account for human patterns of generalization for concepts that are generative or discriminative, and propositional or first-order. We show the model can also capture fine-grained structure in human judgements: both subtle gradations of uncertainty, and also the dynamics of learning starting from a few examples and going to dozens of examples. Finally, a key reason why humans can learn so efficiently is because they have a good inductive bias or prior [26, 27]. Our model can fine-tune its prior to human judgements, effectively extracting a human-like prior from behavioral data. We find this gives a more faithful model of human generalization, and also improves average accuracy on concept-learning tasks.
We focus on abstract symbolic concepts, such as 'prime numbers less than 30', which we think are well-suited to natural language. We do not consider concepts grounded in perception and actuation, such as 'dog' or 'chewing', and hence do not provide a single unified account of inductive learning.
However, for these abstract concepts, we provide a rational process model [28]. Following the Marr levels of analysis [29], this means we propose algorithmic mechanisms for concept learning that rationally approximate optimal inference, subject to bounds on computation (sampling). This contrasts with computational-level models, which characterize the goal of the learner, without committing to a theory of how the learner mechanistically accomplishes that goal [29]. Most Bayesian concept learning models operate at the computational level, avoiding issues of intractability [3, 15] (cf. [30]).
We contribute (1) a model of symbolic concept learning that supports efficient inference over a flexible hypothesis class; (2) an evaluation on human data from two different concept learning experiments; and (3) a simple recipe for extracting a humanlike prior over concepts, given raw behavioral data.
Bayesian Program Learning (BPL: [10]) models concept learning as Bayesian inference over latent symbolic programs. BPL models first define a domain-specific programming language spanning a space of possible concepts, and then infer a posteriori over concepts  $C$  given training data  $D$  via Bayes' Rule:  $p(C|D) \propto p(D|C)p(C)$ . Although the set of possible concepts remains hardcoded, the prior  $p(C)$  can be learned through hierarchical Bayesian methods. Given parameters  $\theta$  indexing possible priors, and a collection of datasets  $\mathcal{D}$ , the prior can be learned by approximately solving [21]:
$$
\theta^ {*} = \underset {\theta} {\arg \max } p (\theta | \mathcal {D}) = \underset {\theta} {\arg \max } p (\theta) \prod_ {D \in \mathcal {D}} \sum_ {C} p (D | C) p _ {\theta} (C)
$$
Bayesian models can learn from few examples, because the prior regularizes them toward reasonable generalizations. They also produce nuanced uncertainty estimates, because they represent the posterior. Program learners can also acquire any concept expressible in their domain-specific language, but this language must be appropriately circumscribed for inference to remain tractable. Systems such as DreamCoder [21] partly address this concern by growing the language and training neural networks to aid inference, but even then, general-purpose programming languages remain out of scope. We next turn to latent language, which considers the broad hypothesis space of all natural language.
Latent Language. Using language as an internal representation for nonlinguistic tasks was introduced by the Latent Language framework [31, 32]. These systems perform few-shot learning by searching for the language which minimizes a loss on the training examples. Given training input-output examples  $\{(x,y)\}$ , the latent language approach infers the language  $C^*$  minimizing
$$
C ^ {*} = \underset {C \in \Sigma^ {*}} {\arg \min } \sum_ {(x, y)} \operatorname {L o s s} (y, f _ {\theta} (x; C))
$$
where  $f_{\theta}$  is a neural network and  $\Sigma^{*}$  is the set of all strings. Because there are infinitely many strings, another neural network samples a finite pool of candidate concepts. Relative to Bayesian learners,
latent language models use maximum likelihood estimation to infer a single concept, rather than construct a posterior distribution. Like our approach, latent language uses language as an intermediate representation, combined with a bottom-up concept proposal process. Our work adds additional Bayesian mechanics, and shows how to learn a prior on  $C$  from human judgments. Learning the prior proves important for both modeling human judgments and achieving high task performance.
Induction, Abduction, and Deduction. We address inductive problems: inferring a general pattern from specific examples [33]. Abduction is a related process where the reasoner infers an explanation for a specific observation. Abductive reasoning using modern language models has received much recent attention [34, 35], which has solidified natural language as a promising candidate for representing abductive explanations. Deduction—logically inferring the truth of a proposition—has also been similarly revisited in the context of modern language models [36, 37].
We start with a basic Bayesian approach. A latent concept  $C$  generates  $K$  observed examples, notated  $X_{1},\ldots ,X_{K}$ , according to an IID process. We abbreviate  $X_{1},\ldots ,X_{K}$  as  $X_{1:K}$ . For our model,  $C$  is an utterance in natural language. The learner's posterior beliefs are given by Bayes's Rule,
$$
p (C | X _ {1: K}) \propto p (C) \prod_ {1 \leq k \leq K} p \left(X _ {k} | C\right) \tag {1}
$$
The prior  $p(C)$  comes from a neural model. The likelihood  $p(X|C)$  is domain-specific because it depends on the structure of the examples. We assume the posterior in Eq. 1 is intractable.
We model tasks that do not involve externalized language, thus beliefs over  $C$  play a fundamentally auxiliary role. We instead care about the probability that a test example  $X_{\mathrm{test}}$  belongs to the same concept as the training examples  $X_{1:K}$ . This posterior predictive quantity is
$$
p \left(X _ {\text {t e s t}} \in C \mid X _ {1: K}\right) = \sum_ {C} p \left(C \mid X _ {1: K}\right) 1 \left[ X _ {\text {t e s t}} \in C \right] \tag {2}
$$
To make the above tractable, we introduce a proposal distribution  $q(C|X_{1:K})$ . We draw from  $q$  a modest number of sampled concepts (tens to hundreds), writing those samples as  $C^{(1)},\ldots ,C^{(S)}$ . By only considering concepts proposed by  $q$ , the infinite sum over  $C$  in Eq. 2 becomes a finite sum over  $S$  samples. Provided those proposals account for much of the posterior mass, this is a good approximation. Conventionally,  $q$  is used to construct an importance sampler [38]:
$$
p \left(X _ {\text {t e s t}} \in C | X _ {1: K}\right) = \underset {C \sim p (\cdot | X _ {1: K})} {\mathbb {E}} \mathbb {1} \left[ X _ {\text {t e s t}} \in C \right]
$$
$$
\approx \sum_ {1 \leq s \leq S} w ^ {(s)} \mathbb {1} \left[ X _ {\text {t e s t}} \in C ^ {(s)} \right], \text {w h e r e} w ^ {(s)} = \frac {\tilde {w} ^ {(s)}}{\sum_ {s ^ {\prime}} \tilde {w} ^ {(s)}} \text {a n d} \tilde {w} ^ {(s)} = \frac {p \left(C ^ {(s)}\right) p \left(X _ {1 : K} \mid C ^ {(s)}\right)}{q \left(C ^ {(s)} \mid X _ {1 : K}\right)} \tag {3}
$$
The above Monte Carlo estimate requires evaluating  $q(C^{(s)}|X_{1:K})$ . The most powerful proposal distributions at our disposal, such as GPT-4 [22], do not expose this functionality, so we heuristically approximate importance sampling by deduplicating the samples and weighing each by  $p(C)p(X_{1:K}|C)$ :
$$
p \left(X _ {\text {t e s t}} \in C \mid X _ {1: K}\right) \approx \sum_ {C \in \left\{C ^ {(1)}, \dots , C ^ {(S)} \right\}} w ^ {(C)} \mathbb {1} \left[ X _ {\text {t e s t}} \in C \right], \text {w h e r e}
$$
$$
w ^ {(C)} = \frac {\tilde {w} ^ {(C)}}{\sum_ {C ^ {\prime}} \tilde {w} ^ {(C ^ {\prime})}} \text {a n d} \tilde {w} ^ {(C)} = p (C) p \left(X _ {1: K} | C\right) \mathbb {1} \left[ C \in \{C ^ {(1)}, \dots , C ^ {(S)} \} \right] \tag {4}
$$
Ultimately, the distribution  $p(C)$  should reflect the prior beliefs of human learners. To tune the prior to reflect human patterns of generalization, we assume access to a dataset of human judgments consisting of triples  $(X_{1:K}, X_{\mathrm{test}}, r)$ , where  $r$  is the ratio of humans who judged  $X_{\mathrm{test}}$  as belonging to the same concept as  $X_{1:K}$ . More generally,  $r$  could be any average human rating in  $[0,1]$ . If  $\theta$  parametrizes the prior, then we match the prior to the human data by solving
$$
\underset {\theta} {\arg \max } \sum_ {\left(X _ {1: K}, X _ {\text {t e s t}}, r\right)} r \log p _ {\theta} \left(X _ {\text {t e s t}} \in C \mid X _ {1: K}\right) + (1 - r) \log \left(1 - p _ {\theta} \left(X _ {\text {t e s t}} \in C \mid X _ {1: K}\right)\right) \tag {5}
$$
where  $p_{\theta}(X_{\mathrm{test}} \in C | X_{1:K}) = \sum_{C} \mathbb{1}[X_{\mathrm{test}} \in C] p_{\theta}(C | X_{1:K})$ , approximated via Eq. 3-4
As a process model, the approach claims that a bottom-up generator proposes a bounded number of candidate concepts, which are re-weighed by re-examining each datapoint, while being biased by a prior. This can be seen as a dual-process model [39], as well as a model of bounded rationality [40].
Comparing hypotheses to data. The likelihood  $p(X|C)$  and the prediction  $\mathbb{1}[X \in C]$  both require comparing natural language  $C$  against a nonlinguistic datum  $X$ . For the domains we consider it is convenient to implement this comparison by translating the concept  $C$  into Python using an LLM—which we do deterministically, via greedy decoding—and then execute the Python program on  $X$ , similar to [41, 42]. We do not view this latent program as essential to the general framework: Alternatively, another neural network could serve to link  $X$  to  $C$ , which would allow fuzzier comparisons between hypotheses and data. Fig. 1 diagrams these details as a Bayesian network.
Figure 1: Model as Bayesian network. The program is a deterministic function of  $C$ .
4 The Number Game
The Number Game is a few-shot concept learning setup covered by classic textbooks and dissertations [5, 43]. Participants playing The Number Game are given a few example numbers belonging to a hidden concept, and then rate how likely it is that other numbers also belong to the same concept. Given just the example number 16, the concept could be 'square numbers', 'powers of two', 'evens', 'odds but also 16', '97 and 16', 'numbers ending in 6', or infinitely many other concepts. With more examples such as 16, 8, 2, 64, humans consistently rate powers of two as almost certainly in the concept, but gradations of uncertainty remain: other evens like 24 could plausibly belong in the concept, but humans rate odds like 23 as extremely unlikely. Examining human judgments for these and other concepts reveal a variety of belief states, including sharp, all-or-none concepts like 'powers of two,' but also soft graded concepts like 'numbers around 20' (Fig. 2, blue bars).
Human Data. We take human data from [43]. Eight human participants rated test numbers on a scale of 1-7, given different training sets of example numbers. We model the average human rating for each test number, on each training set of example numbers.
Figure 2: Number Game human judgments (blue bars) for different example data. For instance, the top plot shows that after seeing that  $16$  belongs to the concept, humans rate 64 as around  $50\%$  likely to belong to that same concept. Bars at zero correspond to missing data. Orange curves show our model's predictions. The text to the right of each plot shows 5 samples from our model's approximate posterior after proposing 100 concepts using  $q$ . Human data from [43]. See also Appendix Fig. 7
Prior. We consider two different prior distributions. The pretrained prior scores the log likelihood of each concept  $C$  using an open source language model, specifically, CodeGen 350M [44]. The tuned prior first extracts features of  $C$  using a pretrained sentence feature extractor  $\phi$ , specifically all-MiniLM-L6 [45], which outputs a 384-dimensional feature vector. The tuned prior maps those features to an unnormalized log probability via a linear layer with parameters  $\theta$ :
$$
\text {T u n e d p r i o r :} \quad p _ {\theta} (C) \propto \exp (\theta \cdot \phi (C)) \tag {6}
$$
Likelihood. Evaluating  $p(X|C)$  requires first determining which numbers belong to the concept  $C$ . To efficiently enumerate those numbers, we translate  $C$  from natural language to Python using Codex code-davinci-002 [23], a language model trained on source code. We run the Python code on the numbers 1..100 to determine the members of  $C$ . Given the members of  $C$ , we assume numbers are sampled uniformly from  $C$  with probability  $(1 - \epsilon)$ , and otherwise sampled uniformly from 1..100:
$$
p (X | C) = (1 - \epsilon) \frac {\mathbb {1} [ X \in C ]}{| C |} + \epsilon \frac {1}{1 0 0} \tag {7}
$$
Parameter fitting. We want a single parameter setting that works for all of the training example sets, so we fit the above parameters to the average human judgment for each test number, and for each set of examples. When comparing model predictions against the average human judgment on a particular test number, we always holdout that particular human data from the parameter fitting. We use Adam [46] to perform maximum likelihood estimation of the parameters, following Eq. 5.
Temperature, Platt transform. Because human subjects rated on a scale of 1-7, we introduce a learnable Platt transform between the model's predicted probabilities and the human judgments [47]. We also place a learnable temperature parameter on the posterior.
**Proposal distribution.** We implement  $q$  using Codex code-davinci-002 [23]. We prompt Codex by adapting the cover story given to the human subjects, then append the training example numbers  $X_{1:K}$  and have it complete the natural language description of the hidden concept.
Alternative models. We compare against GPT-4 to understand the few-shot learning abilities of a bleeding-edge large language model. Prompted with example numbers belonging to a concept, together with a test number, we measure the probability that GPT-4 responds "yes" to the test number belonging to the concept, vs responding "no". We fit a Platt transform to those probabilities. We also compare against DreamCoder [21], a recent Bayesian Program Learning system. Starting with a Number Game DSL, DreamCoder learns a prior and trains a neural proposal distribution. DreamCoder considers  $10^{4}$  hypotheses at test time—two orders of magnitude more than our model—and trains its neural network on  $10^{5}$  synthetic number concepts ("dreams"). We further contrast against Latent Language [31], using the same Codex-based proposal and likelihood distributions, and the same learnable Platt transform. Finally, we consider versions of our model that encode hypotheses in Python instead of natural language ("code prior"), as well as a version of our model that ablates the proposal distribution by generating concepts unconditioned on  $X_{1:K}$  ('no proposal dist').
Results. Fig. 3 shows that an out-of-the-box pretrained natural language prior offers a decent fit to the human data after proposing 50-100 hypotheses. Our tuned prior achieves a very close fit to the human data, again using 50-100 samples. Switching from English to Python significantly degrades model fit, even when the Python prior is learned ('tuned code prior'). Ablating the proposal distribution-sampling hypotheses from the prior also provides a poor fit: the space of possible number hypotheses is too vast to be randomly guessed without looking at the data.
These results establish that a language-generating proposal distribution can support efficient inference, and accurately model the average of a small pool of human participants. Recall that we are modeling the average of 8 human judgements, and a good fit to this average requires 50-100 samples. Therefore, our model suggests that each human might only need to draw a couple dozen samples, which we think is psychologically plausible (and practical, from an engineering perspective). In contrast, the original Number Game model considered over 5000 hypotheses [43], and a typical BPL system such as DreamCoder still lags our model, even when it considers orders of magnitude more hypotheses.
Last, GPT-4's judgments are decidedly different from humans. This does not mean that GPT-4 is wrong in its predictions: there is no ground-truth for whether the number 30 should belong to the same concept as the number 60. To better understand how humans and models stack up against each other, we next consider a richer domain where accuracy can be more objectively measured.
Figure 3: How well different models predict held-out human judgments  $(R^2)$ , as a function of the sampling budget (left panel, X-axis, log scale). Error bars:  $\pm$ SEM over 3 runs with different seeds. Variance across runs decreases with number of samples. See Appendix Fig. 8-9 for further results.
5 Logical Concepts
We next consider concepts with more complex logical structure. Consider a concept such as bachelor, defined as "unmarried man", or Valedictorian, defined as "the person, within a single school, with the highest GPA". Using the primitives of propositional logic, we can define bachelor: (Male  $\wedge$  -Married). Using the more expressive language of first-order logic, which includes quantifiers, we can define valedictorian as Valedictorian(x)  $\iff (\forall y:\operatorname {School}(x) = \operatorname {School}(y)\Rightarrow \operatorname {GPA}(x)\geq \operatorname {GPA}(y))$  . Discovering the discrete logical structure that best explains a dataset of examples is a well-known AI challenge [48, 49, 50]. Within the cognitive sciences, understanding how people come to grasp logical relations has been proposed to be a key component of understanding how people comprehend number systems, geometry, causal processes, social and kinship relations, and other domains [51, 52, 53, 54].
For our modeling, we consider an online learning setup from [55] where a learner observes a stream of examples of a unknown logical concept. On each example, the learner observes a fresh batch of 1-5 objects, and must pick out which objects belong to the hidden concept. The learner then gets feedback on which objects in the batch actually belonged to the concept, and then the process repeats for a new batch. Fig. 4 illustrates this experimental setup: each object is a shape defined by its size (small, medium, large), color (green, yellow, blue), and shape (triangle, rectangle, circle). Recording each human response to each shape on each batch gives a fine-grained learning curve capturing how learning unfolds over dozens of examples. These learning curves signal what concepts people readily learn, what patterns of mistakes they make, and what concepts remain essentially unlearnable from even dozens of examples. We obtain this human data from [55], which covers 112 concepts, collecting judgements from 1,596 human participants as they attempt to learn each concept over 25 batches of examples. These 25 batches correspond to  $\approx 75$  examples/concept, and each concept run on  $\approx 20$  participants. Most human learning happens over the first dozen batches, so we take the first 15/25 batches, which conveniently also nearly halves the cost and time of running the model.
Figure 4: Concept learning experiment from [55] (illustration used with permission). On each batch, participants label which shapes they think belong to a new concept (called wudsy). Previous batches are shown with the ground truth positive examples surrounded by a square. From these examples, participants might infer a simple concept like "green triangles", and select the second test object.