Elamur Research

Learning to (Learn at Test Time): RNNs with Expressive Hidden States

Paper · 2024 · Yu Sun, Xinhao Li, Karan Dalal et al.

Summary

A word near the end of a long document can depend on something the reader saw many pages earlier. For a language model, making use of that information comes with a cost. A Transformer retains a representation of each earlier token for its attention layers to consult. The search grows more expensive as the sequence grows. A recurrent neural network, or RNN, carries a fixed-size state forward, so its work per token can stay constant. Its difficulty is deciding what to preserve in that state. This paper proposes making the state the weights of a small learner, then updating those weights as the sequence arrives.

The authors call the resulting layers Test-Time Training, or TTT. Each input token supplies a training example for a small reconstruction task. The layer learns to predict one projection of the token from another, then uses its updated weights to process a separate projection for the current output. Ordinary next-token training teaches the surrounding network which projections to use. At inference, those instructions are already learned, and each new sequence gets its own evolving state. TTT-Linear uses a linear map as the learner. TTT-MLP uses a two-layer multilayer perceptron, a neural network that can represent nonlinear relationships.

The language experiments span 125M to 1.3B parameters for the TTT systems. On the Pile at 8k context, both variants are competitive with Mamba, a modern recurrent baseline, and the detailed comparison favors the TTT variants in the Mamba backbone when training computation is taken into account. On Books3, a comparison that matches the training computation of Mamba 1.4B tracks how well systems predict tokens at different positions in a sequence. Mamba’s perplexity, a measure of how much probability a system assigns to the observed text, levels off after 16k. Both TTT variants and the Transformer continue to improve through the 32k context. The more expensive TTT-MLP does better than TTT-Linear toward the long end of that comparison.

Updating the state for every token poses a practical problem for parallel hardware. The authors evaluate several tokens’ gradients in parallel and derive a computation that produces the same outputs as the direct implementation of those grouped updates. In their TPU training setup, this dual form ran more than 5× faster than the direct form. Moving data through memory still makes TTT-MLP expensive in elapsed time. The paper establishes that a recurrent layer can carry a nonlinear learner as its state and benefit from longer text in the reported experiments. The choice of learner still determines whether the gain is worth its cost.

Deep dive: Learning to (Learn at Test Time): RNNs with Expressive Hidden States

Test-Time Training turns a recurrent layer’s hidden state into a small learner that updates as it reads, helping it use longer contexts. · about 37 minutes to read

The problem and its context

What a layer carries forward

An autoregressive sequence layer receives inputs in order and produces an output at each position using the input at that position and information from earlier positions. The output is a vector that other parts of the network can use. In a network trained for next-token prediction, those downstream computations ultimately assign probabilities to possible continuations of the text. The paper looks at the part of this process that gives each output access to its history. It describes a layer by asking where its state starts, how a new input changes the state, and how the layer uses the resulting state to produce an output.

In self-attention, the state can be understood as the key-value cache. A key describes how a token can be matched by a later request, and a value is the vector the layer can retrieve from it. At each position the layer adds the current key and value to the cache. It constructs a query from the current input, scores the available keys against it, and uses the scores to combine values. The cache holds a separate record for every observed position. When a later query makes an older record relevant, attention can score that record directly.

This arrangement makes the amount of stored data grow with the prefix. The work of a single attention read grows with it. Across a sequence, each successive position has a longer prefix to consult, and the total attention computation grows quadratically with length. A recurrent layer uses a fixed-size state, so it can update and read that state with a fixed amount of computation per token for a chosen architecture. Its total work is linear in sequence length. The state can be a vector, a matrix, or another fixed-size collection of numbers. Its size is fixed along the sequence even while its contents change.

The recurrent update has to make a choice each time it absorbs a token. An old detail may look unimportant when it arrives and become relevant much later. The state needs to carry enough information for uses that are difficult to anticipate locally. As the history grows, the challenge is to capture relationships among inputs and preserve them in a form the output rule can use. A fixed capacity and a fixed update cost say how much storage and computation are available. They leave open the question of what that budget should store.

The paper takes its empirical starting point from Scaling Laws for Neural Language Models. That earlier study found that long short-term memory networks, or LSTMs, fell behind Transformers in scaling and in their use of long contexts. By the time of the present study, recurrent architectures such as Mamba gave the authors reason to revisit the comparison. They distinguish a system’s performance as its training budget grows from its ability to make better predictions as it is given a longer prefix. Improvements in recurrent architectures make these separate questions worth asking.

Why use learning as the update?

Training already offers one way of fitting a large body of observations into a finite set of weights. After self-supervised training, a predictor can use relationships it has picked up across examples. Self-supervision means that the data supplies the target for a learning task. In next-token training, for instance, the observed continuation of the text supplies the target. The authors bring this view of learning inside the network. A sequence supplies examples, and the changes produced by learning on those examples are what the layer carries forward.

Prior work had adapted predictors at test time in several ways. Local learning trains on examples near the current input before making a prediction. Transductive learning also uses test data and can use a collection of test instances to constrain a predictor. Earlier test-time training studies described in the paper formulate a self-supervised task for an individual test instance. Work on video streams made that setup autoregressive by adapting as frames arrived. In language processing, work on dynamic evaluation fine-tuned a predictor on the test text. The authors’ preliminary study explored learning a reconstruction task for adaptation in object recognition. Learning to (Learn at Test Time)

Putting adaptation inside a sequence layer changes its role. Each layer can perform its own learning operation while the input passes through it, and that operation plays the same architectural role as a recurrent state update. The authors also train the reconstruction task itself through the surrounding network’s objective. The training process can favor an update that leaves a state useful for later predictions even when the information carried by that update is hard to specify in advance.

Fast weights offer a related way of thinking about the architecture. In the work the authors discuss, some weights change on recent or directly relevant data, while slower weights govern how those fast weights are used or changed. A fast-weight programmer is a system in which the slower part controls changes to the faster part. Earlier work had already used a multilayer perceptron as a fast learner, and linear attention had already connected matrix-valued memory with fast weights. The distinguishing design choice here is to specify a self-supervised objective, then use an optimization step on that objective as the transition of the recurrent state. Linear Transformers Are Secretly Fast Weight Programmers

DeltaNet is an especially close precedent. As the authors explain it, a basic linear learner that updates on each token, with the normalization and residual connection omitted, gives the DeltaNet rule. The paper also discusses existing recurrent layers with matrix states and work on parallelizing the delta rule. These connections place the linear variant in a family with established members. They also explain why the authors give so much attention to the nonlinear variant. A framework that accepts different learners makes it possible to ask how far a recurrent architecture can go beyond a matrix update of a particular form.

The authors describe the outer training procedure as a form of meta-learning, or learning how to learn. Some earlier approaches construct an inner learning problem from an entire dataset and need a collection of such problems for the outer training process. Here, a single sequence supplies the inner examples. The outer process can use the same kind of corpus and next-token objective as ordinary language training. This makes the layer’s learning rule part of the architecture that the outer objective trains. Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks

The method, step by step

A token serves as an example and a query

Imagine a layer reaching a position in a long passage. It receives a vector from the preceding part of the network. A fresh sequence starts with a common set of learner weights, and earlier positions in this passage have already changed them. The layer first uses the current vector to construct a small training problem. It updates the learner on that problem and uses the learner to compute the output for the current position. At the next position, the revised weights are the state the layer carries forward.

The obvious learning problem is to reconstruct the input. Copying a complete vector would make that task too easy, so the initial explanation in the paper gives the learner a version with some information removed. Reconstructing the original vector then calls for using relationships among its features. In the evaluated design, the layer learns which features to supply and which to ask the learner to predict. The target is part of the current observation and is available as soon as the input arrives.

