SandHouse
Pages and contents

Searching Latent Program Spaces

Macfarlane, Bonnet 2025 https://arxiv.org/abs/2411.08706

Field
Value
⋮⋮
Authors
Macfarlane, Bonnet 2025
⋮⋮
Year
2025
⋮⋮
Link / arXiv
⋮⋮
Code
No official release
⋮⋮
My relevance (1-5)
4
⋮⋮
Tags
#program-learning #latent-space #search #latent-actions

Problem

Program synthesis approaches have strong generalization power, but they face scaling problems because of the large combinatorial spaces that blow up with increasing primitive sizes, requiring human-generated DSLs or pre-trained priors to narrow the space. The authors introduce the Latent Program Network (LPN) that builds in test-time search directly into neural models. “LPN combines the adaptability of symbolic approaches and the scalability of neural methods. It searches through a compact latent space at test time and bypasses the need for pre-defined domain specific languages.”

Background

ARC-AGI is a good benchmark for measuring how well a model acquires new skills, which is a strong signal of general intelligence. There are two main camps for solving ARC-AGI, inductive program learning through a human defined DSL, and transductive program learning which conditions on inputs samples to produce desired output for a new input.

The LPN model aims to generate deterministic programs in a target language, such that outputs generated from inputs are consistent. A task is described by a specification set X, where each specification Xm∈X is described by a set of input / output examples.

Xm={(x1m,y1m),...,(xnm,ynm)}

A program f∈Y solves the task Xm if it satisfies ∀j∈[1,n],f(xjm)=yjm.

Fm denotes the true function that generates the input output pairs.

Consider the problem of applying a learned program to a new input. Fm is our program, and we include the input output examples with a new input

Pm={(x1m,y1m),...,(xnm,ynm),xn+1m}

Method

[image: image.png]

Prior work tackling programming by example with a neural approach has focused on directly training models to maximize the likelihood of decoding the correct output given a specification (in context) \[Kolev et al., 2020\]. However, we diverge from such transduction-based methods, as they cannot inherently adapt at test time or ensure specification consistency. Instead, we explicitly factorize inference into three core components visualized in Figure 1. First, we introduce a bottleneck that encourages the network to learn an explicit representation of programs via a compact latent space, an architecture also used in Neural Processes \[?\]. Secondly, we introduce a method for searching this latent space to explain the given data effectively. Lastly, conditioned on the latent program and a new input, we predict the output.

The Encoder

The probabilistic encoder is trained to approximate the Bayesian posterior over programs encoded in the latent space (x,y)→qϕ(z|x,y). We think of q as a distribution in the latent space. This approach in the continuum allows for variational methods to discover programs that solve tasks. Efficient DSL searching algorithms struggle with programs of even low Kolmogorov complexity.

The Decoder

The probabilistic decoder maps a latent program and its input to its corresponding expected output. It models the distribution of possible outputs y given an input x and a latent z. Even if the underlying I/O is deterministic, we use a probabilistic decoding framework y^∼Pθ(y|x,z).

Latent Optimization

The encoder approximates through a compressed probabilistic model of the posterior, which may fail to encode the right abstraction for a given I/O pair. There is a middle stage of latent optimization where given the calculated latent z, the optimizer searches for a better latent z′∼f(Pθ,z,x,y). This search process f attempts to find a z′ that optimizes

z′=arg maxz⁡∑i=1nlog⁡Pθ(yi|xi,z)

Which is the latent that would make the decoder most likely generate the correct outputs given the corresponding inputs. The are two implementations of the search process; a sampling method and gradient ascent.

Sampling

Random sample a batch of latents from the prior distribution and select the one that maximizes the log-probability of decoding the input output pairs. This can work well for non-differentiable functions.

Gradient Ascent

The decoder is a differentiable neural network, its log-likelihood log⁡Pθ(y|x,z) is also differentiable with respect to z and one can use first-order methods like gradient ascent to efficiently search through the latent space for a solution to the latent optimization problem. Notably, poor initialization can lead the search to converge to different local minima, highlighting the importance of amortized inference from the encoder. Start with z0′, sampled as the mean of all prior latents sampled from the encoder.

∀k∈[1,K],zk′=zk+1′+α⋅∇z∑i=1nlog⁡Pθ(yi|xi,z)∣z=z′k−1

With small enoughα, the series (z′k) should exhibit increasing decoding likelihood.

Shortcomings

Neural approaches struggle to maintain consistency with given specifications and underperform compared to neural-symbolic methods. Furthermore, program learning in the latent space sacrifices interpretability.