← Latest papers
💬 NLP

Linear-Time and Constant-Memory Text Embeddings Based on Recurrent Language Models

This paper proposes a vertically chunked inference strategy for recurrent language models like Mamba2, RWKV, and xLSTM that enables linear-time, constant-memory text embedding generation, offering a memory-efficient and competitive alternative to quadratic-complexity transformer-based approaches.

Original authors: Tobias Grantner, Emanuel Sallinger, Martin Flechl

Published 2026-04-21
📖 4 min read☕ Coffee break read

Original authors: Tobias Grantner, Emanuel Sallinger, Martin Flechl

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

Imagine you have a massive library of books, articles, and documents. You want to build a super-smart librarian who can instantly find the perfect book for any question you ask, even if the question is about a 100-page novel.

In the world of Artificial Intelligence, this "smart librarian" is called a Text Embedding Model. It turns words into a list of numbers (a "fingerprint") so the computer can understand the meaning and find similar things.

However, the current best librarians (based on Transformer models, like the ones powering many famous AI chatbots) have a big problem: They get exhausted.

The Problem: The "Quadratic" Library

Think of a Transformer model like a librarian who reads a document by comparing every single word to every other word in that document to understand the context.

  • If the document has 10 words, they make 100 comparisons.
  • If the document has 1,000 words, they make 1,000,000 comparisons.
  • If the document has 10,000 words, they need to make 100,000,000 comparisons!

This is called quadratic complexity. As the document gets longer, the librarian's brain (computer memory) fills up instantly, and they get incredibly slow. They simply can't handle long books without running out of space.

The Solution: The "Recurrent" Librarian

The authors of this paper propose a different kind of librarian: one based on Recurrent Models (specifically a new type called Mamba2, along with RWKV and xLSTM).

Instead of comparing every word to every other word, this librarian reads the document one word at a time, like a human reading a book. They keep a small, constant-sized "notebook" (memory) where they summarize what they've read so far.

  • The Magic: No matter if the book is 10 pages or 10,000 pages, the librarian only needs to keep that one small notebook open. Their memory usage stays constant. They don't get overwhelmed by long texts.

The Innovation: The "Vertical Chunk" Strategy

You might ask: "If they read one word at a time, isn't that slow? Can't they read faster?"

Yes, reading one word at a time is slow on modern super-fast computers that love to do many things at once (parallel processing). The authors' big breakthrough is a strategy they call Vertically Chunked Inference.

Imagine the document is a long train.

  1. Old Way (Horizontal): The librarian tries to process the entire train at once. If the train is too long, the station (memory) collapses.
  2. New Way (Vertical Chunks): The authors cut the train into small, manageable carriages (chunks).
    • They process one carriage through the entire depth of the librarian's brain (all layers) before moving to the next carriage.
    • Crucially, they pass a "hand-off note" (the state) from one carriage to the next, so the meaning isn't lost.

The Analogy:
Think of it like a factory assembly line.

  • Transformers try to build the whole car at once on a giant table. If the car is huge, the table breaks.
  • The New Method builds the car in sections. They build the engine, then the chassis, then the wheels, passing the partially built car down the line. They only need a small workbench (constant memory) because they aren't holding the whole car at once. But because they use powerful machines, they still build it incredibly fast.

What Did They Find?

The researchers took these "Recurrent Librarians" (Mamba2, RWKV, xLSTM) and taught them to be embedding models using the same training methods as the best Transformers.

  1. Performance: They are just as good as the Transformers at understanding text. They can find the right answers in the library just as accurately.
  2. Efficiency: When the documents get long (like 32,000 words), the Transformers crash or slow to a crawl because they run out of memory. The Recurrent models? They keep chugging along at the same speed, using the same amount of memory.
  3. The Sweet Spot: They found that you don't need to make the "carriages" (chunks) huge to get the speed benefits. Even small chunks allow the computer to work fast while keeping memory usage low.

Why Does This Matter?

This is a game-changer for anyone working with long documents (legal contracts, medical records, entire books) or for people with limited computer resources (like running AI on a laptop instead of a massive server farm).

It proves that we don't need to choose between "smart" and "efficient." We can have a librarian that is both brilliant at understanding long stories and efficient enough to fit in your pocket.

In short: The paper introduces a new way to process text that is as smart as the current AI giants but as memory-efficient as a simple notebook, making it perfect for the era of long-context AI.

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 →