How a Test-Time Training layer processes a sequence

The steps in order.

How a Test-Time Training layer processes a sequenceStep 1: Start the sequence from shared initial learner weights1. Start the sequence from shared initial learner weightsStep 2: Project each input into training, target, and query views2. Project each input into training, target, and query viewsStep 3: Evaluate reconstruction gradients at the group’s starting weights3. Evaluate reconstruction gradients at the group’s starting weightsStep 4: Accumulate updates using each position’s visible prefix4. Accumulate updates using each position’s visible prefixStep 5: Read each output through the updated learner5. Read each output through the updated learnerStep 6: Carry the boundary weights into the next group6. Carry the boundary weights into the next group

The direct, ungrouped version makes the role of each operation easy to see. The layer updates its weights by gradient descent, which moves the weights in the direction that locally reduces the reconstruction error.

W[t] = W[t−1] − η ∇ℓ(W[t−1]; x[t])

Here t is the current position and x[t] is its input vector. W[t−1] and W[t] are the weights before and after the update. The 1 in the index moves back by one position. ℓ is the inner loss, ∇ differentiates it with respect to the weights in its first argument, and η is the learning rate that scales the change.

ℓ(W; x[t]) = ‖f(x̃[t]; W) − x[t]‖²

Here W denotes whichever weights are being evaluated, f is the learner’s prediction function, and x̃[t] is the reduced or corrupted version of the observed input x[t]. The double bars with the square denote squared Euclidean distance. The loss adds up squared errors in the predicted coordinates. An input that produces a large gradient can cause a large immediate change in the weights. How much of that change remains useful later depends on subsequent updates and reads.

In the introductory construction, the read applies the learner to the current input using the already updated state.

z[t] = f(x[t]; W[t])

Here z[t] is the layer’s output vector at position t. The arguments of f are the current input x[t] and the weights W[t] after incorporating that input. The use of the current input is causal: when the surrounding network predicts a continuation, the current input is part of the observed prefix.

Learning the information to write and read

The implemented layer draws different views from the same vector using learned linear projections. The training view is a lower-dimensional input to the learner, the label view is its reconstruction target, and the query view is what it receives when producing the layer output. A projection can keep combinations of features that matter to its job. The outer objective can therefore shape what the learner practices as it moves through a sequence.

ℓ(W; x[t]) = ‖f(θ_K x[t]; W) − θ_V x[t]‖²

Here θ_K is the projection matrix that produces the training view, and θ_V produces the label view. Multiplication by either matrix acts on the current input x[t]. The learner f evaluates its training view with weights W, and ℓ measures the squared distance to the label view. The names K and V anticipate the connections with keys and values in attention.

z[t] = f(θ_Q x[t]; W[t])

Here θ_Q is the query projection matrix, x[t] is the current input, W[t] is the post-update state, and z[t] is the vector passed onward. The query has the input dimensionality expected by f. Its projection can keep different features from those used to generate the update. A token can thus contribute one kind of information to future states and request a different kind of information for its immediate output.

The reconstruction loss is the inner objective. In that loop, the projections are held fixed and differentiation is with respect to the learner weights. Ordinary network training supplies the outer objective, next-token prediction. In the outer loop the projection matrices change, together with the rest of the network. A projection can affect a prediction several positions later by changing an earlier inner gradient. To learn this effect, the outer backward pass differentiates through the operations that computed those gradients. That is the sense in which training involves gradients of gradients.

The distinction also matters for what is stored and reused. The outer weights are shared across sequences. The inner weights after adaptation belong to the sequence that produced them. A new sequence begins from the learned initialization and performs new updates. In deeper networks each TTT layer receives its own stream of representations, so the reconstruction examples for a layer are the vectors available there, as shaped by the preceding computation.

Choosing the learner and the size of its updates

In TTT-Linear, the learner’s core is a square weight matrix. The core output is a matrix-vector product. TTT-MLP gives the learner a two-layer feed-forward core whose intermediate dimension is 4× its input dimension. A GELU activation supplies the nonlinearity between the linear transformations. The weights of both transformations belong to the evolving state. This gives the inner learner a way to fit relationships that a single linear transformation cannot express by itself.

Both implemented variants wrap their core with layer normalization and a residual connection.

f(u) = u + LN(f_res(u))

Here u is the vector presented to the inner learner, from either the training projection or the query projection. f_res is the linear or multilayer core, with its current weights implicit. LN is layer normalization, which rescales the core’s output using statistics of its features. The addition carries the original u into the result. The authors use this construction to improve stability during adaptation.

The introductory derivation can start from W[0] = 0, where W[0] is the state before any token has been read and 0 is a zero initialization. The implemented layers use a learned initialization, which the paper also denotes by θ_init to show that it is an outer parameter. Like the projections, it receives training signal from the language objective. It specifies the learner’s starting point for every sequence. The paper describes its contribution to the outer parameter count as small because it operates on the projected dimensions.

The step size is also allowed to vary with the token.

η(x) = η_base σ(θ_lr · x)

Here η(x) is the learning rate used for an input vector x, η_base is a scalar base rate, θ_lr is a learned outer-loop vector, and · is a dot product. σ is the sigmoid function, whose output gates the base rate. The base rate is 1 for TTT-Linear and 0.1 for TTT-MLP. The gradient supplies the direction of the change, and the input-dependent gate controls how strongly that example moves the state.

The TTT layer occupies the sequence-processing part of a larger network block. The paper evaluates it in a Transformer backbone and in a backbone inspired by Mamba. The latter includes temporal convolutions before the recurrent layer. These combine information from nearby positions before the TTT update sees it. In the illustrated design the authors share a projection for the training and query views to accommodate the parameters of the backbone’s gate. The same underlying learner can thus receive differently prepared inputs depending on the block in which it is used.

Grouping gradient calculations while preserving causal outputs

In online gradient descent, the calculation of a token’s gradient needs the result of the previous update. This is a long serial chain even though the total number of operations grows only linearly with the sequence. The authors separate calculation of the gradient from accumulation of the resulting update. In the constant-rate presentation, they write the general rule as follows.

W[t] = W[t−1] − η G[t] = W[0] − η ∑(s=1…t) G[s]

Here G[t] is the descent direction assigned to position t, W[0] is the starting state, and W[t−1] and W[t] are consecutive states. η is the constant learning rate in this derivation. The sum, indexed by s, includes positions from the first position through t. Once the directions are known, a cumulative sum yields the state for each prefix. With an input-dependent rate, the contribution of each direction is scaled by its own rate before accumulation.

The descent direction can be evaluated at different reference states. Online descent evaluates it at the immediately preceding state. Batch descent evaluates every gradient at the sequence’s initial weights, so the gradient calculations are independent. Batch descent still gives different outputs at different positions because each read includes a different prefix of the accumulated updates. Its gradients, however, all describe what the initial learner would change, so its effective adaptation is one gradient step evaluated on a growing set of examples.

Mini-batch descent lies between these choices. At the start of a group of b tokens, the layer takes the boundary weights left by the previous group. It evaluates all gradients for the new group at those same weights. Within the group, the state used for each read includes the updates only through that token. At the boundary, the group’s accumulated update becomes the reference point for the next set of gradient calculations. The paper chooses b = 16 for its main experiments. The online endpoint is b = 1, and the full-batch endpoint uses b = T, where T is the sequence length.

This design lets information travel across a group in the accumulated updates and across group boundaries in the state used to evaluate new gradients. A token early in a group can affect a later token’s output immediately by adding to the prefix sum. Its effect on the gradients evaluated for later tokens begins in the next group. Reading all inputs in a group together for computational purposes is compatible with causal prediction because the quantities that reach each output depend on the group’s starting weights and that output’s own prefix.

