Manuscript Offprint

arXiv:2610.31125

Delta N-gram: Forward-Only Continual Writing into a Language Model's Native N-gram Memory

Hao Wu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Our previous analysis found that a model’s native hashed N-gram table is where continual updates disturb the base least, but its writes needed backpropagation and changed the pretrained table. We present Delta N-gram, a forward-only write path into that table. The pretrained table T0T^{0} is never modified. Evidence is written into a sparse patch Δ\Delta on the rows it addresses: a 4.1M-parameter writer emits a target and a gate per (position, hash head) event, and a block-averaged delta rule keeps each row a convex combination of its old value and the gated targets. The writer is trained offline on raw text with the pretraining objective; at use time writing takes forward passes only, and clearing Δ\Delta restores the original model. A 0.6B prototype trained to answer questions keeps 16/16 facts after a second write; online gradient writes keep 2–4/16. We study two writers: a plain writer that encodes evidence with the T0T^{0}-only model, and a delta writer that reads its current memory while encoding. On Qwen3.8-Flash-Next, the plain writer’s memory is document-specific: on 64 held-out news events it lowers continuation NLL by 0.068 nats/token against empty memory and by 0.024 against another document’s memory, and 0.063 and 0.013 after 16 intervening articles. The delta writer’s memory is more document-specific and keeps more of it under distraction (70% vs 54%). Over 35,000 writes on our previous seven-task chain both writers stay stable and the delta writer drifts less (layer-2 math drift 176% vs 188%); later accuracy changes by -0.26/-0.52pp (-7.29pp for gradient updates) and small- kik_{i} drift is 17.9/17.5% (39.2%). Acquisition is negative, and general-input drift reaches 32.8% (20.75%): format rows read by every example grow to 4–12 times their pretrained norm. Zeroing eight such rows removes over 98% of layer-2 drift on math inputs, together with their NLL gain.

1 Introduction

A model that learns while it is used has to write new information somewhere, and every write is paid for by what it disturbs. In our previous work, Representation Drift [31], we compared three places to write on the same 48-layer mixture-of-experts model: the rows of its native, pretrained hashed N-gram table [26], one continually trained LoRA adapter [11], and a fresh LoRA per task merged into the backbone. Updating only the N-gram table changed the base model's representations of general inputs least (big-K drift 26%/15% on math/code, against 64–97%/35–39% for LoRA), and this drift did not grow with the number of tasks. We concluded that long-running online learning should write new knowledge only into the memory table and keep the backbone fixed.

That conclusion was reached with an expensive and irreversible write. Every table update in [31] was an Adam step: a full backward pass through the network per write, optimizer state per row, labels to define the loss, and a table that, once changed, no longer contains its pretrained values. A system that writes continually during use needs the opposite properties. Writing should cost a forward pass, need no labels or task boundaries, and leave the pretrained knowledge recoverable.

This paper builds that write path. We keep the pretrained table T0T^{0} fixed and write into a sparse patch Δ\Delta, so the model reads T0+ΔT^{0} + \Delta. A small writer, trained offline, turns each block of evidence into writes. For every event, that is, every (position, hash head) pair, it emits a target v and a gate β\beta from the frozen model's hidden states. Events that address the same row in a block are averaged and applied with a delta rule we call D1. D1 moves the row toward the gated targets and keeps it a convex combination of its old value and those targets. Seen from linear attention, this is a DeltaNet [27, 32] whose keys are one-hot hash addresses, whose state is never reset, and whose write targets come from a learned fast-weight programmer [28]. The writer is trained with the pretraining objective on raw text. Each document is split into chunks; each chunk is first predicted from the memory written so far and then written, and the loss of later chunks backpropagates through the whole chain of writes. At use time the same writer and the same D1 run forward only.

