remix logo

Hacker Remix

Titans: Learning to Memorize at Test Time

147 points by bicepjai 2 days ago | 32 comments

Ratelman 2 days ago

So Minimax just "open-sourced" (I add it in "" because they have a custom license for its use and I've not read through that) but they have context length of 4-million tokens and it scored 100% on the needle in a haystack problem. It uses lightning attention - so still attention, just a variation? So this is potentially not as groundbreaking as the publishers of the paper hoped or am I missing something fundamental here? Can this scale better? Does it train more efficiently? The test-time inference is amazing - is that what sets this apart and not necessarily the long context capability? Will it hallucinate a lot less because it stores long-term memory more efficiently and thus won't make up facts but rather use what it has remembered in context?

ttul 1 day ago

No, TITANS introduces a new "learning memory" model that is actually trained at test-time based on the input to help remember the right bits from the input to improve how the separate sequence-to-sequence model generates tokens. This is far different from in-context learning, which simply relies on the autoregressive operation of the transformer model to feed output back into input.

The memory works by tracking two kinds of "surprise" - immediate surprise (how unexpected is the current token?) and accumulated surprise (what patterns of unexpected things have we been seeing?). It uses this to decide what's worth remembering and what can be forgotten. What's clever is they formulated this as a gradient descent problem that can run efficiently in parallel despite being inherently sequential.

The really interesting part is how it integrates with the main model - they tried three approaches but the most effective was using the memory as additional context tokens alongside the input. This lets the attention mechanism figure out for itself when to use the memory versus the immediate context. And because the memory tokens are injected both at test-time and during training, the memory model and main model are trained together despite the memory model being unfrozen for each inference.

In practice, this lets them handle sequences over 2M tokens long while outperforming traditional transformers, even matching GPT-4 on some long-context reasoning tasks with far fewer parameters. It's a neat example of combining classical ideas about online learning with modern deep learning architectures.

The code isn't released yet, but the paper suggests the implementation is relatively straightforward since it builds on standard gradient descent mechanics. It'll be interesting to see if this approach influences the next generation of open source LLMs. I'm sure we will see implementations very soon even though it may take some time for open source models to be trained using this new architecture.

I'm very excited to know whether Gemini 2.0 1206 Experimental is using this new architecture. I suspect it is.

timlarshanson 1 day ago

I doubt it. This does not seem to be a particularly well written or well thought-out paper -- e.g. equations 6 and 7 contradict their descriptions in the sentence below; the 'theorem' is an assertion.

After reading a few times, I gather that, rather than kernelizing or linearizing attention (which has been thoroughly explored in the literature), they are using a MLP to do run-time modelling of the attention operation. If that's the case (?), (which is interesting, sure): 1 -- Why did they not say this plainly. 2 -- Why does eq. 12 show the memory MLP being indexed by the key, whereas eq. 15 shows it indexed by the query? 3 -- What's with all the extra LSTM-esque forget and remember gates? Meh. Wouldn't trust it without ablations.

I guess if a MLP can model a radiance field (NeRF) well, stands to reason it can approx attention too. The Q,K,V projection matrices will need to be learned beforehand using standard training.

While the memory & compute savings are clear, uncertain if this helps with reasoning or generalization thereof. I doubt that too.

andy12_ 12 hours ago

The eq. 12 is a loss function to associate a given key and value in the memory MLP using test-time training with gradient-descent.

The eq. 15 is simply the operation to query a value that was previously inserted in previous tokens using eq. 12.

Basically, for each autoregressively processed segmented you do:

1) Test-time inference: query values from memory with eq. 15.

2) Test-time training: associate new keys and values into the memory with the loss from eq. 12.

The forget and remember gates is because... well, the architecture in general is very similar to a LSTM, but using test-time gradient descent to decide what to insert to the long-term memory.

timlarshanson 10 hours ago

Ok, thanks for the clarification.

Seems the implicit assumption then is that M(q) -> v 'looks like' or 'is smooth like' the dot product, otherwise 'train on keys, inference on queries' wouldn't work ? (safe assumption imo with that l2 norm & in general; unsafe if q and k are from different distributions).

Correct me if I'm wrong, but typically k and v are generated via affine projections K, V of the tokens; if M is matrix-valued and there are no forget and remember gates (to somehow approx the softmax?), then M = V K^-1

ljlolel 1 day ago

The paper has ablations

anon373839 1 day ago

The needle in the haystack test is unfortunately not a very good measure of long-context performance. It turns out that searching for isolated pieces of information is a lot less demanding than synthesizing the entire context to solve a task.

iamnotagenius 1 day ago

Sadly LLM itself is not impressive. Not creative, not exactly smartest. good but not great.

gwern 1 day ago

Their creative-writing dataset seems to have been literally written by ChatGPT: https://www.reddit.com/r/LocalLLaMA/comments/1i1a88y/minimax...

marmaduke 2 days ago

similar to RWKV7’s new (sub quadratic) attention mechanism which models key values as v≈kS’ and does an in-context descent on ||v - kS’||^2/2 (where the state matrix S is one attentional head) , explained more by the author here https://raw.githubusercontent.com/BlinkDL/RWKV-LM/main/RWKV-...

and i tried to unpack it a bit here https://wdmn.fr/rank-1-take-on-rwkv7s-in-context-learning/

amai 2 days ago

I wonder why the authors felt they need to use drop caps in this paper. It is a distraction and seems to value style over content.

fancyfredbot 2 days ago

The drop caps spell titan, which they probably found entertaining. It made me smile anyway.

331c8c71 2 days ago

They were not so secretely hoping their paper's gonna go directly in history:) One could check the other papers by the authors to verify.

NotAnOtter 1 day ago

This was the impression I gathered as well. It seemed the authors had already decided this will revolutionize NN before it had even gone through review.

They have several other "We took the best of both worlds" type papers.

bansuian 2 days ago

From the title I thought this was talking about cramming the night before an exam. ;-) Or if it’s an open book exam learning during the exam as one goes through the textbook.