Computing the same group in a form the hardware can use

Even after grouping, a direct implementation can spend much of its time producing intermediate matrices. The paper illustrates this with a plain linear learner in the first group. The train, target, and query projections are taken to be the identity, so all views use the same vector. The gradient for an individual token is an outer product.

G[t] = 2 (W[0] x[t] − x[t]) x[t]ᵀ

Here W[0] is the group’s starting matrix, x[t] is the token vector, and G[t] is the gradient of the squared loss with respect to W[0]. The factor 2 comes from differentiating that loss. ᵀ means transpose. Multiplying the error vector by the transposed input creates a matrix with one coordinate for every pairing of their features. With feature dimension d, the gradient is a d × d object even though its two constituent vectors each have only d coordinates.

The dual form avoids storing that object for every token. It computes the boundary weights directly from a matrix whose columns are the group’s inputs.

W[b] = W[0] − 2η (W[0] X − X) Xᵀ

Here b is the group size, W[b] is the weight matrix after the whole first group, and X stacks the vectors x[t] for that group in position order. W[0] X − X stacks the reconstruction errors, Xᵀ is the transpose of the input matrix, and η scales the summed gradient. The 2 comes from the squared-error derivative. Matrix multiplication adds the outer products into the boundary update directly.

The outputs inside the group need a different amount of that update at each position. The dual form obtains them by combining reconstruction errors with similarities between the input vectors.

Δ = (W[0] X − X) mask(Xᵀ X)

Here Δ is the matrix of output corrections before scaling by the learning rate and derivative factor. Its columns are in the same order as the inputs in X. The entry in row s and column t of Xᵀ X is the dot product between the input at position s and the input at position t within the group. mask keeps the upper triangle, including the diagonal, and sets the remaining entries to zero. Column t therefore draws on errors at positions up to and including t. W[0] remains the starting matrix, and ᵀ denotes transpose.

Z = W[0] X − 2η Δ

Here Z collects the output vectors z[t] as columns. W[0] X gives the reads using the starting weights, and 2η Δ applies the corrections from the relevant updates. η is the learning rate and 2 again comes from differentiating the squared loss.

A direct read would construct the state for position t and multiply it by the query at that position. In the dual computation, the dot product first determines how much each earlier input’s update contributes to the query. The corresponding error vectors then supply the changes to the output. The paper calls the direct computation the primal form. The equality is between primal and dual executions of the same mini-batch rule. Changing the group size changes the learning rule itself.

For the simple linear case, the primal form costs O(b × d²) work within a group, where O describes how the work grows, b is group size, and d is feature dimension. The dual boundary update has the same order, plus O(b² × d) work to obtain all the outputs. The latter term comes from interactions among positions inside the group. With b fixed, the total work remains linear in the sequence length. The hardware advantage comes from expressing the work in matrix multiplications and reducing the traffic from writing and rereading per-token matrices. This is central to the paper’s account of performance on accelerators. GPU & parallel computing

Carrying the dual calculation through a neural network

The appendix develops the calculation for a learner with several layers. The training views first make a forward pass through the learner at the starting weights. Each layer applies its matrix to all columns and then applies its activation. A backward pass provides the error signals at the learner’s internal layers. The appendix uses a squared reconstruction objective scaled by 1/2, so its derivative at the output is just the prediction error. It also sets the illustrative learning rate to 1.

∇_(W[0,k]) l = (∇_(Z[k]) l) (X̂[k])ᵀ

Here k indexes a layer of the inner learner, l is the scaled loss summed over the group, and ∇_(W[0,k]) l is its gradient with respect to that layer’s starting matrix W[0,k]. Z[k] is the matrix of training activations before the nonlinearity, and ∇_(Z[k]) l is the matrix of error signals at that point. X̂[k] stacks the inputs to layer k on the training pass, and ᵀ transposes it. This product gives the sum of the position-specific gradients, which is sufficient to compute the next group’s starting matrix.

A further forward pass processes the query views. At each layer it incorporates the effects of the updates through each query’s position.

Z̄[k] = W[0,k] X̄[k] − (∇_(Z[k]) l) mask((X̂[k])ᵀ X̄[k])

Here Z̄[k] holds the query-side preactivation outputs of inner layer k, and X̄[k] stacks that layer’s query-side inputs. W[0,k] is again the starting matrix. X̂[k] is the training-side input matrix, ᵀ means transpose, and mask keeps the causal triangle of training-input and query-input dot products. ∇_(Z[k]) l supplies the training error vectors that those dot products weight. The subtraction gives the result that applying the adapted matrix to each query would have produced.

Applying the layer’s activation sends those query outputs into the next layer. The final activation gives the group’s output vectors. The same reasoning can cover normalization when the backward calculation uses a vector-Jacobian product, which maps an output error back through a function to its inputs. The rearrangement accelerates the matrix operations around such a function. The function itself and its derivative calculation still take their usual work.

For training, the surrounding network needs intermediate quantities to compute its backward pass. Saving a large state at every position would be expensive. The dual form reduces the number of states that have to be available at group boundaries, and the authors use gradient checkpointing through time. Checkpointing keeps selected states and recomputes intervening quantities during back-propagation. For inference on a supplied prompt, the system uses the parallel dual computation to process the prompt. During sequential generation, it uses the primal computation as new tokens arrive.

How attention fits the same description

The paper gives an exact connection with a simple form of linear attention. Take a linear inner learner, start its matrix at zero, evaluate every gradient at that initial matrix, and use learning rate 1/2. At the initial matrix the predicted value is zero. The gradient is the negative outer product of the value and key views, multiplied by 2. Subtracting half of that gradient simply adds the value-key outer product to the state.

W[t] = ∑(s=1…t) (θ_V x[s]) (θ_K x[s])ᵀ

Here W[t] is the state after reading position t, and s indexes the visible prefix beginning at the first token. x[s] is the input at position s, θ_V gives its value view, θ_K gives its key view, and ᵀ transposes the key vector. Each term adds an association between a key and a value.

z[t] = ∑(s=1…t) (θ_V x[s]) (θ_K x[s])ᵀ (θ_Q x[t])

Here z[t] is the output at the current position. θ_Q x[t] is the current query. θ_K x[s] and θ_V x[s] are the earlier or current key and value, and s ranges through the causal prefix. The transposed key times the query gives the scalar weight for its value. This is the paper’s simplified linear attention, with the score used directly. The equivalence identifies a specific choice of initialization, learner, and gradient rule. The fitted TTT-Linear architecture changes those choices.

A broader definition of a learner brings softmax attention into the same picture. The state can be the learner’s internal storage, an update can be what it does to incorporate an example, and a read can be what it does to predict. A non-parametric learner can store observations and make predictions directly from them. The paper uses the Nadaraya–Watson estimator, which averages the stored targets with weights based on how the input compares with each stored observation.

f(x; x[1], …, x[t]) = ∑(s=1…t) κ(x[s], x) y[s] / ∑(s=1…t) κ(x[s], x)

Here f is the estimator, x is the input being queried, and x[1], …, x[t] are the inputs stored through position t. s runs across those positions, and y[s] is the value projection θ_V x[s] of stored input x[s]. The kernel κ supplies a weight for each stored input and query. The denominator normalizes the weights, so the output is a weighted average. In this notation the stored input is the kernel’s first argument and the query is its second.

κ(a, q) ∝ exp((θ_K a)ᵀ (θ_Q q))

Here a is a stored input, q is a query input, and θ_K and θ_Q compute the key and query projections. ᵀ transposes the projected key for the dot product, exp is the exponential function, and ∝ indicates proportionality. Normalizing these exponential weights gives the softmax attention weights. Separate key and query projections allow the similarity to be asymmetric.

