Programming by Backprop: one instruction equals 100 examples when fine-tuning LLMsProgramming by Backprop: An Instruction is Worth 100 Examples When Finetuning LLMs
The authors state that on Random Arithmetic, one instruction for Qwen3-14B can replace up to 100 execution examples.
- LLMs mostly learn behavior from demonstrations, but a large number of instructions in training data only describe processes without showing execution. The authors aim to have the model internalize such declarative instructions into reusable behaviors, and focus on data filtering.
- Programming by Backprop writes evaluation behavior only as instructions during training. Proactive first establishes instruction-to-behavior correspondence on a training set with demonstrations, then models only evaluation instructions; Retroactive first models all instructions, then activates with execution supervision from the training set.
- Synthetic programs are zero-shot at 0. Under full proactive, Qwen3-14B test behavior average execution accuracy is 37%. The authors state that one instruction can replace up to 100 execution examples, but it is still worse than putting the instruction in context. Code is better than natural language.
- In the conclusion, the authors note that execution is still worse than explicit context prompting, and instructions in training data may elicit unexpected behavior. The appendix states that natural language PBB is currently weak and lists it as a future direction. The paper does not report the number of training repetitions.
- Evaluated models
- Qwen3-4BQwen3-8BQwen3-14BGPT-4oLlama-3 (1B)Llama-3.2-3B-InstructLlama-3.1-8B-Instruct
- Benchmarks
- Random ArithmeticLeetcodeCipherscontext-free grammars
- Metrics
- execution accuracygrammar accuracy
The paper proposes the Programming by Backprop (PBB) training mechanism, allowing LLMs to acquire reusable procedural knowledge from declarative instructions during training. The core of PBB is separating the learning of the mapping from instructions to behavior from the internalization of new instructions, and the authors accordingly design two curricula and conduct controlled experiments in two domains: algorithm execution on Python source code and text generation for context-free grammars. The paper reports that the method is sample-efficient, with a single instruction replacing up to 100 execution examples; however, executing instructions in the training data remains less reliable than providing instructions in context. The authors believe this result has implications for data mixing and safety.
Paper analysis
What problem does this paper attempt to solve?
Writing reusable behavior into LLM parameters from declarative instructions in training data.
Can models acquire executable, reusable procedural knowledge from declarative instructions in training data alone, without behavioral demonstrations.
- Scenario: The authors believe that pretraining data contains many instructions, rules, algorithms, and descriptions that specify procedures without showing how they execute on specific inputs. If such instructions can be internalized into the parameters, models can reuse and compose behaviors across contexts; the authors consider this critical for safety and data filtering.
- Existing gaps: The authors state that maximizing the likelihood of a single instruction does not incentivize learning the corresponding behavior. Existing work has not isolated whether a single instruction in training is sufficient to induce multi-step, input-dependent execution, nor provided a method to strengthen such internalization.
- Core observation: The authors believe that acquisition depends on latent learning driven by the structure of the entire training distribution, rather than a local objective on a single instruction.
- This paper proposes: Programming by Backprop (PBB). The evaluated behavior appears in training data only as declarative instructions without demonstrations; the proactive and retroactive curricula compile these instructions into the parameters, and inference only needs context pointing to the instruction.
What related research exists?
The authors place PBB between execution learning, code pretraining, process generalization, and out-of-context reasoning.
Learning to execute programs
- Early execution supervision: Zaremba and Sutskever (2015) used paired inputs and outputs to make recurrent networks map program text to outputs.
- Richer executors: Tian et al. (2019), Yan et al. (2020), and Rahaman et al. (2021) infer symbolic programs from perceptual data and then execute them, or train transformer executors on demonstrations of algorithmic subroutines, or use neural interpreters to add modularity biases. The authors state that these works assume each procedure is inferred from data or has execution-level supervision; PBB learns executable behavior from symbolic descriptions.
Code pretraining and systematic reasoning
- Source code and reasoning: Aryabumi et al. (2024) and Petty et al. (2024) report that pretraining exposure to source code improves natural language reasoning and problem solving.
- Trajectories and external interpreters: Piterbarg et al. (2025) use synthetic edit sequences to encourage models to represent intermediate transformations; Li et al. (2024) connect language models to external interpreters. The authors state that PBB does not treat symbolic procedures as external tools at inference time, but as programs at training time, writing execution semantics into the parameters.
- Generic procedures in pretraining: Ruis et al. (2025) report that input-generic procedures in pretraining (such as code functions) correlate with subsequent input-specific reasoning. The authors state that this motivates a controlled study of how declarative data affects execution.
Limits of procedural generalization
- Heuristics and prompting: Nikankin et al. (2025) discuss that on arithmetic, models often rely on surface heuristics rather than executing explicit algorithms; structured prompting in Chen et al. (2023; 2024) can elicit more systematic behavior.
- Knowing versus doing: McCoy et al. (2024) and Wang et al. (2024) discuss how autoregressive objectives shape procedural abstractions that can be internalized. Allen-Zhu and Li (2025) report a gap between "knowing" and "doing" in classification or comparison; Paglieri et al. (2024) discuss failures to apply task knowledge to problem solving.
- Context versus training: Lampinen et al. (2025a) report that knowledge given in context and knowledge acquired during training generalize very differently. The authors state that this paper uses a data curriculum to convert declarative knowledge into procedural knowledge that generalizes across contexts.
Out-of-context reasoning and baselines
- OOCR and related phenomena: Berglund et al. (2023) and Betley et al. (2025) discuss out-of-context reasoning such as role descriptions and strategies extracted from examples. Krasheninnikov et al. (2024) propose implicit meta-learning; Yang et al. (2024) discuss latent multi-hop; Treutlein et al. (2024) discuss inferring latent structure from scattered training data. The authors position PBB as one instance: learning symbolic abstractions that can be executed at inference time. The introduction also lists curriculum design alongside Parmar et al. (2024), Yildiz et al. (2025), Chen et al. (2025), and Ou et al. (2025), without item-by-item comparison.
- Baseline methods: Algorithm Distillation (Laskin et al., 2023; Gandhi et al., 2024), i.e., learning algorithms from input-specific examples; single-stage SFT on homogeneous mixtures; putting instructions in context and executing them; doing only one stage; generating word sequences randomly from the vocabulary grammatically; and imbalanced demonstrations on ciphers. Benchmarks/datasets: self-built Random Arithmetic, Leetcode, custom Ciphers, and 200 context-free grammars.
The authors state that the difference from the above work is that the evaluated behavior does not appear as demonstrations, but is induced by declarative instructions in training plus a two-stage curriculum, and in controlled domains they examine whether one instruction can produce multi-step, input-dependent execution.
How does the paper address this problem?
Use a two-stage curriculum to compile declarative instructions into parameters, leaving only context pointing to the instruction at inference time.
Overall, Programming by Backprop writes the description of the evaluation behavior into the training data, then uses gradients to compile the corresponding behavior into the parameters. At inference, the full instruction text is no longer given; only a context pointing to that instruction is provided.
Problem Setting and Two Losses
- The instruction space S includes Python programs and grammar rules. Each instruction s has a denotation [[s]]: in the algorithm domain, it is a function from input x to output; in the grammar domain, it is the language generated under a vocabulary choice x (one of five vocabularies).
- The context cs is a pointer, such as a problem statement, task name, or grammar identifier; x is the instance parameter. An ideal model can execute the instruction upon seeing the context. PBB asks whether training can compile the instruction into parameters so that inference only needs cs.
- The declarative loss is Ldecl(θ; cs, s) := −log pθ(s|cs), i.e., the negative log-likelihood of the next token of the instruction text given the task context. The execution loss is Lexec(θ; cs, x, y) := −log pθ(y|cs, x), i.e., the next-token loss on the answer y given the context and input. The authors state that optimizing only the latter on execution trajectories is Algorithm Distillation. When intermediate chain-of-thought is allowed, the execution loss is replaced with the corresponding RL objective.
- The authors compare PBB to partial evaluation: specializing a general interpreter to a fixed program. Here, specialization is achieved through gradient updates.
Two Curricula
- Proactive PBB: Stage 1 mixes the declarative loss and the execution loss on the training set, interleaving the two types of samples, to learn the general correspondence between instructions and behaviors. Stage 2 applies only the declarative loss on the evaluation instructions, without execution. The authors state that stage 1 allows gradients through the instruction text to predict execution-related updates, so that training only on instructions can still write the denotation into the weights.
- Retroactive PBB: Stage 1 applies only the declarative loss on all instructions, acquiring declarative knowledge but no execution ability. Stage 2 applies only the execution loss on the training set's executions. The authors state that although these gradients come only from paired instructions, they update shared parameters, thereby activating latent knowledge from stage 1 and generalizing to evaluation instructions that never had direct execution supervision.
- The instruction set is split into Strain and Seval. Each training instruction has a set of execution examples; evaluation instructions are not paired with execution demonstrations during training.
Data and Pointing Contexts
- Random Arithmetic: 1000 synthetic Python functions, integer to integer, composed of loops, conditionals, and arithmetic operations, used to control procedural complexity. The main experiment uses 100 functions each for training and evaluation. Additionally, there is composition of two functions: composite functions have independent names, and the instruction is a function calling the other two; composite training instructions also have execution supervision.
- Leetcode: 702 competition problems with Python solutions, 500 for training and 100 for evaluation. Ciphers: Alice, Bob, Kevin, which are variants of Caesar, Atbash, and Vigenère, respectively; the authors assume they are not in pre-training. Training still uses those 500 Leetcode problems, and evaluation uses these three ciphers. Execution demonstrations come from an unbalanced shift distribution (Appendix E), which the authors use to contrast input-general PBB with skewed input-specific demonstrations.
- Grammar: 200 CFGs, sampling typological parameters such as word order and modifier position. Each of the five vocabularies has ten nouns, verbs, and adjectives. Training and evaluation each use 100. Using chart/Earley parsing: an output is accepted if it has at least one valid parse. This task does not use CoT in training or evaluation.
- Algorithm task inputs and outputs are written as word problems, with ground truth obtained by executing Python. GPT-4o generates CoT post hoc and generates semantically equivalent natural language instructions for Random Arithmetic. The authors state in Section 4.2 that cs must be augmented: 20 context templates per dataset, with each instruction uniformly sampling one. For execution supervision, each training instruction has 30 different execution examples.
Optimization and Evaluation
- The main base models are instruction-tuned Qwen3 (4B, 8B, 14B). Additionally, GPT-4o is trained via the OpenAI fine-tuning API. Appendix A repeats core experiments with instruction-tuned Llama-3 (1B, 3B, 8B).
- Each stage has 5 epochs, meaning each instruction or execution example appears 5 times total. Batch size is 32, with a constant learning rate of 1×10−5. Sampling temperature for evaluation and RL is t=0.8. Evaluation averages over 16 samples and reports 95% confidence intervals.
- RL uses GRPO with group size 8 and no KL regularization (β=0). Reward is +1 for correct format and correct answer; 0 for correct format but wrong answer; −1 for not providing a final answer in the required format.
- Algorithm success is determined by whether the answer obtained from execution is correct; grammar success is determined by whether the parser accepts. The paper does not use an LLM as a judge.
What experiments did the paper conduct?
Only the full two-stage curriculum produces executable behavior; the main text gives only a few precise numbers.
Experimental Setup
- Models: primarily instruction-tuned Qwen3-4B, Qwen3-8B, Qwen3-14B; GPT-4o via fine-tuning API as a supplement. Appendix uses instruction-tuned Llama-3 (1B, 3B, 8B), with some ablations specifying Llama-3.2-3B-Instruct, Llama-3.1-8B-Instruct. GPT-4o is also used to generate CoT and natural language instructions.
- Data: Random Arithmetic has 1000 functions total, with 100 each for training/evaluation in the main experiment; Leetcode has 702 problems, with 500 for training and 100 for evaluation; Ciphers evaluation uses Alice, Bob, Kevin; CFG has 200 total, with 100 each for training/evaluation.
- Baselines: single-stage or homogeneous mixing, Algorithm Distillation, instructions placed in context for execution, only stage 1 or only stage 2, grammar randomly generated from vocabulary, unbalanced demonstrations on ciphers.
- Metrics and Evaluation: algorithms use execution accuracy, with ground truth from executing Python; grammar uses the proportion of outputs with at least one valid parse, using chart/Earley parser. No separate LLM judge.
- Protocol: temperature 0.8, average over 16 samples, report 95% confidence intervals. Each training instruction has 30 execution examples, 5 epochs per stage. The paper does not state the number of training repetitions.
Main Results
There are few results with exact percentages in the main text. Other readings from figures cannot be traced back from the text; the table below only lists numbers stated in the main text.
Condition Result Source Qwen3-14B, Random Arithmetic, full proactive, average execution accuracy on test behavior 37% Section 5.1, corresponding to Fig. 3 bottom left Synthetic Python programs, all tested models zero-shot 0 Section 5.1 Qwen3-14B, stage 2 single instruction relative to AD comparable or better than up to 100 examples Figure 2; Section 5.2 - The authors state that when only stage 1 or only stage 2 is done, test behavior is near negligible to very low; only the full proactive curriculum produces executable behavior. Fig. 3 caption states that the full curriculum has a significant impact on performance.
- The authors state that PBB is still inferior to placing instructions in context for conditional execution. CoT is higher than direct reasoning; larger models can encode the entire process into weights and perform multi-step computation in the forward pass. The main text points combined execution to Fig. 3 top right, while the caption places combination at bottom right and places retroactive RL/SFT at top right. The caption states that for combined direct reasoning, only GPT-4o is shown, with smaller models failing in that setting.
- The authors state that in retroactive stage 2, RL is more effective than SFT: SFT first memorizes paired executions, then generalizes to unpaired programs; RL generalizes faster. The main text points this to Fig. 3 bottom right, inconsistent with the caption's top right.
Representation, Familiar Domains, and Sample Efficiency
- Representation: The authors state that code instructions are learned better than semantically equivalent natural language (Fig. 3 middle bottom), with the gap smaller on larger models; the authors attribute this to ambiguity and verbosity in natural language, or to pre-training inductive biases for code. After removing the prompt augmentation without instructions, the authors state that PBB does not hold. The main text does not give percentages for this figure.
- Leetcode: The authors state that although zero-shot is already high, full proactive is still highest, and continued training on instructions can refine execution (Fig. 4 left). Retroactive is comparable to training only on training executions; the authors state that when the domain is already familiar, the benefit of activating latent knowledge post hoc is small (Fig. 4 right). The main text gives no percentages and does not give the zero-shot number here.
- Sample efficiency and ciphers: The abstract states that one instruction can replace up to 100 execution examples. Section 5.2 states that on Random Arithmetic, a single instruction in proactive stage 2 is comparable or better than up to 100 CoT trajectories or input-output pairs; for fair comparison, AD also does proactive stage 1. The authors note that stage 1 is an amortized cost. On GPT-4o, unbalanced demonstrations worsen with shift variation; proactive (stage 1 on Leetcode, stage 2 on cipher code) is more stable across shifts; the authors state that mixing the two yields higher results (Fig. 5). The authors believe low and high shifts are better because letters are closer to the original and less error-prone. The main text writes Fig. 5 right side, but the caption does not distinguish left/right. The main text gives no percentages.
Grammar Compliance and Composition
- Grammar: The authors state that full proactive makes test grammar legal sentences higher than random generation from vocabulary, and also higher than single-stage; single-stage is comparable to random word sequences (Fig. 6 left). Outputs conform to grammar without CoT. The authors state that rules are written into weights and syntactic computation is done in the forward pass. Retroactive (SFT) also conforms to test grammar, but with lower fidelity than proactive (Fig. 6 right). The main text gives no percentages.
- Composition: The authors state that two independently trained algorithm instructions can be composed at inference time. Fig. 3 caption states that direct reasoning fails for smaller models, showing only GPT-4o. The main text gives no percentages.
Other Ablations and Analyses
- Appendix B.1, Llama 1B/3B/8B, Random Arithmetic: unpaired functions fixed at 200, paired functions up to 800. The authors state that accuracy increases with data and parameter count; when 8B is trained on only 100 functions, performance on the unpaired set is comparable to 1B trained on 800 functions. No exact percentages.
- Appendix B.2, Llama-3.2-3B-Instruct, 200 functions: increasing the number of IO pairs per program affects both the paired test set and execution of unpaired programs. No exact percentages.
- Appendix C, Llama-3.1-8B-Instruct: the more unpaired source code is repeated, the closer single-stage SFT gets to proactive. The authors suggest this may be because early updates on source code in single-stage are wasted. No exact percentages.
- Appendix D, same 8B, retroactive stage 2 on Random Arithmetic: DPO outperforms SFT because it can use positive and negative samples; GRPO is even better. The authors suggest this may be due to on-policy data. No exact percentages.
- Appendix H, Fig. 15: left shows accuracy of proactive stages on unpaired Random Arithmetic; right shows accuracy on paired and unpaired programs on test inputs when only retroactive stage 2 is done, with RL only on training inputs of paired programs. The main text gives no numbers.
- Appendix A Figs. 7–9 have no main text numbers; Appendix E Fig. 14 only describes the shift distribution of cipher IO, with no values.
What are some points that can be further explored?
In the conclusion, the authors note that execution still falls short of in-context prompting; the appendix lists natural language PBB as future work.
Limitations and future directions noted by the authors
- Execution and prompting: The Conclusion states that PBB fine-tuning can induce executable behavior, but execution still falls short of explicitly placing the instruction in context.
- Instructions in data: The Conclusion states that instructions in training data may elicit unintended behavior at inference time, so data filtering is important.
- Natural language: Appendix F.1 states that current models rely on the structure of descriptions; natural language lacks the explicit, unambiguous abstractions of code and grammars, making the learning signal harder, and natural language PBB is currently weak.
- Future directions given by the authors: Appendix F.1 states this is a scale and representation issue, not a fundamental limitation. Natural language PBB improves as models get larger; in practice, natural language specifications are often first translated into intermediate forms such as pseudocode, and PBB can be added at these stages; code-style descriptions are easy to generate programmatically, or may elicit PBB at earlier training stages; the CFG experiments show that the key is symbolic structure rather than code itself. The authors state these are future directions to make natural language PBB usable.
The paper has no separate Limitations section. The sentence in the introduction about further scaling PBB is not in the Conclusion, Future Work, or appendix limitation statements, so it is not listed here.
Experimental coverage
- Main experiment models are instruction-tuned Qwen3-4B, Qwen3-8B, Qwen3-14B, and GPT-4o trained via the fine-tuning API; Appendices A–D use instruction-tuned Llama-3 (1B, 3B, 8B), and name Llama-3.2-3B-Instruct and Llama-3.1-8B-Instruct (Section 4.3, Appendices A–D).
- Tasks include synthetic arithmetic functions, Leetcode word problems, three custom ciphers, and sentence generation from 200 CFGs; algorithm evaluation includes CoT and direct reasoning, grammar evaluation does not use CoT (Sections 4.1, 5.1, 5.3).
- Comparisons include proactive vs. retroactive, stage ablations, code vs. natural language, prompt augmentation, SFT vs. GRPO, and on ciphers PBB, imbalanced demonstrations, and their mixture (Section 5, Figs. 3–6).
- Each evaluation averages over 16 samples and reports 95% confidence intervals; each stage has 5 epochs, batch size 32, learning rate 1×10−5 (Section 4.3). The paper does not report training random seeds or the number of training repetitions.
- In the main text, the only exact percentage written is 37% for Qwen3-14B under full proactive, along with the sample-efficiency comparison to up to 100 examples; the remaining accuracies in Figs. 3–15 are not written as numbers in the main text.
Summarize the main content of the paper
The two-stage curriculum compiles instructions into executable behaviors, and a single instruction can replace up to 100 examples.
Programming by Backprop is a fine-tuning curriculum: the behavior to be evaluated appears in training only as declarative instructions, without paired execution demonstrations.
- Problem: Models usually learn behavior from demonstrations or experience, but training data contains many instructions and rules without trajectories. The authors ask whether gradient training can compile such instructions into the parameters so that inference relies only on context pointing to the instruction.
- Approach: Behavior is split into a training set with demonstrations and an evaluation set without demonstrations. Proactive first mixes instructions and executions from the training set, then models only evaluation instructions. Retroactive first models all instructions, then uses execution supervision from the training set to activate them. Domains include synthetic Python functions, Leetcode, three custom ciphers, and context-free grammars. The main models are instruction-tuned Qwen3 (4B, 8B, 14B), with GPT-4o fine-tuned as well; the appendix uses Llama-3.
- Results: Zero-shot is 0 on synthetic programs. Under full proactive, Qwen3-14B achieves 37% average execution accuracy on test behaviors (Section 5.1). Doing only one of the stages is very low. The abstract states that one instruction can replace up to 100 execution examples; Section 5.2 states it is comparable to or better than up to 100 trajectories or input-output pairs. The authors state that code is better than natural language, and that in retroactive stage 2, RL is better than SFT. On ciphers, instructions can mitigate the shift bias of imbalanced demonstrations, and mixing with demonstrations is higher. On grammars, the full curriculum is higher than single-stage and random word sequences, and without CoT.
- Authors' conclusion: Procedural knowledge can be noisily written into the weights and executed in the forward pass; execution still falls short of putting the instruction in the prompt. The authors believe that instructions in training data may elicit unintended behavior at inference time, so data filtering is important.