← Latest papers
🤖 machine learning

Online Vector Quantized Attention

This paper introduces Online Vector-Quantized (OVQ) attention, a sequence mixing layer that achieves linear compute and constant memory costs while significantly improving long-context performance through sparse memory updates, offering a competitive alternative to self-attention with a fraction of the memory usage.

Original authors: Nick Alonso, Tomas Figliolia, Beren Millidge

Published 2026-05-18
📖 6 min read🧠 Deep dive

Original authors: Nick Alonso, Tomas Figliolia, Beren Millidge

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Problem: The "Too Big" and the "Too Small" Brain

Imagine you are trying to read a massive, 100,000-page novel to answer a specific question about a character mentioned on page 5.

  • The Old Way (Self-Attention): This is like having a super-intelligent assistant who reads the entire book every time you ask a question. They remember every single word perfectly. However, to do this, they need a library the size of a city to store all those notes. As the book gets longer, the library gets bigger and the assistant gets slower. It's accurate, but it's expensive and slow.
  • The Efficient Way (Linear Attention/SSMs): This is like an assistant who only keeps a tiny notepad. They summarize the book as they read it, keeping only the most important stats. They are incredibly fast and only need a pocket-sized notepad. But, because the notepad is so small, they often forget the specific details needed for long, complex stories. They struggle to find that character mentioned on page 5 when the book is 100,000 pages long.

The Goal: The authors wanted to build an assistant that is as fast and memory-efficient as the "pocket notepad" guy but as smart and detailed as the "city library" guy.

The Solution: The "Smart Filing Cabinet" (OVQ-Attention)

The authors created a new method called Online Vector Quantized (OVQ) Attention. Think of it as a Smart Filing Cabinet that updates itself in real-time.

Here is how it works, step-by-step:

1. The Dictionary (The Folders)

Instead of remembering every single word (like the city library) or just a summary (like the pocket notepad), this system uses a Dictionary of Folders.

  • Imagine you have a cabinet with, say, 4,000 empty folders.
  • As the assistant reads the book, they don't write down every word. Instead, they look at the current sentence and ask: "Which of these 4,000 folders does this sentence fit into best?"
  • They drop the sentence into that folder.

2. The "Online" Magic (Updating the Folders)

In previous versions of this idea, the folders were pre-written before the assistant started reading. If the book used words the folders didn't expect, the assistant got confused.

In OVQ-Attention, the folders are empty at the start. As the assistant reads the book:

  • They create new folders on the fly if they see something unique.
  • They update the existing folders to better match what they are seeing right now.
  • Crucially: They only update the specific folder that the current sentence belongs to. They don't rewrite the whole cabinet. This keeps the work fast (linear) and the memory usage low (constant).

3. The "Sparse" Update (The Efficient Trick)

Usually, if you want to remember more details, you need a bigger cabinet, which takes up more space.

  • The Paper's Trick: The authors realized that even if you have a cabinet with 100,000 folders, you only ever touch a few of them at once.
  • Because the updates are sparse (you only touch the specific folder relevant to the current sentence), the effort to update the cabinet doesn't grow just because the cabinet is huge.
  • Result: You can have a massive cabinet (high memory capacity) without paying the "effort tax" of a massive cabinet. You get the best of both worlds: huge storage, low cost.

The Results: How Well Did It Work?

The authors tested this "Smart Filing Cabinet" on several challenges:

  1. The "Needle in a Haystack" Test (In-Context Recall):

    • The Task: Hide a specific key-value pair (like a phone number) in a huge block of text and ask the model to find it later.
    • The Result: The old "pocket notepad" models failed miserably after a certain length. The "city library" models worked perfectly but were slow. The OVQ-attention model worked almost as perfectly as the city library, even with a much smaller memory footprint, and it could handle texts up to 64,000 words long.
  2. The "Learning While Reading" Test (In-Context Learning):

    • The Task: Give the model a bunch of examples of a new rule (e.g., "If you see X, do Y") and ask it to apply that rule to new sentences later in the text.
    • The Result: The OVQ model learned the rules just as well as the heavy, slow models, while the efficient-but-dumb models failed to learn the complex patterns.
  3. Reading Long Stories (Language Modeling):

    • When asked to predict the next word in a long story (using the PG19 dataset), the OVQ model performed competitively with the best standard models, despite using a fraction of the memory.

The Secret Sauce: Gaussian Mixture Regression

The paper explains the math behind this using a concept called Gaussian Mixture Regression.

  • Simple Analogy: Imagine you are trying to guess the weather based on a cloud.
    • Standard models try to match the cloud to every past cloud they've ever seen.
    • OVQ-Attention groups clouds into "types" (e.g., "Storm Cloud," "Fluffy Cloud").
    • As new clouds appear, the system doesn't just memorize them; it adjusts the definition of "Storm Cloud" to fit the new data better. It learns the shape of the cloud types while it reads, making its guesses much more accurate over long periods.

Summary

The paper introduces OVQ-Attention, a new way for AI to process long texts.

  • Old Efficient Models: Fast and small, but forgetful.
  • Old Powerful Models: Smart and detailed, but slow and memory-hungry.
  • OVQ-Attention: Uses a dynamic, self-updating filing system. It keeps a small, constant amount of active memory but can store a massive amount of information by organizing it into clusters. It learns these clusters while it reads, allowing it to be both fast and incredibly smart over very long contexts (up to 64k tokens).

The authors conclude that this is a major step forward in making AI models that are both efficient and capable of handling long, complex tasks without needing super-computers.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →