Manuscript Offprint

arXiv:2611.00783

A Tool in the Forward Pass: Frozen Tape Modules as Layers of a Small Language Model

Michael Granitzer, Saber Zerhoudi, Mohammad Al-Maamari, Hai Dang Dang, Kanishka Ghosh Dastidar

Michael Granitzer University of Passau Passau, Germany

Saber Zerhoudi University of Passau Passau, Germany

Mohammad Al-Maamari University of Passau Passau, Germany

Hai Dang Dang University of Passau Passau, Germany

Kanishka Ghosh Dastidar IT-U Interdisciplinary Transformation University Austria Linz, Austria

One item (tracking shuffled objects, BIG-Bench Hard): Alice, Bob and Claire hold a red, a blue and a green ball. First, Alice and Bob swap balls. Then, Claire and Alice swap balls. Finally, Bob and Claire swap balls. At the end of the game, Bob has the (A) red ball (B) blue ball (C) green ball. Answer: (B).

(a) A tool as a program

program of thought: the model writes code, an interpreter runs it

balls = ("Alice": "red", "Bob": "blue", "Claire": "green") for a, b in ["Alice", "Bob"], ("Claire", "Alice"), ("Bob", "Claire"): balls[a], balls[b] = balls[b], balls[a] print(balls["Bob"]).

Python interpreter

→ "blue" → (B)

Every generated token is one forward pass: 252 tokens per item at seven people (gamma-3-4b-it, accuracy 0.76).

(b) A tool through text (baseline)

the model writes the tool's input; hand-written code computes

... At the end of the game, Bob has the Call: Alice Bob Claire Alice Bob Claire Bob =

8 generated tokens = 8 more forward passes

swap code (hand-written)

→ Bob → (B)

Learned by adapters on our own stories: 17 tokens per item at seven people (gamma-3-1b-it, accuracy 0.99).

(c) A tool as a layer (this paper)

inside the one forward pass that reads the prompt

layers 1–8

writer

A B C A B C B tape

reader

module (frozen)

layers 9–26

→ (B)

