Stochastic model, deterministic math

One afternoon of RL on arithmetic with a 0.8B model

Nov 30, 2026

A calculator is deterministic. Ask it for 4821 + 3977 and it returns 8798, every time.

A language model is not. It writes its answer one token at a time, and each token is sampled from a probability distribution. Ask it the same question twice and you can get two different answers.

We were curious whether a model like that can still be reliable on a task that has exactly one right answer. So we spent one afternoon on it. We took a small open model, wrote a reward that checks its answer against Python, and did a single RL training run on one GPU.

This is a small experiment, not a new method. RL with verifiable rewards is a well-known recipe, and we did not invent any part of it. We are sharing what we saw in case it is useful to someone.

This post asks one question: can a stochastic model get good at deterministic arithmetic?

We find that 30 training steps took the model from 50.5% to 89.0% on held-out problems, and that sampling mostly stopped hurting it. Addition and subtraction reached 100%. Large multiplication and division are still weak.

Setup

The task

The model is Qwen3.5-0.8B, the instruction-tuned version, with its thinking mode off. Every problem is one line of integer arithmetic: addition, subtraction, multiplication or division. The prompt is always the same: “Compute 4821 + 3977. Put the final answer in \boxed{}.”

The reward is as simple as we could make it. Python computes the true answer. If the last boxed number in the model's reply equals it, the reply scores 1. Otherwise it scores 0. There is no partial credit and nothing is judged by another model.

We evaluate on 200 held-out problems, 50 per operation, with operands from 1 to 7 digits. None of them appear in training. For evaluation the model decodes greedily, meaning it always takes its most likely token, and each answer can be at most 1024 tokens long.

Training

We train with GRPO, a reinforcement learning method. For each problem the model samples 16 answers at temperature 1.0. Answers that scored above the average of their group of 16 are made more likely, and answers that scored below are made less likely. If all 16 are right, or all 16 are wrong, there is nothing to compare, so that problem is skipped.

One training step is 24 problems, so 384 sampled answers, followed by one update to the model. We ran 30 steps at a learning rate of 1e-6. The training problems are addition and subtraction with 4 to 7 digits, multiplication with 2 to 4 digits, and division with 3 to 6 digits.

The whole run took under two hours on a single 24 GB GPU. It is the only training run we did. We did not search over hyperparameters or pick the best of several runs.

Figure 01

One training step

24 problems model samples 16 answers Python checks the box one update from a fixed list temperature 1.0 reward 1 or 0 GRPO REPEATED 30 TIMES
One training step. The model samples 16 answers to each of 24 problems. Python checks the boxed number in every answer, and the model is updated once. The parts in black are the model.

Results

Before training

Before any training, the model gets 50.5% of the held-out problems right. It does not use tools. It writes out the working step by step, the way a person does column arithmetic on paper, and then boxes a number.

The misses come in two kinds. Of the 99 problems it gets wrong, 53 end in a wrong number. The other 46 never end at all: the model runs into the 1024-token limit, either repeating the same line or re-checking its own work again and again. More room does not fix this. With a limit of 4096 tokens, 25 of those 46 still did not finish.

We also ran the same evaluation with sampling at temperature 1.0 instead of greedy decoding. Accuracy fell from 50.5% to 29.3%, averaged over three runs. Nothing about the model changed, only how its tokens were picked. A worked answer is hundreds of tokens long, and one unlucky token in a carry is enough to ruin it.

The training run

We evaluated the model every 10 steps during training. Accuracy on the held-out problems went from 50.5% to 66.5% at step 10, 79.5% at step 20, and 89.0% at step 30.

Addition and subtraction both reached 100% by step 20, at every size in the evaluation, and stayed there. Multiplication went from 58% to 80% and division from 46% to 76%. Almost all of the remaining errors are large problems: 5-digit multiplication is at 20% and 7-digit division at 30%.

Figure 02

Held-out accuracy before and after training

Accuracy on the 200 held-out problems. Left: before and after training, overall and for each operation. Right: the four evaluations during the run (squares), and the share of sampled training answers that were correct at each step (line).

What changed