The appendix motivates the weighted average as an estimate of the expected output given an input. It estimates the input density and the joint density of inputs and outputs using kernels centered on the observations. Integrating over outputs reduces the expression to a normalized sum of the observed target vectors, weighted according to input similarity. In the attention interpretation, incorporating an example means appending an entry to storage, and prediction means consulting that storage. The same learner interface covers both the growing cache and the fixed-size weight state. It can also cover additional optimizer variables when those are part of a parametric learner’s memory.

Experiments and results

Corpora, system sizes, and comparison budgets

The Pile experiments use 2k and 8k contexts. The Pile is a collection of documents for language training, and the authors point out that comparatively few of its sequences are longer than 8k. They therefore use Books3, a subset of the Pile, to run the longer-context experiments. The Books3 series tests 1k, 2k, 4k, 8k, 16k, and 32k contexts. These runs let the authors compare training at different sequence lengths and examine what happens as a predictor reads farther into a single long sequence.

The standard size settings for Transformer and the TTT systems are 125M, 350M, 760M, and 1.3B parameters. Mamba’s corresponding configurations are 130M, 370M, 790M, and 1.4B. The protocol follows the training recipe used in the Mamba study, which in turn draws on Chinchilla’s work on allocating training computation. The authors use a common recipe to make the comparisons interpretable across architectures and report that their baseline implementations reproduce the earlier results in the corresponding settings. Training Compute-Optimal Large Language Models

The Transformer baseline is the Llama-based Transformer++ configuration used in the Mamba study. It uses rotary positional encoding, which introduces position information through rotations, alongside SwiGLU feed-forward blocks and RMS normalization. Mamba uses the public implementation from its authors. The present paper uses the Llama tokenizer throughout, so all systems divide text into tokens in the same way. That matters to both the context length measured in tokens and the probabilities measured per token. Llama 2 · RoFormer · Tokenization

Each outer training batch contains 0.5M tokens. As context length increases, a batch contains fewer sequences, each with a longer span. The authors use AdamW with moment coefficients of 0.9 and 0.95. The learning rate warms up linearly over 10% of the training steps and follows a cosine schedule to 1e-5. The recipe uses weight decay of 0.1 and gradient clipping at 1.0, both ways of controlling the outer optimization, as well as mixed-precision computation. The code is built on EasyLM for JAX, and the authors make code and data available for reproducing the experiments.

The central quality measure is perplexity. A lower value corresponds to assigning higher probability to the observed tokens in the aggregate. In the scaling comparisons, the authors plot it against training FLOPs, the number of floating-point operations used in training. This reveals whether a gain at a particular parameter count still looks favorable once the additional computation to train that system is taken into account. The paper also reports perplexity by token position, which asks how prediction quality changes as more of a sequence becomes available.

Shorter contexts on the Pile

At 2k on the Pile, the comparison against training FLOPs puts TTT-Linear with the Mamba backbone close to Mamba and Transformer. The paper reports a perplexity of 11.09 for the final 125M TTT-Linear configuration in this setting. Across the tested size settings, the TTT-MLP version with the Mamba backbone has better perplexity than TTT-Linear at the corresponding size. It requires more training FLOPs, and toward the larger budgets its curve is slightly worse. This distinction matters because a stronger inner learner costs more work even at the same nominal network size.

At 8k, the FLOP comparison moves in favor of both TTT variants in the Mamba backbone relative to Mamba. TTT-MLP in the Transformer backbone also edges ahead of Mamba around 1.3B. Transformer itself remains strong when the comparison is made by parameter count. The computations needed for attention at that length make its curve less competitive when training FLOPs are on the horizontal axis. The paper’s headline description emphasizes that the TTT systems are already in Mamba’s range at 8k. The detailed comparisons show how the advantage depends on the architecture around the layer and the choice of budget.

Longer sequences on Books3

At 2k on Books3, the broad pattern resembles the Pile comparison, with Mamba slightly ahead of TTT-Linear. At 32k, both TTT variants in the Mamba backbone give better perplexity for their training computation than Mamba. TTT-MLP in the Transformer backbone is also slightly ahead of Mamba there. At the 1.3B scale on Books3, putting TTT-MLP in the Transformer backbone gives perplexity only slightly worse than placing it in the Mamba backbone.

The authors add a practical Transformer baseline for the longer Books3 settings. Beginning at 4k, they compare against a Transformer pretrained at 2k and then adapted to the designated longer length with 20% more training tokens. This setup follows a practice described in earlier work, where most training takes place at a shorter context and a further stage extends the usable context. For the Transformer at 4k and above, the authors compare rotary settings of 10,000 and 500,000 and retain the better perplexity. For fine-tuning, they try peak rates of 1e-5, 1e-4, and 1e-3. The reported choice is 1e-4 for the 125M configuration and 1e-5 for configurations at 350M and above. Effective Long-Context Scaling of Foundation Models

The token-position experiment matches the training FLOPs of Mamba 1.4B and uses its training recipe. To match that budget, the fine-tuned Transformer uses 19 blocks in place of 24. For the TTT systems, the authors adjust the hidden dimension in the surrounding feed-forward blocks from 5504 to 5808 for TTT-Linear and to 5248 for TTT-MLP. The TTT systems also match Mamba’s inference FLOPs under this setup. The fine-tuned Transformer has 2.8× the inference FLOPs, a relevant condition when interpreting how well it predicts at later positions.

In that experiment, the authors average prediction quality by position in the sequence. Early predictions have small prefixes, and later predictions can draw on much more text. Mamba’s average perplexity stops improving after 16k. The fine-tuned Transformer, TTT-Linear, and TTT-MLP all continue improving through the 32k span. At matched training FLOPs, TTT-MLP trails TTT-Linear towards the short end and does better toward the long end. The paper interprets that pattern as evidence that the additional capacity is more useful when the system has a larger history to compress.

The authors also compare systems trained separately at different context lengths. For architectures trained from scratch, perplexity worsens once the training context gets sufficiently long in the reported series. The best training context tends to move upward as the system gets larger. The fine-tuned Transformer mostly avoids that pattern, with an exception at 125M. A predictor can make better use of later positions inside a 32k run while a different training length gives it better aggregate perplexity overall. The figures address these distinct questions.

Elapsed time on accelerators

Measured training time provides a separate comparison from FLOPs. On a v5e-256 TPU pod at 2k context, the paper reports the following durations per training iteration.

Transformer and TTT-Linear training on a v5e-256 TPU pod in the 2k-context experiment

TTT-Linear completes a training iteration faster than Transformer in this setup.

Transformer and TTT-Linear training on a v5e-256 TPU pod in the 2k-context experimentTransformer: 0.30Transformer0.30TTT-Linear (this paper): 0.27TTT-Linear (this paper)0.27
The numbers
System or settingseconds per training iteration
Transformer0.30
TTT-Linear (this paper)0.27

The 0.30s Transformer time and 0.27s TTT-Linear time compare complete training iterations for those systems. The more than 5× improvement reported for the dual form answers a different question. It compares dual and primal execution of TTT training in JAX, where both compute the same mini-batch rule. Its size reflects how a change in the organization of the computation can affect hardware utilization even when the learning algorithm and outputs are held fixed.

The authors also write GPU inference kernels for comparison with Mamba. They time prefill, the processing of an already available prompt, and decode, the sequential production of new tokens. The device is an NVIDIA A100 with 80G HBM and PCIe connections. The evaluated systems have 1.3B parameters, apart from Mamba at 1.4B. The Transformer runs through the vLLM serving system, which the paper describes as a faster baseline than the implementation used for timing in the earlier Mamba comparison. Efficient Memory Management for Large Language Model Serving with PagedAttention