The writer must read the evidence before it writes, and we study two ways of doing so. The plain writer encodes evidence with the model reading only T0T^{0}. Its targets are then anchored to the evidence, rows stay separable, and all blocks of a document can be encoded in one batch. The delta writer encodes evidence with the model reading its current memory, so what it writes can depend on what it has already stored. That is what long-term continual learning ultimately needs, for instance to connect a new report to an entity written earlier. Its price is sequential writing and a feedback loop through the memory. We analyse that loop and train both writers on the same data.

What the design gives by construction.

• No new memory module. Memory is the model’s own N-gram table, addressed by pretrained hashes of the last two or three tokens and read by the model’s native injection at layer 2.

• Pretrained parameters are untouched. Rows that were never written read exactly T0T^{0}; clearing Δ\Delta returns the original model, and each user's Δ\Delta is a separable set of sparse rows.

• Forward-only writes. At use time there is no backpropagation, no optimizer state and no label.

• Row-level attribution. Every change lives on a known row, so drift can be traced to, and intervened on, individual rows.

Findings. We train both writers (4.1M parameters each) on Qwen3.8-Flash-Next (512 experts, 48 layers) for 100M target tokens. We evaluate them on held-out news events, on the seven-task chain of [31], and on LoCoMo [20].

  1. Trained to answer, forward writes bind and keep facts, but only in the trained form. On a 0.6B prototype trained with a question-answering objective, the writer keeps 16 of 16 facts after a second write, where online gradient writes into the same table keep 2–4. With a paraphrased question it stays at the empty-memory level (Section 6.1).

  2. Raw-text training yields document-specific memory. On 64 late-2025 news events, reading a document's own memory beats reading another document's, which beats empty memory, at every training stage. At 100M tokens the two gains are 0.068 and 0.024 nats/token, and 0.063 and 0.013 after 16 intervening articles (Section 6).

  3. Reading memory while encoding changes how the writer writes. The delta writer's memory is more specific to its document ( Δdonor\Delta_{donor} 0.032 against 0.023 without distractors) and keeps more of that specificity after 16 distractors (70% against 54%); its total gain over empty memory on these news events is smaller. A weight ×\times encoding factorial places this change in the learned weights (Section 6.5). On the seven-task chain the delta writer drifts less than the plain writer: math drift is 176% against 188% at layer 2 and 40.2% against 41.8% at the head. It also answers slightly more (129 against 125 of 448 test items, and 112 against 103 written examples) (Section 7).

  4. Long write chains are stable. Both writers, including the delta writer whose encoding feeds back through its own memory, made 35,000 consecutive writes on two hardware stacks without numerical failure (Section 7).

  5. What was stored changes little afterwards, but little is stored. After each task is written, learned-task accuracy changes by -0.26pp (plain) and -0.52pp (delta) over the rest of the chain, against -7.29pp for the Adam table updates of [31]. Small- kik_i drift at the head input is 17.9% and 17.5%, against 39.2%. Net acquisition on these tasks, which the writer never saw, is negative (-12/448), and recall of written examples is 23–25% (Section 7).

  6. Drift concentrates on a few hot rows and can be located. General-input big-K drift is 32.8%, 1.6 times that of [31]. It enters at the injection layer through eight format bigram rows that every example writes, whose patches reach 4.4–11.7 times ∥T0∥\|T^0\|. Zeroing them removes over 98% of the layer-2 drift on math inputs and also removes their NLL gain (Section 8).

Analysis. Section 4 gives the relations behind these measurements: the bound of old-task drift by prefix overlap times row displacement, inherited from [31]; the boundedness of D1; row separability, under which zeroing a set of rows after the fact equals never committing them; and the fixed-point dynamics of a writer that encodes evidence through its own memory, which we then test with a weight × encoding factorial.

Position. The two properties that a forward write path into the native table had to show, that writes carry information forward and that long chains of them stay stable without touching T0T^{0}, hold. The two that remain, using what was written at a different position and bounding the absolute drift of hot rows, are where we take the method next (Section 9). Code is available at https://github.com/af-74413592/delta-ngram.

References (33)