A Tool in the Forward Pass: Frozen Tape Modules as Layers of a Small Language Model
Organizations: University of Passau, Passau, Germany · IT:U Interdisciplinary Transformation University Austria, Linz, Austria
Abstract
Calling a tool through generated text adds decoding steps, even when the computation itself is short. We study an alternative: a small neural module that runs inside a language model's forward pass. A learned writer turns hidden states into a symbolic tape, a short sequence of discrete symbols that encodes the computation. The module, trained separately and then frozen, reduces the tape to a result, and a learned reader returns that result to the model. We evaluate arithmetic and object tracking in gemma-3-1b-it. With a writer trained on labelled tapes, the layer answers all 750 items of BIG-Bench Hard's tracking shuffled objects correctly. At seven people it needs about 1/10 of the GPU kernel time of a text-tool baseline that uses the same host model and exact code, with accuracy 1.00 against 0.99. The writer can also be learned from answers alone, guided by a hand-written copying prior, but less reliably: 5 of 6 runs succeed in the 1B host and 2 of 4 in the 4B host. Two independently trained layers keep their task accuracy when attached to one model, and a learned gate keeps them silent on the tested general-text and look-alike prompts. The results support a narrow use case: a bounded computation that returns one symbol can avoid the decoding cost of a textual tool call. Extracting the right input reliably, and deciding when to act, remain the main open problems.
Figures & tables
| module, trained from its final tape only | trained on | at the longest trained | at 4 | 16-place carry chain | formed |
|---|---|---|---|---|---|
| addition, discrete tape (straight-through) | 1–4 digits | 0.08–1.00 | 0.00–1.00 | 0.00–1.00 | 3 of 4 |
| + a continuous state per cell | 1–4 digits | 1.00 | 0.98–1.00 | 0.99–1.00 | 4 of 4 |
| trained soft, used hard | 1–4 digits | 0.02–0.30 | 0.00 | – | 0 of 4 |
| multiplication (either tape) | 1–4 digits | 0.00 | 0.00 | – | 0 of 8 |
| operator order: selector + column, length curriculum | 1–6 operators | 1.00 | 0.97–1.00 | – | 4 of 4 |
| no curriculum | 1–6 operators | 0.19–1.00 | 0.12–1.00 | – | 2 of 4 |
| how the writer is trained | tape labels | 4–6 ops | unseen templates | 12 ops | tapes exact | swap | reader off |
|---|---|---|---|---|---|---|---|
| adapters only, no tape | – | 0.35–0.38 | 0.28–0.34 | 0.10–0.12 | – | – | – |
| answers only, gradient through the soft module | none | 0.37 | 0.29–0.31 | 0.10–0.12 | 0.00 | 0.28–0.36 | 0.12 |
| answers only, straight-through | none | 0.34–0.41 | 0.29–0.33 | 0.09 | 0.00 | 0.32–0.34 | 0.11–0.16 |
| answers only, reward (module a black box) | none | 0.36–0.39 | 0.30–0.31 | 0.07–0.11 | 0.00 | 0.32–0.34 | 0.14–0.17 |
| answers only, ReinMax ‡ | none | 0.24–0.30 | 0.17–0.18 | 0.12 | 0.00 | 0.20–0.27 | 0.20–0.25 |
| answers only, I-MLE ‡ | none | 0.24–0.25 | 0.16–0.20 | 0.08–0.10 | 0.00 | 0.20–0.21 | 0.18–0.21 |
| accuracy | wall-clock (ms) | GPU kernels (ms) | floor | ||||
|---|---|---|---|---|---|---|---|
| per question | 4–6 ops | unseen templates | B1 | B16 | B1 | B16 | (ms) |
| text tool: adapters copy the expression, exact evaluator (code) | 0.99–1.00 | 0.93–0.98 | 235 | 255 | 103 | 138 | 32 |
| tape layer (frozen module after layer 8) | 1.00 | 0.55–0.59 | 20 | 25 | 8.9 | 16.0 | 2 |
| gemma-3-4b-it, chain of thought | 0.94 | – | 3091 | 8010 | – | – | – |
| accuracy, people | per item at 7 people | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| 3 | 5 | 7 | tokens | wall B1 (ms) | kernels B1 (ms) | wall B16 (ms) | floor (ms) | layer | |
| tape layer: frozen swap module after layer 8, writer taught which tokens to mark | 1.00 | 1.00 | 1.00 | 0 | 31 | 11.0 | 5.1 | 2 | 1 |
| text tool: adapters write the names, code runs the swaps | 1.00 | 0.98 | 0.99 | 17 | 328 | 112.4 | 23.5 | 34 | 10 |
| gemma-3-1b-it, chain of thought | 0.85 | 0.57 | 0.34 | 485 | 8099 | 2842.8 | 597.3 | 970 | 257 |
| gemma-3-1b-it, program-of-thought | 0.05 | 0.07 | 0.05 | 439 | 7372 | 2124.9 | 838.5 | 878 | 192 |
| gemma-3-4b-it, chain of thought | 1.00 | 0.96 | 0.93 | 534 | 11832 | 6864.0 | 927.1 | 4596 | 621 |
| BBH, people (= swaps) | synthetic | tapes exact | reader off | tokens | |||
|---|---|---|---|---|---|---|---|
| model | 3 | 5 | 7 | 7 people, 10 swaps | BBH 7 | BBH 7 | generated |
| gemma-3-1b-it, answers directly | 0.32 | 0.21 | 0.13 | – | – | – | 4 |
| gemma-3-1b-it, chain of thought | 0.85 | 0.57 | 0.34 | – | – | – | 492 |
| gemma-3-4b-it, answers directly | 0.31 | 0.12 | 0.08 | – | – | – | 5 |
| gemma-3-4b-it, chain of thought | 1.00 | 0.96 | 0.93 | – | – | – | 536 |
| 1B + adapters on our stories, no tape | 0.98–1.00 | 0.93–0.95 | 0.78–0.83 | 0.46–0.54 | – | – | 0 |
| rewritten, people | original, people | tape right | fires | |||||
|---|---|---|---|---|---|---|---|---|
| 3 | 5 | 7 | 3 | 5 | 7 | rewritten, 7 | rewritten | |
| layer, adapters, marks taught | 0.43–0.81 | 0.40–0.86 | 0.27–0.85 | 1.00 | 1.00 | 1.00 | 0.21–0.82 | 1.00 |
| layer, no adapters, marks taught | 0.94–0.96 | 0.94 | 0.87–0.88 | 1.00 | 1.00 | 1.00 | 0.87–0.88 | 1.00 |
| layer, no adapters, from answers alone | 0.94–0.95 | 0.91 | 0.90–0.94 | 1.00 | 1.00 | 1.00 | 0.90–0.94 | 1.00 |
| with the prompt gate of Table 8 | 0.67 | 0.45 | 0.62–0.63 | 1.00 | 1.00 | 0.97–1.00 | 0.76–0.78 | 0.39–0.53 |
| gate trained with rewrites of our stories | 0.84–0.86 | 0.83–0.84 | 0.82–0.83 | 1.00 | 1.00 | 0.97–1.00 | 0.76–0.78 | 0.73–0.88 |
| alone | together | change | tapes exact | fires: other layer; arithmetic / swap writer | |
| arithmetic, 4–6 operators | 1.00 | 1.00 | +0.000 | 1.00 | 0.00 |
| unseen templates | 0.39–0.73 | 0.39–0.73 | +0.000 | 0.34–0.69 | 0.01 |
| 12 operators | 0.96–1.00 | 0.96–1.00 | +0.000 | 0.95–0.99 | 0.00 |
| state tracking, 7 people, 10 swaps | 1.00 | 1.00 | +0.000 | 1.00 | 0.00 |
| BBH, 3 people | 1.00 | 1.00 | +0.000 | 1.00 | 0.00 |
| BBH, 5 people | 1.00 | 1.00 | +0.000 | 1.00 | 0.00 |
| MMLU (base 0.382) | fires: general text | fires: BBH logic | fires: GSM8K | BBH tracking, 7 | |
|---|---|---|---|---|---|
| writer trained on general text; marks nothing adds nothing | 0.368–0.370 | 7.2–9.0 % | 86.8–92.4 % | 54.0–80.8 % | 1.00 |
| + question negatives, well-formed tape | 0.376–0.386 | 7.2–9.0 % | 36.0–38.0 % | 28.2–37.2 % | 0.99–1.00 |
| + the tape must compute (an operator, a swap) | 0.382 | 0.4 % | 0.0–4.8 % | 0.2–0.6 % | 0.99–1.00 |
| + a learned gate on the whole prompt | 0.382 | 0.0 % | 0.0 % | 0.0 % | 0.99–1.00 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| label (measurement) | prediction | outcome |
|---|---|---|
| e2e1b-a (operator order) | at 6 operators on 3 of 4; at 24 on 2 of 4 | confirmed (4 of 4; 0.97–1.00) |
| e2e1b-b, c (curriculum; straight-through) | without curriculum lower; straight-through | refuted on the median (forms on 2 of 4); confirmed |
| e2e1b-d, e (no-ops) | twice the rounds change ; cost | confirmed |
| e2e2-a, b (layer) | adapters alone ; tape labels , swap within 0.02 | confirmed (0.35–0.38; 1.00, swap identical) |
| e2e2-c (answers only) | on one seed | refuted (0.37, no exact tape) |
| e2e2-d, e (warm start; reader off) | warm within 0.05 of labels; reader off | confirmed, d only through the checkpoint kept while supervised |
LLM Tool Use
Large language model tool use studies how models select, call, and coordinate external tools to extend their reasoning and take actions.
See all 307 papers