The clearest change is that the answers got short. At the start of training, a sampled answer was 766 tokens long on average and 55% of them hit the token limit. By the end, the average was about 100 tokens and 1% hit the limit. The model stopped writing out column-by-column working and started stating the result directly.

With short answers, sampling has far fewer chances to go wrong. We repeated the sampling test on the trained model: 86.7% with sampling at temperature 1.0, against 89.0% with greedy decoding. Before training that gap was 21 points. After training it is about 2.

Figure 03

Sampling and answer length

Left: held-out accuracy with greedy decoding and with sampling at temperature 1.0, before and after training. Sampled scores are the average of three runs. Right: the average length of a sampled training answer at each step.

Samples

The same held-out problem, 902 + 686, answered before and after training. Both answers are greedy and unedited. The correct answer is 1588.

Before training · 158 tokens

To compute the sum $902 + 686$, we can add the numbers column by column from right to left.

1.  **Units place**: $2 + 6 = 8$
2.  **Tens place**: $0 + 8 = 8$
3.  **Hundreds place**: $9 + 6 = 15$

Since the result in the hundreds place is $15$, we write $5$ and carry over $1$ to the thousands place.

Now, add the carried $1$ to the thousands place:
$15 + 1 = 16$

So, the final sum is $1658$.

\boxed{1658}

After training · 43 tokens

To compute the sum $902 + 686$:

$$
902 + 686 = 1588
$$

\boxed{1588}

Is it just the prompt?

If the untrained model loses so many points to long, rambling answers, maybe a better prompt would have been enough. We tested this as a control. We wrote four other prompts that ask the untrained model for a short answer, and evaluated each one.

The best of them reached 63.5%. So a better prompt recovers about a third of the gain, and training adds roughly 25 points on top of it.

One prompt told the model not to show any working. With it, the untrained model gets 96% on addition, up from 46%. For addition, the model could already do the sums. Its own working was getting in the way. That is not true for the other operations: no prompt took the untrained model above 74% on subtraction, 60% on multiplication or 68% on division, and training reached 100%, 80% and 76%.

The trained model also did not simply delete its working. When we force it to show none, multiplication drops from 80% to 30% and division from 76% to 38%. It kept a short version of the working where it still needs it.

Beyond the training range

The training problems stop at 7 digits for addition and subtraction. We tried the trained model on 20 fresh problems at each of a few larger sizes. It got 100% on 8-digit addition, 100% on 9-digit addition, and 95% on 8-digit subtraction.

Multiplication and division did not carry over the same way. 5-digit multiplication, one digit past the training range, was 10%. 7-digit division was 35% and 8-digit division 55%.

Limitations

This is one training run with one random seed, done in one afternoon. We do not know how much the result would move if we ran it again. The method itself is standard, so nothing here should be read as a new technique.

The evaluation is small. It has 200 problems, which is 10 for each combination of operation and size. The overall numbers are reasonably stable, but a single cell such as “5-digit multiplication, 20%” is 2 problems out of 10 and should be read as rough.

The scope is narrow. We trained and tested integer arithmetic in one prompt format. The trained model is tied to that format: under our other prompt wordings it scored between 64% and 87%. We also did not test whether training changed anything else the model can do.

Finally, the prompt control used four prompts we wrote by hand. It is not a search, and someone could find a prompt that does better than 63.5%.

Open questions

The main open question is how much of this is arithmetic and how much is learning when to stop talking. For addition, the control suggests most of the gain is the second kind. For the other three operations it is not, but we have not separated the two cleanly.

A second question is large multiplication and division. Our method can only reinforce answers the model sometimes gets right. On a problem where all 16 sampled answers are wrong, there is nothing to learn from. Two ideas we have not tested are training only on the hard sizes, and on-policy distillation, where a larger model guides the small one on the small one's own answers.


Citation

Please cite this work as:

Clevr Labs, "Stochastic model, deterministic math", Clevr Labs: Research, November 2026.

Or use the BibTeX citation:

@article{clevrlabs2026arithmetic,
  author = {Clevr Labs},
  title = {Stochastic model, deterministic math},
  journal = {Clevr Labs: Research},
  year = {2026},
  note = {https://theclevr.com/research/math-arithmetic}
}