Transformer’s time per token rises with context length in those measurements. The recurrent alternatives stay roughly flat, with some upward movement in end-to-end prefill time. The paper distinguishes that behavior from the constant latency it observes for the recurrent sequence layers on their own and offers throttling at very long lengths as a possible contributor to the whole-network behavior. The measured advantage of linear growth becomes apparent beyond 8k in the reported setup. TTT-MLP has a substantially higher elapsed-time cost than its FLOP comparison alone would suggest, consistent with the paper’s concern about moving its larger state through memory.

What the ablations show

Changing the update rule has the largest measured effect

The main component ablation starts from linear attention and arrives at the full TTT-Linear design. Every row uses 125M parameters and the Pile training recipe. The authors first compare linear attention with and without its feature expansion and normalization of the attention computation. The simpler variant does better in their evaluation. It also supplies a starting point whose outputs can be matched by the linear TTT construction. This establishes a controlled point of comparison before the authors change the inner learner and its optimization.

Making the starting weights learnable slightly worsens perplexity at that early point in the ablation. The later rows require learned starting weights for stable training. The initialization therefore plays a different role depending on which other components are present. The initial comparison measures its direct effect in a simple batch learner. The later runs show that a learned starting point can matter when a sequence repeatedly updates its state.

The largest reduction in perplexity comes from moving from full-batch evaluation of the gradients at b = T = 2048 to mini-batches of b = 16. In the full-batch version, the gradient for each token asks what would improve the initial learner. In the mini-batch version, each group asks what would improve a learner that has already fitted earlier groups. The result isolates an advantage of refreshing that reference state. It also explains why simply adding a linear memory matrix to a recurrent architecture captures only part of what the proposed layer is doing.

Adding layer normalization and the residual connection inside the learner supplies the next-largest gain in the reported progression. These operations change the transformation whose errors drive learning, as well as the function used to read out the state. The ablation introduces them together, so it supports the combined design. The value 11.09 belongs to the final configuration’s Pile perplexity, after the changes have been assembled.

Group size changes both quality and runtime

In the group-size sweep, smaller groups improve perplexity. More frequent group boundaries give the gradients more opportunities to respond to previously changed weights. The authors acknowledge the possibility that very small groups might give noisy updates, and they report that they saw no such effect in this sweep. The result gives an empirical reason to preserve frequent adaptation even though the largest possible batch would offer more parallel gradient calculations.

The timing sweep uses a single TTT layer from the 1.3B TTT-Linear architecture, in pure PyTorch, at a context of T = 2048. The authors use that implementation so they can distinguish the time spent computing the weights at group boundaries from the time spent computing the outputs within groups. Larger groups initially improve hardware utilization. As groups grow, the output calculation must account for more pairs of positions inside each group. Boundary updates get faster until their parallelism saturates, and the extra output computation eventually makes the total time rise. The chosen size of 16 is the paper’s compromise between these effects and perplexity.

What changing the backbone reveals

The backbone comparisons show that the recurrent learner’s performance also depends on what happens before its update. In the reported comparisons, the Mamba-style backbone improves TTT perplexity. In that backbone, TTT-MLP does at best comparably to TTT-Linear in the Pile compute comparison discussed by the authors. With the Transformer backbone, TTT-MLP has a clearer advantage over TTT-Linear. The relative benefit of increasing the expressive capacity of the inner learner therefore varies with how the larger block processes local context.

The authors suggest that a temporal convolution gives a simpler recurrent update a larger boost. It can collect local information before the learner has to store or use it. That explanation is consistent with TTT-MLP coming closer to its Mamba-backbone counterpart at 1.3B on Books3. The controlled comparison changes the whole backbone, so the observed effect belongs to that architectural change. How much of it comes from the convolution is a further question.

The reconstruction objective improves during a test sequence

A separate analysis measures the inner loss on Pile test sequences of length T = 2048. It uses the 125M network with online updates and presents all 12 TTT layers in the appendix. The curves compare the loss on a token using the initial weights, the weights just before updating on the token, and the weights just afterwards. For readability, the paper averages the plotted values over a moving window of 10 timesteps.

The before-and-after comparison shows that a gradient update improves reconstruction for the token that supplied it. The comparison against initial weights shows a growing benefit from adaptation as the network reads farther into a test sequence. At some middle layers, the magnitude of the input vectors rises and the raw losses rise with it. The gap from the initial-state loss still widens. That relative comparison gives evidence that the accumulated state is learning something useful for the layer’s local objective. The language experiments provide the separate evidence about next-token prediction.

The paper also describes an earlier variant with an additional decoder after the inner learner. It slightly improved the results, with increased training instability and substantial extra computation. The final architecture uses the encoder alone. For the inner learning rate, the authors tested base values of 0.01, 0.1, 1, and 10 and chose the largest stable value for each variant. They report using warmup over 10% of training for the TTT-MLP rate and observing no difference from testing warmup for TTT-Linear. These checks help explain the settings of the final systems and the greater optimization demands of the nonlinear learner.

Limitations

Limits the authors state

The authors emphasize elapsed time as a remaining obstacle, especially for a nonlinear learner with a larger state. Mini-batching and the dual calculation improve the organization of the work, but a more expressive learner still has more weights and intermediate quantities to move. TTT-MLP illustrates the tradeoff directly. Its perplexity at long context can justify its FLOPs in the quality plots, while its memory traffic makes the measured time much less favorable. The systems work covers GPU inference kernels, and the paper leaves optimized GPU training kernels outside its implementation.

The language experiments stop at 32k context and at 1.3B parameters for the TTT systems. The authors discuss much longer sequences, larger learners, and possible applications in video and embodied agents. They also describe possibilities such as using additional devices to parallelize work through time or nesting another learning process inside the learner. These are proposed extensions. The paper’s measured relationship between state expressiveness and useful context is confined to the text experiments and hardware it reports.

The authors also caution against extrapolating the compute curves. In both the Pile and Books3, the points in the log-log plots resist a clean straight-line fit, including for Transformer. They connect observed points and describe what happens in that range. Deriving separate compute-optimal training schedules would require a much larger set of experiments. The scope of their scaling claims is thus the range of configurations under the chosen protocol. Scaling laws

The search over what the inner learner should practice is narrow by design. The evaluated views are learned linear projections, and the prediction task is squared-error reconstruction in that projected space. The authors suggest richer projections, other self-supervised objectives, and optimizers with their own internal state. The framework gives those choices a place in the architecture. The reported results concern the particular choices the authors implement.

Limits visible in the comparisons

The position experiment measures average predictive benefit on long text. It supports a claim about next-token prediction as the prefix grows. An experiment on precise retrieval of a fact at a known distance would measure a different property. The paper’s protocol gives neither the target information at each position nor a count of specific earlier details preserved in the state. Its evidence about memory is expressed through prediction quality and inner reconstruction. The attention equivalences give exact results for specified mathematical cases and have a different scope from the empirical memory claim.

The corpus changes when the study moves from the Pile’s standard settings to long runs on Books3. The Books3 series provides comparisons across lengths within one dataset, while the long Pile-to-Books3 progression also changes the mix of text. Backbone comparisons on Books3 are concentrated at 2k and 32k. The results support claims about the tested combinations of context, corpus, and backbone, and leave open how broadly these relations hold on other types of long input.

The experiments compare architectures that use a single principal kind of sequence layer. The authors exclude hybrids so the baselines and proposed systems can be compared more clearly. A system mixing local or global attention with TTT might make different choices about which information to store and where to look for it. Its quality, memory use, and runtime would depend on where attention is placed and how much of the sequence it can see. The experiment establishes the behavior of the standalone designs under study.