round 1: A B C A [B C B] → C round 2: A B [C A C] → A round 3: [A B A] → B (Bob's own)

Writer and reader learned, module trained alone; gamma frozen. One forward pass (gamma-3-1b-it, accuracy 1.00).

(d) The tape layer in detail

Figure

gamma-3-1b-it (frozen; adapters only where stated)

(e) Result: near-equal accuracy, less cost

accuracy shown at seven people; GPU time per item at seven people relative to the layer (log scale)

Figure

Separate experiments: answer-only training succeeds in some runs; two gated layers share one frozen model and preserve its answers on the tested negative prompts.

Figure 1: One computation, three interfaces. (a) The model generates a program for an interpreter. (b) It generates only the inputs to a fixed tool. (c) A learned writer constructs those inputs directly from hidden states. A frozen neural module computes the result, and a reader returns it to the model. The tape traces Bob's final object back through the swaps to its original owner. (d) The layer's components. (e) Measured GPU kernel time at seven people, relative to the layer, with each method's accuracy (§5.2).

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 gamma-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.

1 Introduction

A language model that uses a calculator, an interpreter or a database writes the call as text, waits for the result and reads it back [5, 12, 26]. This interface is flexible, but generating the call requires sequential decoding steps. The returned result must also be processed by the model, although its tokens can be processed together. For a short computation inside a longer answer — arithmetic in a word problem, the state of a few objects in a story — the call can cost more than the answer.

A tool can instead sit inside the forward pass (Figure 1, a-b against c). A writer reads hidden states and hands the tool its input, the tool computes, and a reader writes the result back, all in one pass. Earlier work has shown this with exact code as the tool and a writer supervised on annotated operands [9, 10], and with a symbolic network steered from hidden states [11]. We examine four questions in this setting. Can the tool be a learned module, trained on its own and frozen, so that modules can be developed and exchanged independently (RQ1, and RQ5 for several modules)? What does a tool in the forward pass save against the same tool used through text, at near-equal accuracy (RQ2)? How can the model learn what to hand the tool when nobody labels the tool's input (RQ3)? And does the interface read wording it was never trained on (RQ4)?

We study these questions with a tape layer (Figure 1c, d). The intuition is a scratchpad that the model fills in without writing a word: instead of spelling a computation out as text, the model places its inputs on a short row of cells inside the forward pass, a small specialised network computes on that row, and the result is handed back to the model's hidden state.

Conceptually, the row is a symbolic tape: a short sequence of cells, each holding one discrete symbol from a small alphabet, with a tape language that fixes which tapes are well formed and what they mean. A tape module is a small network that rewrites the tape step by step, each step replacing a few neighbouring cells by one, until a single cell holds the result. The module is trained alone, on tapes only, and then frozen. The tape layer connects it to a language model: a learned writer reads the hidden states and fills the tape, the frozen module computes, and a learned reader adds the result back to the hidden state from which the model answers.

Concretely, we use two tasks, each with its own tape language and module, in gamma-3-1b-it [14]. In arithmetic, the tape is the expression itself, such as 3+4*2, and the module evaluates it. This is the development task on which the layer was designed. In tracking shuffled objects from BIG-Bench Hard (BBH), a benchmark of hard reasoning tasks [27], people exchange objects and the question asks what one of them holds at the end. The tape lists who swaps with whom, followed by the person asked about (Figure 1c). We chose this task after developing the arithmetic architecture. Its benchmark items are excluded from training, but later interface decisions were informed by experiments on this task. It is therefore a transfer case study, not a completely untouched test of the final design.

The central result is a cost reduction at near-equal accuracy: the layer performs the computation during prompt processing, while the text-tool baseline generates its inputs token by token. Our contributions are:

  • A learned tool that the model uses (RQ1). The tool is a small network trained alone on tapes, then frozen. One check shows that it computes correctly on the tapes the model writes: replacing it by exact code of the same computation gives the same accuracy. A second shows that the answer depends on it: removing its result from the hidden state drops accuracy to chance (§5.1).
  • Length extrapolation (RQ1). The module applies one small rule round after round, so a longer input needs more rounds, not new parameters. Trained on up to six operators, it reaches 0.97–1.00 at twenty-four. As a layer, the model answers 1.00 at twelve operators, where the same model with adapters alone answers 0.10–0.12, and it is exact on seven exchanges after training on at most five (§5.1).
  • A tool call without generated tokens (RQ2). On seven-person object tracking, the layer is as accurate as the same model calling exact code through text (1.00 against 0.99) at 1/10 of its GPU kernel time per item at batch size one (§5.2).
  • Which tokens to hand the tool, learned from answers (RQ3). Without labelled tapes, rewarding tapes whose result is right trains the writer: 5 of 6 runs in gamma-3-1b-it and 2 of 4 in gamma-3-4b-it become exact. A hand-written prior supplies each token's symbol (digits and operators, a fixed name-to-index lexicon), so reward learns which tokens to mark, for example to leave out the story's introduction, not what the symbols mean. Gradients through the frozen module destroy the writer instead (§5.3).
  • Unseen wording (RQ4). On benchmark items rewritten by another language model, writers on the frozen model reach 0.87–0.96, while gamma-3-4b-it with chain of thought falls from 0.96 to 0.71 at seven people (§5.4).
  • Tools added independently (RQ5). Two layers trained separately, each for its own task, share one frozen model. Each stays as accurate as alone, and with a learned gate neither acts on any of 3,800 general and look-alike prompts, so accuracy on MMLU, a multiple-choice knowledge benchmark [18], equals the base model's (§5.5).

The claim concerns two task-specific tape languages, fixed computation budgets and single-symbol outputs. It does not establish a general tool interface or an advantage of learned execution over exact code. On both tasks exact code would have served as well. The learned module is a feasibility result for tools that have no code, or that should be trained and exchanged independently. Registered predictions and their outcomes, including failures, are listed in Appendix B.

References (23)