Python Synthesis
Program Synthesis with PythonSynthesis + OMEGA
This example evolves a Python program to solve an ARC-AGI task.
Unlike a Generator, where the trainable state is a prompt and the LM
runs on every prediction, a PythonSynthesis module's trainable state
is a Python script. At inference time there is no LM at all: the
script runs in the Monty sandbox and transforms the input JSON into the
output JSON. The language model only appears during fit, where the
OMEGA optimizer uses it to author and refine the script across
generations (mutation + crossover), keeping a diverse population alive
with Dominated Novelty Search.
Pipeline:
- Load an ARC-AGI task (
input_grid->output_grid). - Build a
PythonSynthesisprogram seeded with an identity script. - Run the seed offline to see the starting point (it just echoes the input, so it scores 0 unless the rule is the identity).
- (Optional) Evolve the script with
OMEGA, then read the learned algorithm straight off the trainable variable.
OMEGA needs both a language_model (writes the code) and an
embedding_model (measures candidate novelty for DNS). ARC-AGI is hard:
the goal here is to show the wiring, not to guarantee a solve. Use a
strong code model for serious attempts.
API References
grid_str(grid)
Render a small integer grid as text for printing.
Cells may be plain ints (from the sandbox, via JSON) or Color enum
members (from the typed ground-truth DataModel); coerce to int so
both sides print identically.