Finally, training FLOPs, inference FLOPs, and elapsed time measure different costs. The long position comparison gives the fine-tuned Transformer more inference FLOPs at equal training FLOPs. The GPU timing compares available inference implementations, and the TPU results cover a different hardware and software setup. A serving decision would require the quality and resource measurements for its own prompt lengths, generation lengths, and hardware. The figures in the paper show why context length and implementation belong alongside perplexity when judging the proposed tradeoff.

What came after

Later citations take up different parts of the research question. Some concern the design of a recurrent memory, others the use of learning during inference, and several organize research on efficient context or reasoning. The relationships below follow the subjects identified by the works’ titles and their citations to the paper. Those establish the connection in topic. More specific claims about which TTT components a later project implemented would require its method and experiments.

Alternatives for a recurrent memory

Longhorn frames state-space sequence layers as amortized online learners. In that framing, a state transition can be understood in terms of a learning calculation whose cost is built into processing the sequence. This is close to the question Sun and colleagues pose when they turn an inner optimization step into a recurrent update. Longhorn approaches the connection from the state-space side, asking how an existing architectural family can be understood as learning online. Longhorn: State Space Models are Amortized Online Learners

RWKV-7 centers on the evolution of a dynamic recurrent state. Its connection is to the paper’s question of how expressive a state and its transition can be within an efficient sequence layer. MoM focuses on a mixture of memories within linear sequence modeling. Read alongside TTT, its title points to a different design choice. The TTT paper varies the learner that occupies the state. A mixture of memories raises the question of what several memories can store or use collectively. RWKV-7 “Goose” with Expressive Dynamic State Evolution · MoM: Linear Sequence Modeling with Mixture-of-Memories

Kimi Linear addresses the same pairing of expressiveness and computational efficiency in an attention architecture. MiniMax-M1 places the emphasis on scaling computation at test time through Lightning Attention. Both belong to the broader problem of making additional inference computation affordable. The distinction between the amount of arithmetic and its cost on hardware, which was central to the TTT experiments, is pertinent to that problem. Kimi Linear: An Expressive, Efficient Attention Architecture · MiniMax-M1: Scaling Test-Time Compute Efficiently with Lightning Attention

Adaptation during inference

Akyürek and colleagues study test-time training for few-shot learning, where a predictor has a small set of examples for the task it must solve. That places the emphasis on what adapting to those examples can accomplish. Sun and colleagues instead study the use of reconstruction updates in the forward pass of a sequence layer, with examples arriving as tokens. The common question is what a predictor can learn from the input available at inference. The observations that drive adaptation and the outcome used to evaluate it depend on the problem. The Surprising Effectiveness of Test-Time Training for Few-Shot Learning

Dynamic Cheatsheet explicitly connects test-time learning with adaptive memory. The connection runs through the choice of what is changed when new input arrives and how that change can inform later outputs. Language Modeling by Language Models expresses a related shift in role in its title, putting a language predictor in the position of carrying out language modeling. It sits near the TTT paper’s broader question of what a predictor can do when a learning problem is part of processing its input. Dynamic Cheatsheet: Test-Time Learning with Adaptive Memory · Language Modeling by Language Models

Other citing works name different sources of adaptation. TTRL applies reinforcement learning at test time. Reinforcement Learning via Self-Distillation places self-distillation within reinforcement learning. Red-Bandit names bandit-guided LoRA experts as its route to test-time adaptation. These works connect to the choice of learning procedure during inference, while the original recurrent layer derives its update from reconstruction of an observed token view. TTRL: Test-Time Reinforcement Learning · Reinforcement Learning via Self-Distillation · Red-Bandit

Where the idea enters broader surveys

The long-context survey cites the work in the setting closest to its original experiments, where the goal is to keep benefiting from earlier text without making each new position prohibitively expensive. The surveys on efficient reasoning and latent reasoning cite it from broader areas concerned with the allocation of computation and what happens inside a predictor as it processes input. Together these citations show the different questions for which the paper provides a point of comparison. Its measurements establish the language-prediction and runtime behavior of the tested TTT layers, while its learner formulation gives later work a way to describe other choices of state, update, and readout. A Comprehensive Survey on Long Context Language Modeling · A Survey of Efficient Reasoning for Large Reasoning Models · A Survey on Latent Reasoning

Cite

Cite as Yu Sun, Xinhao Li, Karan Dalal, Jiarui Xu, Arjun Vikram, Genghan Zhang, Yann Dubois, Xinlei Chen, Xiaolong Wang, Sanmi Koyejo, Tatsunori Hashimoto and Carlos Guestrin. 2024. Learning to (Learn at Test Time): RNNs with Expressive Hidden States. arXiv:2407.04620.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.2407.04620 · arXiv 2407.04620

@misc{sun2024learning,
  title = {{Learning to (Learn at Test Time): RNNs with Expressive Hidden States}},
  author = {Yu Sun, Xinhao Li, Karan Dalal, Jiarui Xu, Arjun Vikram, Genghan Zhang, Yann Dubois, Xinlei Chen, Xiaolong Wang, Sanmi Koyejo, Tatsunori Hashimoto and Carlos Guestrin},
  year = {2024},
  doi = {10.48550/arxiv.2407.04620},
  eprint = {2407.04620},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2407.04620}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/sun-2024-learning-learn-test-time-rnns/

References

