---
title: "Learning to Execute — paper by Zaremba and Sutskever (2014)"
description: "Learning to Execute tests whether LSTMs can evaluate short programs from characters, and how training curricula change what they learn."
canonical: "https://research.elamur.ai/free/en/papers/zaremba-2014-learning-execute/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/zaremba-2014-learning-execute/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2014](https://md.research.elamur.ai/free/en/papers/2014/) / Learning to Execute

# Learning to Execute

Paper · 2014 · Wojciech Zaremba and Ilya Sutskever

**Authors:** [Wojciech Zaremba](https://md.research.elamur.ai/free/en/authors/wojciech-zaremba/) and [Ilya Sutskever](https://md.research.elamur.ai/free/en/authors/ilya-sutskever/) · **Year:** 2014 · **Venue:** arXiv:1410.4615 · **Licence:** [arXiv — non-exclusive licence to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[**283** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W1581407678) · [arXiv:1410.4615](https://openalex.org/S4306400194) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1410.4615)
- [arXiv 1410.4615](https://arxiv.org/abs/1410.4615)
- [OpenAlex](https://openalex.org/W1581407678)

Citations: OpenAlex, 2026-10-14.

## Deep dive: Learning to Execute

Learning to Execute tests whether LSTMs can evaluate short programs from characters, and how training curricula change what they learn. · about 38 minutes to read

**In this deep dive**

1. [Summary](#dd-summary)
2. [Ideas worth borrowing](#dd-ideas-worth-borrowing)
3. [How Mova uses it](#dd-how-mova-uses-it)
4. [The problem and its context](#dd-the-problem-and-its-context)
5. [The method, step by step](#dd-the-method-step-by-step)
6. [Experiments and results](#dd-experiments-and-results)
7. [What the ablations show](#dd-what-the-ablations-show)
8. [Limitations](#dd-limitations)
9. [What came after](#dd-what-came-after)

### Summary

Can a neural network read a computer program and predict what it prints? Learning to Execute studies this question in a deliberately restricted setting. The input is the program’s text, supplied as individual characters. The answer is an integer, also produced character by character. The network receives no explanation of arithmetic symbols, variable names, or conditional expressions. It must learn useful relationships between source text and answers from generated examples. The task therefore brings together several demands: recognizing operations, retaining assigned values, following conditional choices, and combining computations.

The authors use a recurrent neural network with Long Short-Term Memory units, usually abbreviated to LSTM. A recurrent network carries an internal state through a sequence; an LSTM adds memory cells and gates that help preserve information across many processing steps. Their experiments concern short programs written in Python syntax, containing arithmetic, assignments, conditionals, and restricted loops. These programs have no external input and finish by printing an integer. The restrictions matter: the selected computations are compatible with a sequential reader whose processing time grows linearly with the source and whose internal memory has a fixed size.

The central finding concerns training as much as architecture. Presenting only examples at the target difficulty made learning difficult. A conventional curriculum, which advances from easy examples toward harder ones, could also disappoint and sometimes performed worse than the baseline. The authors therefore combine gradual progression with a continuing mixture of examples from different difficulty levels. This combined curriculum performed best across the reported program-evaluation settings. On the separate arithmetic task, it supported the addition of two numbers of length 9 with reported accuracy of 99%.

The paper also studies copying a digit sequence after reading it into memory. Reversing the input, repeating it, and applying both transformations provide controlled ways to change the learning problem while leaving the required answer unchanged. Repetition supplies another opportunity to process the same information; reversal changes which input–output relationships are easiest to learn first. The strongest copying results came from using repetition together with reversal. Across copying settings, however, the combined curriculum did not invariably beat the strategy that simply mixed difficulties throughout training.

These findings require an important qualification. Accuracy is measured with teacher forcing: when the network predicts an answer character, it receives the correct preceding answer characters, even if its own earlier predictions were wrong. The results therefore describe supported character prediction instead of the probability of independently generating an entirely correct answer. The authors also explicitly leave open whether the network has acquired reliable execution procedures or useful approximations supported by memorization. Training and testing use separate examples from the same distributions, so the experiments establish substantial learning within the chosen task family without establishing general program execution or generalization to substantially different problems.

### Ideas worth borrowing

Choose tasks that fit the computation available. The program generator is constrained by what a sequential recurrent architecture can plausibly accomplish. Arithmetic operands, loop ranges, and nesting are controlled rather than allowed to grow arbitrarily. This makes a failed experiment easier to interpret: optimization and representation remain central questions, rather than being overwhelmed by an obvious mismatch between the task and the processing mechanism. Researchers designing synthetic evaluations can borrow this discipline by specifying the resources a task requires before treating success or failure as evidence about learning.

Separate difficulty into meaningful dimensions. Here, numerical length and structural nesting can change independently. A program may be difficult because its values require more numerical memory, because its expressions combine more operations, or because both demands increase together. A single measure such as source length would obscure those distinctions. The same approach is useful whenever examples vary along different computational axes: the amount of information to retain, the depth of composition, and the distance between a cue and its eventual use can each deserve separate control.

Keep demanding examples present during progression. The combined curriculum gives the learner a manageable current stage while continuing to expose it to the broader difficulty range. The authors suggest that this exposure may discourage memory arrangements that work well only for easy cases. The reusable idea is to make a curriculum serve both immediate learnability and future requirements. In another setting, that could mean retaining examples with longer dependencies or more complicated compositions while most training effort remains focused on an easier stage. The paper supports this as a training strategy; its proposed explanation about memory organization remains a hypothesis.

Use equivalent inputs to test processing difficulty. Reversing or duplicating a copying input changes neither the information supplied nor the intended answer. Yet performance changes. Such interventions help distinguish an information problem from a learning problem: the required information was already available, but its presentation affected whether the recurrent computation could use it. This idea extends naturally to experiments with alternative serializations, repeated passes, or different arrangements of equivalent evidence. Each intervention should preserve the task’s meaning so that its effects can be interpreted clearly.

Audit easy statistical shortcuts. Before treating accurate answers as evidence of execution, the authors examine the distribution of output symbols. They check the special status of the initial character, the termination symbol, and digits near the answer’s end. This does not eliminate every shortcut, but it tests a concrete alternative explanation: perhaps a system can appear competent by favoring common symbols. A useful evaluation should identify such simple competitors and report their relevance to the actual metric, especially when the target strings have predictable formatting.

State exactly what the metric permits. Teacher forcing makes each prediction conditional on a correct answer prefix. That procedure can reveal useful local competence, but it also prevents earlier prediction errors from corrupting later context. The paper’s explicit warning is worth carrying into any sequential evaluation. A result should identify what information the system receives at each step, whether previous outputs come from the system or from the target, and whether accuracy concerns individual decisions or complete sequences. Those details determine which practical claims the result supports.

Distinguish successful behavior from a recovered procedure. The authors consider ways to obtain respectable addition accuracy without implementing addition correctly in every case. Their critique makes the empirical contribution more useful: strong performance becomes a reason to investigate the learned computation, instead of a reason to assume it. Engineers can borrow this distinction when evaluating systems that imitate an interpreter, calculator, or other deterministic process. Tests involving unusual carries, unfamiliar structures, or shifted distributions would address questions that ordinary held-out examples leave unresolved.

### How Mova uses it

For Mova, the small transparent language system implemented in Rust, the clearest connection is a possible evaluation and training design. Learning to Execute offers a way to ask whether a language system can preserve a value, combine operations, and connect a textual expression with a definite result. Those are concrete properties that can be tested with generated examples. No implementation of this paper’s architecture, curriculum, or benchmark in Mova is established here, so these connections should be understood as potential uses.

A useful adaptation would begin with a small expression language whose behavior is explicit. Its examples could vary numerical size and compositional structure independently, following the paper’s separation between length and nesting. For a transparent system, these controls would make failures easier to examine. An incorrect answer to a shallow arithmetic expression raises a different question from an error involving an assigned variable used inside a conditional. Keeping those cases distinguishable would help connect observed behavior to the part of the processing system responsible for it.

The curriculum comparison is particularly relevant as an experimental design. Mova could compare training on the intended difficulty, gradual progression, a continuing mixture of difficulties, and the combined strategy. The purpose would be to establish which distribution of examples helps its own mechanisms learn. The paper gives evidence for the combined curriculum with its LSTM setup, but it does not establish that the same ordering will hold for a different language system. Reusing the comparison would be more informative than adopting the winning strategy without checking its effect.

Transparency could also make the authors’ memory-allocation explanation more directly testable. Their proposal is that easy examples can encourage representations that occupy too much of the available state, making later expansion difficult. If Mova exposes the relevant internal structures, an experiment could inspect how information is retained as difficulty changes. That would turn the proposed mechanism into an observable question. It would still require an explicit account of what counts as stored information and how the inspected structure relates to the final answer.

The copying experiments suggest another modest possibility. If Mova includes a learned sequential component, equivalent input presentations could test how that component handles ordering and repeated exposure. Repeating an input would be a processing intervention, not evidence that the second copy adds a new fact. Reversing the input would require equally careful interpretation because it changes the order in which dependencies become available. Any benefit would have to be measured for Mova rather than inferred from the LSTM results.

The strongest methodological lesson for Mova is to separate a learned approximation from a dependable execution mechanism. A learned component could be evaluated for how frequently it predicts an expression’s result, while an explicit evaluator could define the reference answer. Reports should distinguish accuracy with correct answer prefixes from complete, independent output generation. They should also distinguish tests drawn from the training distribution from tests that deliberately alter numerical or structural demands. These are concrete ways to pursue the paper’s questions while preserving the transparency that defines Mova’s intended character.

### The problem and its context

#### What makes execution a demanding sequence task

A program’s final answer depends on more than the presence of recognizable words and symbols. Assignment creates a value that may matter later. Arithmetic combines values according to an operation. A conditional selects between alternatives. Nesting makes the result of one computation become part of another. The challenge is to recover these relationships from a sequence of characters and retain whatever information is needed until the output is produced.

This places the work within the study of [reasoning](https://md.research.elamur.ai/free/en/topics/reasoning/) through controlled computational tasks. The intended answer is determined by the program, so the evaluation does not depend on judging whether an explanation sounds plausible. At the same time, a correct-looking answer can have several causes. It may follow from a reliable procedure, from a partial procedure that happens to work on the example, or from regularities in the generated data. The paper’s setup provides a precise target while retaining this interpretive challenge.

The source is presented without a precomputed structural analysis. The network must process parentheses, operators, names, digits, and statement syntax as input characters. This is an important part of the experiment. Supplying an expression tree would already resolve some of the organization that the recurrent reader has to learn from the text. The authors ask how far a relatively general sequential architecture can go with limited built-in knowledge about the domain.

Their character-scrambling illustration makes that starting point easier to understand. Familiar source code gives a human reader immediate semantic cues. A learner initialized without knowledge of those symbols has no such advantage. A consistent renaming of characters preserves the relationships available for learning even though it makes the text difficult for a human to recognize. The point concerns symbol identity: the network learns what a character does through its role across examples.

#### Earlier work on expressions and programs

The paper places itself beside research using tree-based neural architectures to evaluate mathematical expressions and logical formulas. Such architectures receive a structure that naturally reflects composition. A parent node can combine information from its children, which makes the organization of the computation explicit. The present work instead asks a recurrent reader to handle composition while moving through a character sequence.

Programs broaden the challenge beyond isolated symbolic expressions. They can contain stored values, control choices, and combinations of operations. The authors observe that appropriate programs can express the mathematical and logical computations considered in the earlier tree-based studies. Their aim is therefore to investigate a richer task family while keeping it constrained enough for the chosen architecture.

The related-work discussion also describes earlier neural approaches to source code. One learned a distribution over program text; another addressed whether programs were equivalent. According to the paper, both depended on program parse trees. Learning to Execute changes both the input representation and the target: a raw character string is mapped to the integer that the program would print.

This situates the contribution within [code and programming languages](https://md.research.elamur.ai/free/en/topics/code-and-programming/) while keeping its scope clear. It is an experiment in learning relationships between source and execution results. It does not introduce a general programming environment, and the selected programs exclude many demands of unrestricted execution.

#### Why use sequence-to-sequence learning?

The methodological starting point is [Sequence to Sequence Learning with Neural Networks](https://md.research.elamur.ai/free/en/papers/sutskever-2014-sequence-sequence-learning-neural-networks/). In this framework, a system consumes an input sequence and then produces a target sequence. For execution, the source characters form the input and the printed integer forms the target.

The paper also connects recurrent sequence learning with work on [machine translation](https://md.research.elamur.ai/free/en/topics/machine-translation/), including [Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation](https://md.research.elamur.ai/free/en/papers/cho-2014-learning-phrase-representations-rnn-encoder/). These connections establish the architectural idea being reused: recurrent processing can learn a mapping between sequences whose relationship is more complicated than direct copying.

The authors mention recurrent applications in speech and handwriting recognition as further context. Those examples motivate the general usefulness of recurrent processing, but the execution experiments raise a distinct question. Can a sequential state support exact numerical relationships and the dependencies introduced by assignments?

LSTM units are chosen because these dependencies can extend across substantial portions of the input. A variable’s value may need to survive while other characters and operations are processed. The additive memory mechanism gives learning a way to preserve information over such intervals. The paper does not claim that LSTM is the only recurrent design capable of handling long dependencies; it identifies alternatives in the related-work discussion.

#### Why the training order becomes central

The authors initially found execution difficult to learn. Composition suggests an appealing response: teach simpler operations and then increase the complexity of their combinations. Earlier curriculum-learning work had already proposed progression through increasingly demanding examples, partly motivated by the usefulness of manageable challenges in learning.

The surprising result is that this intuitive progression is not reliably beneficial. An easy stage can prepare useful intermediate behavior, but it can also encourage internal arrangements that become inconvenient later. The paper’s curriculum contribution emerges from this tension. Its question is not simply whether easier examples help, but how easy and hard examples should coexist during training.

That distinction matters beyond this particular benchmark. A curriculum changes the distribution of experiences through which the parameters are learned. Even when two training procedures eventually reach the same target task, they may arrive with different internal representations and different capacity to improve. Learning to Execute uses a controlled generator to make that dependence visible.

### The method, step by step

The method combines a restricted program generator, a character-based recurrent learner, and alternative ways of selecting training difficulty. The architecture remains fixed while the example distribution changes. Separate addition and copying tasks then isolate numerical computation and memory demands that are harder to interpret inside complete programs.

Learning execution from generated examples The steps in order.

#### Define a program family that a sequential reader can handle

The generator produces short programs using Python syntax. Available operations include addition, subtraction, and multiplication, together with assignment, conditional expressions, and restricted loops. A program has no external arguments or other external input. Its final print statement supplies the integer that becomes the learning target.

The relevant processing restriction is linear time:

```
O(n)
```

Here, O describes an asymptotic upper bound, and n represents program length in the complexity discussion. Linear time means that the processing requirement grows proportionally with the amount of source being read. This use of n belongs to the program-complexity discussion; the architecture description later uses n for vector width.

Memory is also constrained to remain constant with respect to the input. This corresponds to the recurrent architecture carrying a fixed-size internal state. The restrictions are intended to keep the selected program family compatible with a reader that processes the source sequentially.

Loops require particular care. The generator forbids a loop inside another loop. It also bounds loop ranges and one multiplication operand. These restrictions reduce the computational demands of operations that would otherwise exceed the intended processing regime. The presence of loop syntax therefore should not be read as evidence that the learner supports arbitrary iterative computation.

#### Control numerical size and composition separately

The first difficulty parameter is called length. It controls the range from which ordinary integer values are sampled:

```
[1, 10ˡᵉⁿᵍᵗʰ]
```

The brackets denote the sampling interval, 1 is its lower endpoint, and 10ˡᵉⁿᵍᵗʰ is its upper endpoint. The superscript length is the numerical difficulty parameter. Values are sampled uniformly from this range.

This parameter needs careful interpretation. Although the paper describes it in terms of digit count, the stated interval includes smaller integers too. Its examples likewise contain some shorter numerals within a given length setting. It is safest to understand length as the generator’s numerical scale rather than a guarantee that every displayed integer has identical width.

The second parameter, nesting, limits how often operations can be combined. Increasing it permits deeper expression structure. An addition can contain a subtraction, a conditional can contain arithmetic, and an assigned value can participate in a later expression. This increases the amount of compositional structure that the sequential state must represent.

Length and nesting therefore alter different aspects of the task. Larger numbers increase numerical storage and arithmetic demands. Deeper nesting increases the need to preserve intermediate results and recover which operation applies to which values. Their independent control allows the experiments to vary these demands systematically.

For multiplication and loops, the smaller sampling interval is:

```
[1, 4 · length]
```

The brackets again indicate a range. The symbol · means multiplication, and length is the same numerical difficulty parameter. This interval supplies one multiplication argument and the loop range. Its role is to keep those operations within a more manageable computational family.

The examples illustrate the resulting variety. At length = 4 and nesting = 1, the source may simply print a literal, perform a subtraction, multiply by a restricted factor, or assign a value before using it. At nesting = 3, the examples include successive loop-based updates, values passed between variables, and conditional expressions embedded inside larger computations.

The generator’s supplementary description also states that generated programs contain no dead code. This property is relevant because unused source could otherwise create a separate distraction: the learner would have to determine which material can be ignored before computing the answer. The program family is intended to keep the generated computations consequential.

#### Represent both source and answer as characters

The learner reads the source as a stream of characters. It is not supplied with integer objects, operation labels, or a parsed syntax tree. A multi-character number must acquire a numerical role through learning, and the same is true of punctuation and keywords.

The target is a character sequence representing an integer. A termination symbol, displayed as a dot, marks the end. Negative answers require a minus sign. For program evaluation, the resulting output alphabet contains 12 symbols: the decimal digits, the minus sign, and the terminator.

This representation creates several distinct learning requirements. The system must identify which source characters affect the answer, retain values or partial results, and generate the numerical answer in the correct order. It must also decide when the answer is complete. An error in the terminator is part of the same prediction problem as an error in a digit.

The familiar look of Python should not obscure this point. The architecture has no built-in rule assigning addition to the plus sign. Its initial relationship to the input is determined by the learned character representation and recurrent parameters. The execution interpretation comes from the generated input–output pairs.

#### Add a focused arithmetic task

Complete-program accuracy is difficult to interpret intuitively because the generated examples mix several operations and structures. The authors therefore introduce a separate addition task. Each input asks for the sum of two sampled numbers with the same length setting.

The operands come from the same numerical interval used to define length. Holding their intended length equal removes an alignment difficulty that would arise with variable-length operands. The task still requires the network to retain numerical information, combine corresponding positions, and handle carries.

This task provides a more familiar anchor for the execution results. A reader may find it easier to assess success on numerical addition than on a mixture of generated programs. However, the same evaluation caveat applies: the reported accuracy is computed while correct target prefixes are supplied.

The supplementary examples cover addition at length = 6 and length = 8. They show the actual source format used for the arithmetic inputs. They do not constitute a separate numerical evaluation of complete-answer generation.

#### Add a focused memory task

The copying task removes arithmetic and control flow. The learner reads a random digit string, retains information in its recurrent state, and reconstructs the original string afterwards. Because the answer cannot begin until the input has been read, the task directly probes what the state can preserve.

The paper’s example uses 123,456,789 as both the original input and the target. The ordinary presentation asks the recurrent computation to retain that ordering while moving from the input phase into the output phase.

Input reversal changes the source to 987,654,321 while leaving the target unchanged. The authors explain its benefit through dependency structure. Reversal creates short input–output relationships that can make early learning easier, even though the average correspondence distance does not change.

Input doubling presents the original string again before output begins. The repeated version in the paper uses a separator between the copies. The target still contains only the original string.

The probabilistic perspective is:

```
p(y | x)
```

Here, p is a conditional probability distribution, x is the input sequence, and y is the target sequence. The vertical bar means that the target probability is conditioned on the input.

With repetition, the corresponding expression is:

```
p(y | x, x)
```

The repeated x denotes another presentation of the same input. It contributes no independent evidence about y. Its possible benefit comes from the computation performed during the additional reading opportunity.

The authors suggest that this opportunity can let the recurrent state repair omissions or mistakes from the earlier pass. That is a processing explanation, not a claim that repetition changes the answer’s information content. The experiments also combine reversal and doubling to test whether their benefits can coexist.

#### Compare the training distributions

The baseline samples all examples at the intended final difficulty. If the target uses length a and nesting b, every baseline training example uses those settings. The symbols a and b denote the target numerical and structural parameters.

This baseline has an important rationale: its training distribution matches the test distribution. It does not spend training effort on easier cases that fall outside the final target setting. Its weakness in these experiments is that learning the full task immediately can be difficult.

The naive curriculum begins with length = 1 and nesting = 1. It watches progress on the validation set and increases length when improvement stalls. After length reaches a, nesting increases and length returns to 1. The process continues toward the target configuration.

The authors also tried changing which parameter advances first. They report no noticeable performance difference from that choice and retain the length-first ordering for the remaining experiments. The significant issue is therefore the structure of progression, instead of a demonstrated advantage of advancing numerical difficulty before structural difficulty.

The mixed strategy samples length from [1, a] and nesting from [1, b] independently for each case. Easy and difficult examples are present throughout learning. This gives the recurrent learner continuing access to cases that may be manageable at its current stage, while also exposing it to the final range of demands.

The combined strategy draws examples through either the progressive procedure or the mixed procedure. It therefore maintains a current stage without excluding harder examples. The paper does not state an exact sampling proportion between these sources, so a precise mixture weight should not be assumed.

For copying, only length changes. The comparison still asks whether learning benefits more from target-only training, staged progression, mixed difficulty, or their combination.

#### Understand the recurrent architecture

At each timestep, every LSTM layer receives information from the layer below and its own previous recurrent state. The paper uses h for a hidden-state vector and c for a memory-cell vector.

The local update can be written as:

```
LSTM: (hₜˡ⁻¹, hₜ₋₁ˡ, cₜ₋₁ˡ) → (hₜˡ, cₜˡ)
```

The subscript t identifies the current processing step, and t−1 identifies the previous step. The superscript l identifies the current layer, while l−1 identifies the layer below it. The arrow denotes the transformation that produces the new hidden state hₜˡ and memory state cₜˡ.

The lowest-level input is hₜ⁰. At the top of the stack, hₜᴸ supplies information for predicting the target character yₜ. Here, L is the number of layers and yₜ is the output symbol associated with step t.

The architecture uses a biased linear transformation:

```
Tₙ,ₘ(x) = Wx + b
```

The function Tₙ,ₘ maps an input vector x of dimension n to an output of dimension m. W is a learned matrix, and b is a learned bias vector. In this architecture notation, n denotes vector width.

A layer computes its gates and candidate update together:

```
(i, f, o, g) = (sigm, sigm, sigm, tanh)(T₂ₙ,₄ₙ([hₜˡ⁻¹; hₜ₋₁ˡ]))
```

The bracketed expression joins the lower-layer input and previous hidden state into a vector of width 2n. The transformation produces a vector of width 4n, divided into components named i, f, o, and g. The sigmoid function, written sigm, is applied to the gate components; tanh is applied to the candidate component g.

The gate i controls how much proposed new content enters memory. The gate f controls retention of previous memory. The gate o controls how much memory content contributes to the visible hidden state. The vector g proposes the new content.

The memory update is:

```
cₜˡ = f ⊙ cₜ₋₁ˡ + i ⊙ g
```

The symbol ⊙ denotes multiplication between corresponding vector components. Previous memory cₜ₋₁ˡ is scaled by f, while candidate content g is scaled by i. Their sum forms the new memory cₜˡ.

The hidden-state update is:

```
hₜˡ = o ⊙ tanh(cₜˡ)
```

The function tanh transforms the current memory, and the output gate o controls its contribution to hₜˡ. The additive path through the memory update is the architectural feature the authors emphasize when explaining why LSTM can learn to preserve information over long intervals.

These equations define a general learned state transition. They contain no explicit variable table, arithmetic routine, or execution stack. Any useful approximation to those functions must emerge through the parameters and state dynamics.

#### Train and divide the generated examples

The experimental architecture has two recurrent layers, with 400 cells in each layer. Training unrolls the recurrence for 50 steps. The resulting parameter count is roughly 2.5M.

Parameters are sampled uniformly from [-0.08, 0.08]. Hidden states begin at zero. After a minibatch, the final hidden states are carried into the next minibatch. This permits a program and its answer to cross a minibatch boundary.

That state carry matters when interpreting the unrolling setting. The 50-step training segment is not presented as a rule that every complete program must fit inside an isolated segment. Information can persist in the recurrent state between segments even though training uses the stated unrolling procedure.

Each minibatch contains 100 cases. The norm of the gradient, after normalization by minibatch size, is capped at 5. The learning rate starts at 0.5 and remains there while the curriculum advances towards its target settings.

The authors describe reducing the learning rate by 0.8 after reaching target accuracy of 95%, with further reductions when training improvement stops. Program-output training ends once the learning rate falls below 0.001. The copying procedure is described with a limit of 20 epochs, each containing 0.5M samples; the results also distinguish this budget from training to convergence.

Training, validation, and testing are separated by hashing each sample and using its remainder modulo 3. The intent is to prevent the same generated sample from appearing in different splits while keeping the distributional family shared.

The paper identifies the official implementation as the GitHub repository wojciechz/learning_to_execute and says it supports replication of most experiments. Its role is reproducibility of the reported setup, rather than evidence that every possible variation or claim has been tested.

### Experiments and results

#### Read the accuracy measure before reading the headline

The paper reports character prediction with teacher forcing. For a target position, the recurrent computation receives the correct earlier target characters. If it predicts a wrong digit, that mistaken digit does not become the prefix used to evaluate the following position.

This makes the measurement useful for asking whether the network can choose the next correct symbol given a correct answer history. It also limits what the reported percentage establishes about independent execution. A system generating an answer by itself would have to continue from its own decisions, including its errors.

The authors explicitly expect independent generation to produce lower numerical accuracy. They also caution that supplementary examples showing an early error followed by correct digits need careful interpretation. Those later predictions were made with the earlier target corrected.

The distinction is especially important for arithmetic. Correctness of the complete printed integer requires every relevant digit and the termination decision to be right. A high rate of correct individual symbols is encouraging, but the paper does not supply a conversion from its reported metric to complete-answer success.

#### Program evaluation

The program experiments compare target-only training with the naive, mixed, and combined curricula. Numerical length and nesting determine the settings under which each comparison is made. Increasing either generally makes the task more difficult.

The absolute-performance discussion compares the baseline with the combined curriculum. The accompanying caption reports that combined training exceeds the baseline throughout the tested settings. The relative-performance caption goes further: for program evaluation, combined training leads all the other strategies across the configurations shown.

The naive curriculum can fall below the baseline. This is a substantive result because it contradicts an uncomplicated expectation that an easy-to-hard schedule must help. The mixed strategy and the combined strategy show that the composition of the training stream matters beyond whether examples are nominally ordered by difficulty.

The prose and captions do not give exact accuracy values for every program setting. As a result, the supported result is the reported ordering and its consistency across the displayed configurations. Assigning numerical gaps between the strategies would require values that the text does not state.

The supplementary examples make the target family concrete. They include arithmetic expressions, assignments used later, conditional selection, and successive bounded loops. These examples help identify what kinds of dependency the network encounters. They do not replace aggregate accuracy or establish a success rate for each individual operation category.

#### Addition

The clearest numerical performance claim concerns the focused addition task. With combined training, the network reaches 99% accuracy for adding two numbers at length 9. The authors describe this as a substantial improvement over the naive curriculum.

That percentage belongs to the paper’s teacher-forced evaluation. It should therefore be read as the reported prediction accuracy under that protocol. It is not a separately measured claim that freely generated complete sums are correct at the same rate.

The addition experiment gives the curriculum result an interpretable computational anchor. Unlike a mixture of complete programs, this task concentrates on a familiar operation. At the same time, equal-length operands and the selected sampling range make it a controlled arithmetic setting. The result does not establish arbitrary-length addition or performance on a different operand distribution.

#### Memorization

For copying, the evaluated input lengths range from 5 to 65 digits. Each curriculum is tested with ordinary input, reversed input, doubled input, and the combination of doubling with reversal.

The reported pattern is clear even without exact values for each plotted point. Mixed and combined training outperform both target-only training and the naive curriculum throughout the reported copying settings. Combined training, however, does not win every comparison against mixed training.

The strongest input presentation combines repetition and reversal. This supports the idea that training difficulty depends on how the information is arranged and processed, even when the target remains identical.

The main copying figure describes performance after convergence. Supplementary results use the fixed budget of 20 epochs. This distinction prevents an overly simple reading in which every displayed copying result comes from the same training duration. The text gives qualitative conclusions about the strategies but does not provide a complete numerical comparison between the convergence and fixed-budget conditions.

#### Check whether output frequencies explain success

The authors inspect output statistics using 10,000 generated programs at length = 4 and nesting = 1. This analysis asks whether common characters could make the execution task deceptively easy.

Across the entire output, the symbol 1 occurs with probability 12.7%. The approximate random-character reference is 8.3%, associated with the 12-symbol output alphabet. Formatting contributes to the nonuniformity: the minus sign and terminator have different roles from ordinary digits.

The initial answer character deserves a separate check. There are 11 possibilities at that position, and the paper gives an approximate random reference of 9%. The symbol 1 appears first in 20.3% of the sampled answers. Always selecting that symbol therefore provides a simple diagnostic reference for initial-character prediction.

Initial-character diagnostic on programs with length = 4 and nesting = 1 Favoring the common initial symbol provides a stronger reference than uniform guessing.

**The numbers**

| System or setting | initial-character accuracy % |
| --- | --- |
| Uniform guessing, approximate | 9 |
| Always select 1, strongest constant choice (this paper) | 20.3 |

The starred choice is the strongest constant-symbol diagnostic in this comparison, instead of a trained LSTM result. Its value reflects the empirical frequency of the most common initial character. The random reference is approximate, as the paper states.

This bias is meaningful but limited. It shows why random guessing is not the only simple reference worth considering. It does not provide a general method for predicting the rest of an integer or for following the source program.

Immediately before the terminator, the most frequent digit is 4, with probability 10.3%. The termination symbol itself is always last. These observations reinforce the need to distinguish predictable output structure from numerical content.

The authors report that larger numerical and structural settings also lack a sufficiently strong symbol bias to explain their prediction results. This is a useful check against a narrow shortcut. It does not eliminate more complicated approximations that exploit relationships among source patterns, answer prefixes, and familiar arithmetic cases.

### What the ablations show

#### The curriculum comparison isolates the example distribution

The paper’s most informative controlled comparison holds the recurrent architecture fixed while changing how examples are selected. Target-only training, staged progression, persistent mixing, and their combination expose the same architecture to different learning histories.

The baseline asks whether matching the final test distribution is sufficient. The naive curriculum asks whether mastering easier cases first creates a useful path towards the target. The mixed strategy asks whether a range of difficulties is enough without a prescribed stage. Combined training asks whether staged support and broad exposure work well together.

For program evaluation, the reported ordering favors the combination across every configuration shown. That supports a practical conclusion: the easy-to-hard component becomes more effective when it is supplemented by examples spanning the broader task range.

Copying qualifies the generality of that conclusion. Mixed training sometimes matches or exceeds the combined approach, even though both remain stronger than the baseline and naive curriculum. The evidence therefore supports the value of ongoing difficulty diversity more broadly than it supports a universal advantage for the particular combined schedule.

This distinction also resolves a tension in the paper’s language. Some passages describe combined training in broadly superior terms. The detailed copying results give the more precise boundary: superiority over mixed training is not uniform across those settings.

#### Changing the order of difficulty dimensions has little reported effect

The naive curriculum can advance numerical length before nesting or reverse that priority. The authors report no noticeable difference from this choice and use length-first progression thereafter.

This is a small but useful control. It suggests that the weakness of the naive curriculum cannot simply be attributed to selecting the wrong one of these advancement orders. The more consequential difference is whether training continues to include examples outside the current stage.

The paper does not provide detailed numerical results for the alternative ordering. It therefore supports the qualitative conclusion that the change was not noticeably important in the authors’ experiments, without establishing a precise bound on its effect.

#### Reversal changes the route from input to output

Input reversal is a controlled transformation because the required copied sequence remains unchanged. The system has access to the same symbols, but the order of exposure changes.

The authors’ explanation concerns which dependencies become short. Some output decisions can be associated with input symbols encountered relatively recently, giving learning a more accessible starting point. This can make the entire mapping easier to acquire even though reversal does not improve the average correspondence distance.

The comparison is informative about optimization and sequential organization. It does not show that reversed source is intrinsically more meaningful, nor that reversal would help every task. Its demonstrated setting is memorization of digit sequences with the tested recurrent architecture.

#### Repetition creates another processing opportunity

Doubling is a different intervention. The input becomes longer, while its informational content and target remain the same. Any gain therefore arises through how the recurrent computation uses the extra pass.

The authors interpret this as an opportunity to revisit information that may have been imperfectly represented earlier. This explanation fits the architecture: state changes after every character, so encountering the same material again can alter the stored representation before output begins.

The copying comparison shows that repetition and reversal can be complementary. Their combination gives the strongest reported input-presentation results. It does not isolate a single internal mechanism responsible for that gain, because the experiments do not directly inspect what changes in memory between passes.

#### Memory allocation is an explanation to test

The hidden-state allocation hypothesis connects the curriculum results with the memory task. Easy cases require less information than hard cases, but a learner has no explicit reason to reserve unused capacity for future demands. It may spread the information for an easy case across much of its state.

The authors illustrate this with the transition from remembering 5 digits to accommodating a 6-th digit. A representation that uses the available state generously for the easier case may need substantial reorganization when the task expands. Learning that reorganization could be difficult even if the architecture has enough capacity in principle.

Mixed examples would counter this pressure by making larger demands relevant from the beginning. Combined training would retain the helpful progression through simpler mappings while preventing easy stages from becoming the only influence on memory organization.

This is a plausible causal account, but the paper does not directly measure state occupancy, representation compression, or the cost of reorganizing memory. The experiments establish a difference between training strategies. They do not establish that memory allocation is the sole cause of that difference.

#### The diagnostic checks cover specific alternatives

The output-frequency analysis tests whether a few common symbols could explain apparent competence. The copying transformations test whether equivalent presentations change learnability. The curriculum comparisons test the effect of training distribution.

Together, these analyses make the results more interpretable than a single accuracy score would be. They still leave other alternatives open. In particular, they do not determine how much arithmetic is handled through general rules, how much depends on familiar local patterns, or how performance changes when the evaluation distribution is deliberately shifted.

### Limitations

#### Author-stated: high accuracy can coexist with an incomplete procedure

The authors explicitly question whether the learned computation resembles correct execution. Their addition examples explain why this matters. A system that adds corresponding digits while mishandling carries can still succeed on many positions. Another system might store results for small numerical combinations and reuse them without implementing a fully general algorithm.

These possibilities are relevant because the metric rewards correct local predictions. A method can obtain a strong score while failing on the cases that expose its missing rule. The difference between approximate success and exact computation is therefore central to the paper’s interpretation.

The authors do not determine how much their results depend on memorization. They also do not establish how closely the learned arithmetic follows a correct general procedure. This is an acknowledged open question, not an incidental omission.

#### Author-stated: training and testing share a distribution

The generated splits contain different examples, but they are drawn from the same task distributions. This tests whether learning transfers to unseen samples within the established numerical and structural regime.

It does not test a large discrepancy between training and evaluation. The authors identify such a discrepancy as a possible way to investigate whether the learner has acquired the underlying concepts. They leave that investigation for future work.

This boundary matters when interpreting the term execution. Correct behavior on held-out samples is evidence that the network has learned something beyond the identities of the individual training strings. It is not sufficient evidence that its procedure will remain correct when number lengths, structures, or combinations change substantially.

#### Author-stated: independent output generation is harder

Teacher forcing supplies information that would not be guaranteed during autonomous generation. After an incorrect prediction, the evaluation restores the correct prefix before continuing.

The authors expect a freely generating system to achieve lower accuracy. They do not report a corresponding numerical rate for complete, independently generated answers. As a consequence, the 99% addition result should remain attached to the stated supported-prediction protocol.

The supplementary examples require the same caution. Correct digits following an incorrect digit do not demonstrate recovery from the system’s own mistaken prefix. They show later predictions made after the correct preceding symbol has been supplied.

#### Author-stated: arbitrary programs exceed the architecture’s regime

The paper does not claim unrestricted execution. Its programs are chosen to fit a single-pass, fixed-memory recurrent computation. Multiplication and loops are constrained, nested loops are excluded, and external input is absent.

The discussion explicitly identifies programs requiring more than linear time as outside what conventional recurrent processing of this kind can provide. This is a resource limitation of the setup. More training examples cannot by themselves establish support for computations that require a different processing regime.

The reported success should therefore remain attached to the generated subclass. Source code that looks superficially similar may impose very different memory or runtime requirements once those restrictions are removed.

#### Author-stated: the best curriculum remains unknown

The combined strategy is effective in the experiments, but the authors do not identify an optimal training distribution. They suggest that understanding which examples are most useful could be necessary for better curriculum design.

The distinction between mixed and combined performance on copying reinforces this uncertainty. There is no single schedule that is demonstrated to dominate every alternative under every reported condition. The paper introduces a successful strategy and an explanatory hypothesis, instead of a complete theory of curriculum selection.

#### A careful reader’s limit: the generator defines the scope

All examples come from a synthetic program family. This gives the experiments precise control and an effectively renewable source of labeled cases. It also makes the generator’s choices part of the result.

The architecture encounters selected operations, selected source patterns, bounded numerical ranges, and bounded compositions. The experiments do not establish robustness to unfamiliar formatting, a broader syntax, external state, or operations absent from the generator.

This limitation does not make the task trivial. The source still requires meaningful numerical and structural dependencies. It means that competence should be described relative to the family actually tested rather than generalized to arbitrary source code.

#### A careful reader’s limit: the controls do not identify a unique mechanism

The curriculum experiments show that changing training examples changes performance. The input transformations show that processing order and repeated exposure matter. Neither comparison directly reveals the internal procedure that produces the answer.

Memory allocation is one plausible explanation. Other changes in learned state dynamics could also contribute. Without direct interventions or measurements targeting the proposed mechanism, the evidence supports the training effect more strongly than the causal story.

Similarly, the absence of a dominant output-symbol bias removes only a simple explanation. A learner could still exploit more elaborate regularities in the generated programs or in the correct prefixes supplied during evaluation.

#### A careful reader’s limit: training duration needs explicit interpretation

The experimental description includes a copying budget of 20 epochs, while the main copying results discuss convergence and the supplementary material reports the fixed-budget condition. These are distinct reporting conditions.

A reader should therefore avoid interpreting all copying comparisons as measurements under an identical fixed amount of training. The text supports conclusions about the patterns reported in each condition, but it does not provide a full numerical accounting that would separate final quality from learning speed in every setting.

The program experiments also use learning-rate-based termination instead of a shared fixed training budget. That is relevant when assessing claims about optimization efficiency. Better final accuracy and faster progress are related questions, but they require their own evidence.

#### A careful reader’s limit: character accuracy is an incomplete execution specification

A practical executor must produce the exact answer, terminate appropriately, and behave predictably across its supported language. The paper’s reported metric addresses a narrower component of that requirement.

The answer alphabet includes both numerical content and formatting. Some positions are easier because the terminator has a fixed role or because certain initial digits occur more often. The authors investigate these effects, but a single overall score does not reveal how errors are distributed across carries, variable dependencies, conditional choices, and termination.

A fuller specification would need to identify those failure categories and evaluate complete outputs. Learning to Execute provides evidence that substantial execution-related behavior can be learned, while leaving the reliability requirements of a dependable interpreter unresolved.

### What came after

Learning to Execute sits at an intersection that later citing work explores from several directions: textual computation, program-related tasks, memory architecture, mathematical reasoning, and evaluation. These citation relationships establish that the paper remained relevant to those discussions. A citation alone does not establish that a later work adopted its combined curriculum, repeated-input technique, or execution architecture.

#### Computation expressed through text

[Chain-of-Thought Prompting Elicits Reasoning in Large Language Models](https://md.research.elamur.ai/free/en/papers/wei-2022-chain-thought-prompting-elicits-reasoning/) belongs to the later work on prompting for reasoning. Its title identifies reasoning elicited through chain-of-thought prompting as the focus. The connection with Learning to Execute is the broader question of how a sequential language system carries out a computation that is not directly available as a copied answer.

Learning to Execute makes this question concrete through deterministic program outputs. It also exposes an interpretive problem that remains relevant when discussing textual reasoning: producing accurate answers does not, on its own, identify the procedure used internally. The citation connection supports placing the works in that shared research conversation; it does not establish that the prompting method uses the earlier curriculum strategy.

[Show your work: Scratchpads for intermediate computation with language models](https://md.research.elamur.ai/free/en/papers/al-2021-show-your-work-scratchpads-intermediate/) explicitly concerns scratchpads and intermediate computation. This provides a natural point of comparison with a recurrent system that must retain its useful intermediate information in a fixed internal state while reading the source.

The useful continuity is the problem of where computation is represented. In Learning to Execute, hidden-state capacity and organization motivate the curriculum hypothesis. Scratchpads, as named in the later work, bring intermediate computation into the scope of the textual task. The citation establishes relevance, while the exact relationship between the implementations is not specified by that connection alone.

#### Code generation and code execution

[Evaluating Large Language Models Trained on Code](https://md.research.elamur.ai/free/en/papers/chen-2021-evaluating-large-language-models-trained/) concerns the evaluation of systems trained on source code. Learning to Execute supplies an earlier, tightly controlled example of pairing program text with a computationally defined target.

The important distinction between the questions is the direction of the task. Reading a program and predicting its result is a particular form of code understanding. A broad evaluation of systems trained on code can raise additional questions. The later title establishes its subject, but it does not by itself specify which execution tests, training schedules, or metrics it inherits from the earlier study.

[Program Synthesis with Large Language Models](https://md.research.elamur.ai/free/en/papers/austin-2021-program-synthesis-large-language-models/) places program synthesis in the foreground. Synthesis concerns producing a program, whereas Learning to Execute begins with a program and asks for its answer. These directions are related through the need to connect textual structure with computational behavior.

The earlier paper is useful background for that connection because it separates familiarity with source characters from success on a semantic target. Its limitations are equally relevant: agreement with examples does not automatically establish a general procedure. The citation relationship does not justify attributing the combined curriculum or a particular synthesis technique to the later work.

[Code Execution with Pre-trained Language Models](https://md.research.elamur.ai/free/en/papers/liu-2023-code-execution-pre-trained-language/) names the closest later task connection. Both titles concern obtaining execution-related behavior from a language-processing system. The later title adds pretraining as part of its framing.

Learning to Execute contributes a clear experimental reference point for this line of inquiry: generated source, controlled difficulty, a definite answer, and an explicit warning about teacher-forced evaluation. A comparison with later execution work should preserve those details. Shared task language does not guarantee that the supported program family, evaluation protocol, or generalization claim is the same.

#### Testing whether a procedure generalizes

[Universal Transformers](https://md.research.elamur.ai/free/en/papers/dehghani-2018-universal-transformers/) develops a concern directly relevant to the earlier paper’s critique: a sequence system can do well on familiar examples while failing to acquire a procedure that extends beyond them. Copying illustrates the issue. Success on shorter strings does not establish correct copying on much longer strings.

This sharpens the interpretation of Learning to Execute’s memorization results. Its comparisons show that curricula and input transformations improve performance within the evaluated length settings. The stronger question is whether a learned rule survives a change in the demands placed on it. That is exactly the type of distributional test the earlier authors identify as unfinished work.

[Compositionality decomposed: how do neural networks generalise?](https://md.research.elamur.ai/free/en/papers/hupkes-2019-compositionality-decomposed-neural-networks-generalise/) places generalization and composition at the center of its title. Learning to Execute offers a concrete setting in which these issues separate. A system may handle familiar operation combinations at tested nesting levels without demonstrating a general method for composing them under substantially different conditions.

The useful connection is therefore a question about evaluation: which change in the test cases would distinguish familiarity with a generated distribution from a reusable compositional procedure? The citation establishes the paper’s relevance to that discussion without specifying a particular experimental inheritance.

[Analysing Mathematical Reasoning Abilities of Neural Models](https://md.research.elamur.ai/free/en/papers/saxton-2019-analysing-mathematical-reasoning-abilities-neural/) similarly points toward systematic evaluation of mathematical behavior. Learning to Execute’s addition task makes one such behavior easier to inspect by separating it from the broader program mixture.

The earlier paper’s own warning remains essential in that context. High numerical accuracy can arise from an incomplete treatment of carries or from stored local patterns. The connection is strongest as an evaluation problem: identify the mathematical capability being tested and choose conditions that reveal where the procedure stops working.

#### Structured representations and memory

[Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks](https://md.research.elamur.ai/free/en/papers/tai-2015-improved-semantic-representations-tree-structured/) concerns tree-structured LSTM representations. Its topic connects with a central architectural tension in Learning to Execute: the source has compositional structure, but the learner receives a linear character stream.

The earlier paper explicitly contrasts recurrent processing with tree-based architectures that have a more natural route to composition. The later title identifies tree structure as part of the representation being studied. This is a relevant architectural connection, although the citation does not establish that the later work addresses the same program generator or execution task.

[Neural Random-Access Machines](https://md.research.elamur.ai/free/en/papers/kurach-2015-neural-random-access-machines/) belongs to the later work concerned with a different computational framing. Its title brings memory access to the foreground, which makes it relevant to the fixed-state constraints of Learning to Execute.

The earlier experiments show why memory is a substantive issue rather than an implementation detail. Values must remain available across the source, and curriculum design may influence how that capacity is organized. The later citation can be situated around those questions without assuming particular mechanisms or results beyond what its title establishes.

Across these connections, Learning to Execute contributes a durable experimental stance. It pairs a precise computational target with a deliberately limited learner, varies the training experience, and remains cautious about the meaning of success. Later work can extend the task, alter the representation, or ask for stronger generalization. The earlier result retains its value when its conditions remain visible: restricted programs, controlled distributions, learned sequential state, and accuracy measured with correct answer prefixes.

## Cite

Cite as Wojciech Zaremba and Ilya Sutskever. 2014. Learning to Execute. arXiv:1410.4615.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.1410.4615](https://doi.org/10.48550/arxiv.1410.4615) · [arXiv 1410.4615](https://arxiv.org/abs/1410.4615)

```bibtex
@misc{zaremba2014learning,
  title = {{Learning to Execute}},
  author = {Wojciech Zaremba and Ilya Sutskever},
  year = {2014},
  doi = {10.48550/arxiv.1410.4615},
  eprint = {1410.4615},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1410.4615}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
