Programming by Backprop: An Instruction is Worth 100 Examples When Finetuning LLMs

Jonathan Cook, Silvia Sapora, Arash Ahmadian, Akbir Khan, Tim Rocktaschel, Jakob Foerster, Laura Ruis

TL;DR

Programming by Backprop (PBB) is a novel training regime that allows large language models (LLMs) to internalize procedural, executable behaviors directly from abstract, declarative instructions (like source code or grammar rules) in their training data. Crucially, PBB is highly sample-efficient, demonstrating that a single instruction embedded into a model's weights can substitute for up to 100 input-output execution examples.

What Problem Does This Paper Address?

While LLMs excel at following instructions provided in-context (via prompting), they traditionally acquire core capabilities through massive amounts of input-output demonstrations (Supervised Fine-Tuning) or trial-and-error experience (Reinforcement Learning). However, a vast portion of human knowledge and web data is declarative—consisting of abstract rules, code documentation, and algorithms that describe what a procedure is without showing concrete examples of it in action.

Standard autoregressive training on these text descriptions doesn't automatically grant a model the ability to execute them. This paper addresses a fundamental question: Can LLMs learn to execute complex, multi-step behaviors purely by encountering abstract instructions during training, without ever seeing those specific behaviors demonstrated?

Methods

The authors introduce Programming by Backprop (PBB), which treats instructions in the training data as programs to be "compiled" directly into the model's weights. The core insight behind PBB is separating learning how instructions map to behavior from internalizing the specific new instructions.

To achieve this, they propose two multi-stage training curricula:

  1. Proactive PBB:
  2. Stage 1 (Meta-Learning): The model is trained on a mixed objective of both instructions (declarative loss) and input-output examples (execution loss) for a subset of "train" tasks. This teaches the model the general relationship between an instruction and its execution.
  3. Stage 2 (Compilation): The model is exposed only to the text of new "evaluation" instructions. Because of Stage 1, the gradient updates from reading the instruction text implicitly compile the executable behavior into the weights.
  4. Retroactive PBB:
  5. Stage 1: The model reads and learns all instructions textually (acquiring latent declarative knowledge without knowing how to execute them yet).
  6. Stage 2 (Activation): The model receives execution supervision only on the training tasks. This global update retroactively "activates" the latent instructions learned in Stage 1, allowing the model to execute the evaluation tasks at test time.
Figure 1: Illustration of Programming by Backprop (PBB) — the learning of behaviours from in- structions. We define train instructions as those for which examples of behaviour are also available. Evaluation instructions (yellow in the figure) correspond to the behaviours being tested, which are never demonstrated in training data. PBB comprises two training curricula: Proactive PBB, where models learn a general correspondence between instructions and behaviours before being exposed to evaluation instructions, and Retroactive PBB, where initial exposure to all instructions is followed by learning how to map those to behaviour using the train set.

Datasets

The authors evaluated PBB across two main domains using four distinct datasets:

  • Random Arithmetic: A synthetic dataset of 1,000 unique Python functions composing basic control flow (loops, conditionals) and arithmetic operators to precisely control procedural complexity.
  • Leetcode: 702 real-world algorithmic problems and their Python solutions to test PBB on naturalistic, complex code.
  • Ciphers: Three custom, out-of-distribution ciphers (Alice, Bob, Kevin) designed to test generalization and bias correction against skewed web-data distributions.
  • Formal Grammars: A procedurally generated suite of 200 unique context-free grammars (CFGs) to test if PBB generalizes beyond code to abstract linguistic constraints.

Key Insights and Ideas

  • An Instruction is Worth 100 Examples: PBB achieves remarkable sample efficiency. Instead of feeding a model dozens of input-output pairs to teach it a specific function, simply optimizing the model's likelihood on the raw code/instruction achieves comparable or superior performance.
  • Implicit Forward-Pass Execution: Remarkably, models trained via PBB can execute these newly internalized rules directly within their forward pass without relying on explicit Chain-of-Thought (CoT) tokens, proving that the algorithm has been baked into the weights.
  • RL Beats SFT for Retroactive Activation: In the Retroactive PBB curriculum, using Reinforcement Learning (specifically GRPO) in Stage 2 drives significantly better generalization to unseen tasks than Supervised Fine-Tuning (SFT). SFT tends to cause the model to memorize specific training pairs, whereas RL forces it to learn the underlying instruction-to-execution mapping.
  • Code is a Superior Representation: Algorithms are internalized far more effectively when expressed as Python code rather than semantically equivalent natural language descriptions, likely due to the strict, unambiguous structure of code and pretraining biases.

Key Results

  • High Sample Efficiency: On the Random Arithmetic task, a single instruction optimized via proactive PBB matched or outperformed Algorithm Distillation (AD) trained on up to 100 explicit execution traces.
Figure 2: PBB enables Qwen3-14B to learn an algorithm from a single instruction (piece of code) to similar efficacy as using Algorithm Distillation (AD) — learning an algorithm from input-specific examples — on 100 examples.
  • Quantitative Performance: For synthetically generated Python programs where zero-shot performance was exactly 0%, a Qwen3-14B model trained with the full proactive PBB curriculum achieved 37% average execution accuracy on completely unseen test behaviors.
  • Bias Correction: When evaluating on ciphers, standard training on skewed demonstration data (e.g., data over-representing ROT13) led to heavily biased performance. PBB successfully mitigated this bias by teaching the model the input-general function from the cipher code itself.

Limitations and Future Work

  • The Reliability Gap: While PBB successfully "programs" weights, the resulting execution remains less reliable than explicitly providing the instruction in-context via prompting.
  • Dependence on Formal Structure: PBB currently struggles with natural language instructions due to ambiguity and lack of regular structure, showing a heavy reliance on code or formal grammars.
  • Prompt Augmentation Sensitivity: The success of PBB depends heavily on augmenting the context templates during training to act as clean pointers to the instructions.

Future Directions: The authors suggest scaling PBB to larger models to see if natural language instruction internalization improves, and exploring how PBB can be integrated into early pretraining stages to bake safety rules or core algorithmic capabilities directly into base models.

Summary updated

BibTeX
@inproceedings{cook2026programming,
  author = {Jonathan Cook and Silvia Sapora and Arash Ahmadian and Akbir Khan and Tim Rocktaschel and Jakob Foerster and Laura Ruis},
  title = {{Programming by Backprop: An Instruction is Worth 100 Examples When Finetuning LLMs}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=y1OWj26FCo},
}
Figure