85 references, from the paper's own bibliography.

  1. Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et al. Gpt-4 technical report. arXiv preprint arXiv:2303.08774, 2023. our card
  2. Marcin Andrychowicz, Misha Denil, Sergio Gomez, Matthew W Hoffman, David Pfau, Tom Schaul, Brendan Shillingford, and Nando De Freitas. Learning to learn by gradient descent by gradient descent. Advances in neural information processing systems, 29, 2016. OpenAlex ↗ · Scholar ↗
  3. Authors Guild. You just found out your book was used to train ai. now what?, 2023. Accessed: 2024-06-24. OpenAlex ↗ · Scholar ↗
  4. Maximilian Beck, Korbinian Pöppel, Markus Spanring, Andreas Auer, Oleksandra Prudnikova, Michael Kopp, Günter Klambauer, Johannes Brandstetter, and Sepp Hochreiter. xlstm: Extended long short-term memory. arXiv preprint arXiv:2405.04517, 2024. our card
  5. Yoshua Bengio, Samy Bengio, and Jocelyn Cloutier. Learning a synaptic learning rule. Citeseer, 1990. OpenAlex ↗ · Scholar ↗
  6. Hermanus Josephus Bierens. The nadaraya-watson kernel regression function estimator. (Serie Research Memoranda; No. 1988-58). Faculty of Economics and Business Administration, Vrije Universiteit Amsterdam., 1988. OpenAlex ↗ · Scholar ↗
  7. Christopher M Bishop and Nasser M Nasrabadi. Pattern recognition and machine learning, volume 4. Springer, 2006. OpenAlex ↗ · Scholar ↗
  8. Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, et al. Gpt-neox-20b: An open-source autoregressive language model. arXiv preprint arXiv:2204.06745, 2022. our card
  9. Léon Bottou and Vladimir Vapnik. Local learning algorithms. Neural computation, 4(6):888–900, 1992. OpenAlex ↗ · Scholar ↗
  10. Leo Breiman, William Meisel, and Edward Purcell. Variable kernel estimates of multivariate densities. Technometrics, 19(2):135–144, 1977. OpenAlex ↗ · Scholar ↗
  11. Zongwu Cai. Weighted nadaraya–watson regression estimation. Statistics & probability letters, 51(3):307–318, 2001. OpenAlex ↗ · Scholar ↗
  12. Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost, 2016. OpenAlex ↗ · Scholar ↗
  13. Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020. OpenAlex ↗ · Scholar ↗
  14. Yen-Chi Chen. A tutorial on kernel density estimation and recent advances. Biostatistics & Epidemiology, 1(1):161–187, 2017. OpenAlex ↗ · Scholar ↗
  15. Kevin Clark, Kelvin Guu, Ming-Wei Chang, Panupong Pasupat, Geoffrey Hinton, and Mohammad Norouzi. Meta-learning fast weight language models. arXiv preprint arXiv:2212.02475, 2022. OpenAlex ↗ · Scholar ↗
  16. Ronan Collobert, Fabian Sinz, Jason Weston, Léon Bottou, and Thorsten Joachims. Large scale transductive svms. Journal of Machine Learning Research, 7(8), 2006. OpenAlex ↗ · Scholar ↗
  17. Tri Dao and Albert Gu. Transformers are ssms: Generalized models and efficient algorithms through structured state space duality. arXiv preprint arXiv:2405.21060, 2024. our card
  18. Soham De, Samuel L Smith, Anushan Fernando, Aleksandar Botev, George Cristian-Muraru, Albert Gu, Ruba Haroun, Leonard Berrada, Yutian Chen, Srivatsan Srinivasan, et al. Griffin: Mixing gated linear recurrences with local attention for efficient language models. arXiv preprint arXiv:2402.19427, 2024. OpenAlex ↗ · Scholar ↗
  19. Harm de Vries. In the long (context) run, 2023. Accessed: 2024-06-24. OpenAlex ↗ · Scholar ↗
  20. Jerome A Feldman. Dynamic connections in neural networks. Biological cybernetics, 46(1):27–39, 1982. OpenAlex ↗ · Scholar ↗
  21. Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International conference on machine learning, pages 1126–1135. PMLR, 2017. our card
  22. A. Gammerman, V. Vovk, and V. Vapnik. Learning by transduction. In In Uncertainty in Artificial Intelligence, pages 148–155. Morgan Kaufmann, 1998. OpenAlex ↗ · Scholar ↗
  23. Yossi Gandelsman, Yu Sun, Xinlei Chen, and Alexei A. Efros. Test-time training with masked autoencoders. Advances in Neural Information Processing Systems, 2022. OpenAlex ↗ · Scholar ↗
  24. Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, Shawn Presser, and Connor Leahy. The pile: An 800gb dataset of diverse text for language modeling, 2020. our card
  25. Xinyang Geng. EasyLM: A Simple And Scalable Training Framework for Large Language Models. https://github.com/young-geng/EasyLM, mar 2023. https://github.com/young-geng/EasyLM. OpenAlex ↗ · Scholar ↗
  26. Riccardo Grazzi, Julien Siems, Arber Zela, Jörg KH Franke, Frank Hutter, and Massimiliano Pontil. Unlocking state-tracking in linear rnns through negative eigenvalues. International Conference on Learning Representations (ICLR), 2024. OpenAlex ↗ · Scholar ↗
  27. Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. arXiv preprint arXiv:2312.00752, 2023. OpenAlex ↗ · Scholar ↗
  28. Nicklas Hansen, Rishabh Jangir, Yu Sun, Guillem Alenyà, Pieter Abbeel, Alexei A Efros, Lerrel Pinto, and Xiaolong Wang. Self-supervised policy adaptation during deployment. arXiv preprint arXiv:2007.04309, 2020. OpenAlex ↗ · Scholar ↗
  29. Moritz Hardt and Yu Sun. Test-time training on nearest neighbors for large language models. arXiv preprint arXiv:2305.18466, 2023. OpenAlex ↗ · Scholar ↗
  30. Horace He. Strangely, matrix multiplications on gpus run faster when given "predictable" data! [short], 2024. Accessed: 2024-06-30. OpenAlex ↗ · Scholar ↗
  31. Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. OpenAlex ↗ · Scholar ↗
  32. Geoffrey E Hinton and David C Plaut. Using fast weights to deblur old memories. In Proceedings of the ninth annual conference of the Cognitive Science Society, pages 177–186, 1987. OpenAlex ↗ · Scholar ↗
  33. Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997. OpenAlex ↗ · Scholar ↗
  34. Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. Training compute-optimal large language models, 2022. our card
  35. Kazuki Irie, Róbert Csordás, and Jürgen Schmidhuber. The dual form of neural networks revisited: Connecting test time predictions to training patterns via spotlights of attention. In International Conference on Machine Learning, pages 9639–9659. PMLR, 2022. OpenAlex ↗ · Scholar ↗
  36. Kazuki Irie, Róbert Csordás, and Jürgen Schmidhuber. Practical computational power of linear transformers and their recurrent and self-referential extensions. Conference on Empirical Methods in Natural Language Processing (EMNLP), 2023. OpenAlex ↗ · Scholar ↗
  37. Kazuki Irie, Francesco Faccio, and Jürgen Schmidhuber. Neural differential equations for learning to program neural nets through continuous learning rules. Advances in Neural Information Processing Systems, 35:38614–38628, 2022. OpenAlex ↗ · Scholar ↗
  38. Kazuki Irie, Imanol Schlag, Róbert Csordás, and Jürgen Schmidhuber. Going beyond linear transformers with recurrent fast weight programmers. Advances in Neural Information Processing Systems, 34:7703–7717, 2021. OpenAlex ↗ · Scholar ↗
  39. Kazuki Irie, Imanol Schlag, Róbert Csordás, and Jürgen Schmidhuber. A modern self-referential weight matrix that learns to modify itself. In International Conference on Machine Learning, pages 9660–9677. PMLR, 2022. OpenAlex ↗ · Scholar ↗
  40. Kazuki Irie and Jürgen Schmidhuber. Images as weight matrices: Sequential image generation through synaptic learning rules. International Conference on Learning Representations (ICLR), 2022. OpenAlex ↗ · Scholar ↗
  41. Vidit Jain and Erik Learned-Miller. Online domain adaptation of a pre-trained cascade of classifiers. In CVPR 2011, pages 577–584. IEEE, 2011. OpenAlex ↗ · Scholar ↗
  42. Thorsten Joachims. Learning to classify text using support vector machines, volume 668. Springer Science & Business Media, 2002. OpenAlex ↗ · Scholar ↗
  43. Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020. our card
  44. Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International conference on machine learning, pages 5156–5165. PMLR, 2020. OpenAlex ↗ · Scholar ↗
  45. Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. our card
  46. Louis Kirsch and Jürgen Schmidhuber. Meta learning backpropagation and improving it. Advances in Neural Information Processing Systems, 34:14122–14134, 2021. OpenAlex ↗ · Scholar ↗
  47. Ben Krause, Emmanuel Kahembwe, Iain Murray, and Steve Renals. Dynamic evaluation of neural sequence models. In International Conference on Machine Learning, pages 2766–2775. PMLR, 2018. OpenAlex ↗ · Scholar ↗
  48. Ben Krause, Emmanuel Kahembwe, Iain Murray, and Steve Renals. Dynamic evaluation of transformer language models. arXiv preprint arXiv:1904.08378, 2019. OpenAlex ↗ · Scholar ↗
  49. Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th Symposium on Operating Systems Principles, pages 611–626, 2023. our card
  50. Brenden M Lake, Tomer D Ullman, Joshua B Tenenbaum, and Samuel J Gershman. Building machines that learn and think like people. Behavioral and brain sciences, 40:e253, 2017. our card
  51. Quoc V Le. Building high-level features using large scale unsupervised learning. In 2013 IEEE international conference on acoustics, speech and signal processing, pages 8595–8598. IEEE, 2013. OpenAlex ↗ · Scholar ↗
  52. Hao Liu, Wilson Yan, Matei Zaharia, and Pieter Abbeel. World model on million-length video and language with blockwise ringattention. arXiv preprint arXiv:2402.08268, 2024. our card
  53. Xuan Luo, Jia-Bin Huang, Richard Szeliski, Kevin Matzen, and Johannes Kopf. Consistent video depth estimation. ACM Transactions on Graphics (ToG), 39(4):71–1, 2020. OpenAlex ↗ · Scholar ↗
  54. Dougal Maclaurin, David Duvenaud, and Ryan Adams. Gradient-based hyperparameter optimization through reversible learning. In International conference on machine learning, pages 2113–2122. PMLR, 2015. OpenAlex ↗ · Scholar ↗
  55. Luke Metz, Niru Maheswaranathan, Brian Cheung, and Jascha Sohl-Dickstein. Meta-learning update rules for unsupervised representation learning. arXiv preprint arXiv:1804.00222, 2018. OpenAlex ↗ · Scholar ↗
  56. Ravi Teja Mullapudi, Steven Chen, Keyi Zhang, Deva Ramanan, and Kayvon Fatahalian. Online model distillation for efficient video inference. arXiv preprint arXiv:1812.02699, 2018. OpenAlex ↗ · Scholar ↗
  57. F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011. OpenAlex ↗ · Scholar ↗
  58. Bo Peng, Eric Alcaide, Quentin Anthony, Alon Albalak, Samuel Arcadinho, Stella Biderman, Huanqi Cao, Xin Cheng, Michael Chung, Matteo Grella, et al. Rwkv: Reinventing rnns for the transformer era. arXiv preprint arXiv:2305.13048, 2023. OpenAlex ↗ · Scholar ↗
  59. Bo Peng, Daniel Goldstein, Quentin Anthony, Alon Albalak, Eric Alcaide, Stella Biderman, Eugene Cheah, Teddy Ferdinan, Haowen Hou, Przemysław Kazienko, et al. Eagle and finch: Rwkv with matrix-valued states and dynamic recurrence. arXiv preprint arXiv:2404.05892, 2024. OpenAlex ↗ · Scholar ↗
  60. Zhen Qin, Xiaodong Han, Weixuan Sun, Dongxu Li, Lingpeng Kong, Nick Barnes, and Yiran Zhong. The devil in linear transformer. arXiv preprint arXiv:2210.10340, 2022. our card
  61. Frank Rosenblatt. The perceptron: a probabilistic model for information storage and organization in the brain. Psychological review, 65(6):386, 1958. OpenAlex ↗ · Scholar ↗
  62. Imanol Schlag, Kazuki Irie, and Jürgen Schmidhuber. Linear transformers are secretly fast weight programmers. In International Conference on Machine Learning, pages 9355–9366. PMLR, 2021. our card
  63. Imanol Schlag, Tsendsuren Munkhdalai, and Jürgen Schmidhuber. Learning associative inference using fast weight memory. arXiv preprint arXiv:2011.07831, 2020. OpenAlex ↗ · Scholar ↗
  64. Jürgen Schmidhuber. Evolutionary principles in self-referential learning, or on learning how to learn: the meta-meta-... hook. PhD thesis, Technische Universität München, 1987. OpenAlex ↗ · Scholar ↗
  65. Jürgen Schmidhuber. Learning to control fast-weight memories: An alternative to dynamic recurrent networks. Neural Computation, 4(1):131–139, 1992. OpenAlex ↗ · Scholar ↗
  66. Noam Shazeer. Glu variants improve transformer, 2020. OpenAlex ↗ · Scholar ↗
  67. Sam Shleifer, Jason Weston, and Myle Ott. Normformer: Improved transformer pretraining with extra normalization. arXiv preprint arXiv:2110.09456, 2021. OpenAlex ↗ · Scholar ↗
  68. Assaf Shocher, Nadav Cohen, and Michal Irani. “zero-shot” super-resolution using deep internal learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 3118–3126, 2018. OpenAlex ↗ · Scholar ↗
  69. Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding, 2023. our card
  70. Yu Sun, Xinhao Li, Karan Dalal, Chloe Hsu, Sanmi Koyejo, Carlos Guestrin, Xiaolong Wang, Tatsunori Hashimoto, and Xinlei Chen. Learning to (learn at test time). arXiv preprint arXiv:2310.13807, 2023. our card
  71. Yu Sun, Wyatt L Ubellacker, Wen-Loong Ma, Xiang Zhang, Changhao Wang, Noel V Csomay-Shanklin, Masayoshi Tomizuka, Koushil Sreenath, and Aaron D Ames. Online learning of unknown dynamics for model-based controllers in legged locomotion. IEEE Robotics and Automation Letters, 6(4):8442–8449, 2021. OpenAlex ↗ · Scholar ↗
  72. Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. In International Conference on Machine Learning, pages 9229–9248. PMLR, 2020. OpenAlex ↗ · Scholar ↗
  73. Sebastian Thrun and Lorien Pratt. Learning to learn: Introduction and overview. In Learning to learn, pages 3–17. Springer, 1998. OpenAlex ↗ · Scholar ↗
  74. Tijmen Tieleman and Geoffrey Hinton. Using fast weights to improve persistent contrastive divergence. In Proceedings of the 26th annual international conference on machine learning, pages 1033–1040, 2009. OpenAlex ↗ · Scholar ↗
  75. Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. Llama 2: Open foundation and fine-tuned chat models, 2023. our card
  76. Vladimir Vapnik. The nature of statistical learning theory. Springer science & business media, 2013. OpenAlex ↗ · Scholar ↗
  77. Pascal Vincent, Hugo Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In ICML, page 1096–1103, 2008. OpenAlex ↗ · Scholar ↗
  78. Christoph Von Der Malsburg. The correlation theory of brain function. In Models of neural networks: Temporal aspects of coding and information processing in biological systems, pages 95–119. Springer, 1994. OpenAlex ↗ · Scholar ↗
  79. Renhao Wang, Yu Sun, Yossi Gandelsman, Xinlei Chen, Alexei A Efros, and Xiaolong Wang. Test-time training on video streams. arXiv preprint arXiv:2307.05014, 2023. OpenAlex ↗ · Scholar ↗
  80. Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. Huggingface's transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019. our card
  81. Wenhan Xiong, Jingyu Liu, Igor Molybog, Hejia Zhang, Prajjwal Bhargava, Rui Hou, Louis Martin, Rashi Rungta, Karthik Abinav Sankararaman, Barlas Oguz, Madian Khabsa, Han Fang, Yashar Mehdad, Sharan Narang, Kshitiz Malik, Angela Fan, Shruti Bhosale, Sergey Edunov, Mike Lewis, Sinong Wang, and Hao Ma. Effective long-context scaling of foundation models, 2023. our card
  82. Songlin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, and Yoon Kim. Gated linear attention transformers with hardware-efficient training. arXiv preprint arXiv:2312.06635, 2023. OpenAlex ↗ · Scholar ↗
  83. Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, and Yoon Kim. Parallelizing linear transformers with the delta rule over sequence length. arXiv preprint arXiv:2406.06484, 2024. OpenAlex ↗ · Scholar ↗
  84. Biao Zhang and Rico Sennrich. Root mean square layer normalization, 2019. OpenAlex ↗ · Scholar ↗
  85. Hao Zhang, Alexander C Berg, Michael Maire, and Jitendra Malik. Svm-knn: Discriminative nearest neighbor classification for visual category recognition. In 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'06), volume 2, pages 2126–2136. IEEE, 2006. OpenAlex ↗ · Scholar ↗