Elamur Research

Memorizing Transformers

Paper · 2022 · Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins et al.

Summary

A function can be defined near the beginning of a code repository and called much later. By the time a language model reaches that call, the definition may have fallen outside the part of the text it can directly consult. Memorizing Transformers asks whether a system can keep useful traces of what it reads and look them up when needed. The aim is to make information from a new document available during reading, with the trained weights held fixed at inference time.

The authors add a retrieval branch to an upper layer of a decoder-only Transformer. The system reads a document in order, in segments of 512 tokens. As it goes, it saves internal representations as key–value pairs. A key describes an earlier position in a form the system can search, and its value carries the information that attention can bring forward. Each current position uses approximate nearest-neighbor search to find similar keys. The layer combines attention over those retrieved entries with ordinary local attention, using a learned mixing weight for each attention head. A smaller Transformer-XL cache also carries recent context across segment boundaries. Gradients stop at the large memory, so training can reuse entries made on earlier steps.

The paper evaluates next-token prediction on long C4 web documents, PG-19 books, arXiv mathematics papers, Github repositories, and Isabelle formal proofs. External memory improves perplexity, a measure of how much probability the system assigns to the observed text, across the datasets and architectures studied. In the C4(4K+) comparison, an external memory of 8192 tokens takes Transformer-XL from 15.38 to 14.04 perplexity. Larger memories usually bring smaller additional gains after the initial improvement, with gains on arXiv Math continuing up to 262K tokens in the larger-memory fine-tuning experiment.

On arXiv Math, adding memory helps at sizes from 200M to 8B parameters. A smaller system with 8K tokens of memory can match the perplexity of a plain Transformer with 5X more trainable parameters in the scaling comparison. A system trained with a smaller memory can also benefit from a larger one at inference. In the neighbor-count ablation, retrieving 32 entries per query gives results comparable to retrieving 128 or 256. The seed comparison finds that variation between repeated runs is much smaller than the gap between the tested memory-equipped system and Transformer-XL.

The clearest examples concern details that can be found elsewhere in the same document. Queries retrieve reference names in mathematics papers, function and variable names in code, and earlier statements around mathematical definitions in Isabelle. In a manual check, the retrieved material included the needed lemma body in 8 out of 10 examples. The overall results establish an improvement in predicting long documents, while these examples show how reading earlier text can supply information for a later prediction.

Deep dive: Memorizing Transformers

Memorizing Transformers uses nearest-neighbor attention to recall earlier text and improve next-token prediction in long documents. · about 36 minutes to read

The problem and its context

When relevant text lies outside the attention window

A system predicting the next token has access to two sources of information. Its parameters reflect patterns acquired during training. The text it has already read supplies evidence about the document in front of it. The second source matters particularly for an identifier chosen by an author, the name of a reference in a paper, or a character mentioned much earlier in a book. In these cases the document can supply the relevant detail directly. The practical difficulty is keeping that detail available until the point where it matters.

Attention provides a way to use earlier text. A representation at the current position produces a query, which is compared with keys produced at other positions. The query can favor positions that carry relevant information, and the layer forms an output from their associated values. With dense attention, a larger context adds more positions to compare against each query. The cost of making those comparisons limits how much text can be directly visible, even when the document contains useful material much farther back.

A short window can work well when the clues to a prediction are nearby. The immediate context might establish the grammar of a sentence or show which argument is being supplied to a function. A distant passage often supplies a different kind of information. It may establish the exact name the author selected or introduce a mathematical result that is invoked later. A system could infer from nearby syntax that a name belongs at the current position and still need the earlier passage to identify the name.

This distinction explains why the paper treats long context as a route to rapid acquisition of information. Training changes the weights gradually across many optimization steps. Attention can already use information that appeared in its context moments before a prediction. The authors ask how far that property can extend when the accessible context is no longer confined to a short run of tokens. Their approach makes earlier representations available as data that can be consulted immediately after being written.

The problem has two parts. The first is retention. A theory or repository may contain enough text that the relevant earlier span has long since left the active segment. The second is selection. Keeping a large body of earlier text helps only if a current query can find useful parts of it. The proposal addresses selection through information retrieval over representations that the Transformer itself produced as it read.

Earlier ways to extend attention

The paper places its design among approaches that reduce the cost of attending over longer inputs. A sliding window limits attention to a neighborhood of fixed size. That makes the work at a position depend on its nearby window and lets a long sequence be processed under a common local rule. A distant token can still influence later positions indirectly through stacked layers, although an individual layer only consults the allowed neighborhood. Longformer is the example the authors cite for windowed attention. Longformer

Other approaches change how the attention computation is represented. The paper discusses Linformer and Performer among methods that approximate or restructure the calculation. It describes a linear complexity target for efficient variants. Here O(N) denotes growth proportional to the sequence length in the relevant calculation, with N standing for the number of positions. The focus is the computation over the sequence itself. Performer

Sparse attention provides a different way to control how much work each position requires. Big Bird restricts attention to a subset of positions. Routing Transformers use clustering to help select positions, and Reformer uses hashing. These approaches illustrate that sparse attention can be organized around different rules for deciding which positions should interact. Big Bird · Routing Transformers · Reformer

The authors also discuss methods that represent distant text at a coarser scale. Pooling can combine information from several tokens into a smaller set of representations. Hierarchical designs can organize information around larger units such as phrases or sentences. ReadTwice makes an additional pass that consults summaries produced from the first pass. These techniques change what remains available about distant material. Memorizing Transformers keeps individual stored values accessible, a choice that is particularly relevant when a later query needs the representation of a particular occurrence. ETC

What the paper inherits from caches and retrieval

A closer predecessor is the practice of carrying state across segments. In the paper's account of truncated back-propagation through time, a recurrent system processes a long sequence in chunks. The final state of a chunk becomes the initial state of the next chunk, with the state carried across the boundary outside the gradient computation. Neural caches retain a larger record of past hidden states. Transformer-XL adapts that idea to attention by retaining keys and values from the previous segment and exposing them as a prefix when processing the next one.

That cache gives a prediction near the beginning of a segment access to text on the other side of the boundary. It also lets representations carry information across a larger span through the layers. Compressive Transformers extend the cache approach by compressing the material kept from earlier positions. Memorizing Transformers retains a short Transformer-XL cache in many experiments. Its additional branch stores reusable key–value pairs individually and searches them when a current query might benefit from a more distant record. Compressive Transformers

The paper distinguishes its memory from an earlier nearest-neighbor approach to language prediction. In that work, a pretrained system is run over a corpus to construct a table associating contextual keys with token identities. A lookup in that table contributes at the point where the system selects an output token. In Memorizing Transformers the records are attention keys and values. The result of lookup is a representation that enters the network before the final token prediction. This difference determines what retrieval supplies. A neighbor can contribute information about the use or definition of a name even when the token at the retrieved position differs from the next token being predicted.

The authors make a similar distinction from learned internal memories. They describe work that treats the feed-forward portion of a Transformer layer as related to attention over learned entries. Earlier work used fast lookup over a larger learned store to stand in for a feed-forward layer. In Memorizing Transformers, the feed-forward network remains part of the layer. It receives representations enriched by attention over earlier input. The entries in that attention store originate in the document stream.

Other retrieval systems in the paper's background, including REALM and RAG, consult a knowledge base of text passages for tasks such as question answering. Such a knowledge base already exists when the query arrives. Here the data source is the stream currently being read, and the searchable unit is an internal representation. Writing and reading the store are both part of ordinary sequence processing. This is the relationship between the paper's design and retrieval-augmented generation. REALM · RAG

The method, step by step

Read the document in order

The starting architecture follows the Transformer described in Attention Is All You Need. Text is converted into tokens, which are pieces of text drawn from a fixed vocabulary. Each token is mapped to an embedding, a vector that the network can process. The vectors pass through layers containing self-attention and a feed-forward network. At the top of this decoder-only stack, the representation at each position is used to predict the following token.

The first constraint is causality. Each prediction may use the tokens that have already occurred. A causal mask enforces that constraint within a segment by controlling which positions each query can see. The same principle governs the external store. When the current segment is being processed, the large memory contains entries from earlier segments. The current segment contributes its own entries after the step.

The standard segmentation is into subsequences of 512 tokens. Consecutive steps advance from the beginning of a document toward its end. If these subsequences were shuffled, later segments might arrive before the passages they refer to. Keeping them in sequence makes the store reflect the history of the running document. It also lets the authors evaluate retrieval under the same basic condition that motivates the architecture. A useful definition must have passed through the system before it can be found.

The Transformer-XL cache carries keys and values from the preceding step into local attention. These entries are placed before the current segment's keys and values. A sliding causal mask then gives each query a local context covering the previous 512 tokens in the standard setup. Close to the beginning of a new segment, many of those tokens come from the cache. Later in the segment, the local window draws increasingly on positions within the current segment. The short cache thus solves a problem that can arise even for a dependency spanning only a few tokens.

Batches contain subsequences from different documents. Each active document has its own store, because the entries visible to a query should come from the history of that document. Documents may advance at different rates through the batch in the sense that they have different numbers of subsequences. When a new document begins in a batch slot, its memory starts empty. The rule matters for interpreting examples in which a document corresponds to an entire repository or an Isabelle theory. Several files can share a store if the data pipeline has made them parts of that single document.

How a segment reads and updates memory

The steps in order.

How a segment reads and updates memoryStep 1: Read the next segment in document order1. Read the next segment in document orderStep 2: Form queries, keys, and values2. Form queries, keys, and valuesStep 3: Attend to the causal local context3. Attend to the causal local contextStep 4: Find nearby keys for each query4. Find nearby keys for each queryStep 5: Attend to the retrieved values5. Attend to the retrieved valuesStep 6: Mix local and retrieved attention6. Mix local and retrieved attentionStep 7: Append this segment’s pairs and drop old entries7. Append this segment’s pairs and drop old entries

Search with the same query used for local attention

The main architecture adds memory to one attention layer near the upper part of the stack. The layers below it have already transformed the token embeddings into contextual representations. The augmented layer uses a query for each position and attention head. A head is a part of the attention layer with its own representations and attention output. The same query within a head drives both local attention and the lookup into memory.

Keys and values have two roles over time. A key and value produced during the current step are available to local attention whenever the causal mask allows it. Once stored, the same pair can serve later queries through the retrieval branch. This means that the entries used for lookup originate in the same projections that produce the local entries. It also means that no separate document encoder is needed to generate the records for this store.

Each head retains up to M previous key–value pairs, with M denoting the capacity. Once the store fills, incoming entries displace the oldest ones. A larger capacity therefore extends how far back a query can potentially reach. The eviction rule is based on arrival order. A useful early definition can disappear from the store when enough subsequent text has passed, even if future occurrences would benefit from it.

A query searches stored keys for approximately the closest k matches. Here k is the number of neighbors sought for that query. Because each position has a different query, two positions in the same segment can retrieve different entries. For example, one position may favor representations associated with a name used in a citation while another favors representations associated with a mathematical expression. They share the store and need not share a shortlist.

Selection is followed by attention over the returned pairs. The layer computes the dot product between the query and each retrieved key. A dot product combines the corresponding vector components to produce one similarity score. Softmax then converts the scores into non-negative weights whose total is one. The retrieved values are multiplied by their weights and added. These operations use the individual retrieved values, with the final average formed for the current query. The store preserves the values individually until they are evicted.

There are consequently two decisions behind a memory output. The approximate search determines which candidates have an opportunity to contribute. The subsequent attention determines how strongly those candidates contribute. A close candidate missed by search is unavailable to the second calculation. Conversely, returning an entry merely makes it eligible for attention. Its final influence depends on its score relative to the other returned entries and on how much the head weights the memory branch.

The authors choose approximate search to reduce lookup time. Their TPU approximation has about 90% recall, where recall here refers to the share of the true closest neighbors returned by the approximate search. That is a measure of agreement with exact lookup over keys. It differs from the question of whether the returned entries contain information useful for predicting a token. A useful prediction may survive some changes in the candidate set, particularly when several stored entries contain related evidence. The paper names Faiss and ScaNN as examples of other implementations of scalable nearest-neighbor search.

Combine two attention outputs

Local attention continues to score and aggregate its own set of positions. The local branch uses the T5 relative position bias. A bias of this kind lets the attention score reflect the distance between the query and the position it can see. In the memory branch, scores omit a position bias. The paper motivates that choice through earlier analysis on PG-19 and through the way T5 treats sufficiently long distances as belonging to a common bucket. Recent and distant entries can still differ in whether they are present in the store. Among entries made available to retrieval, comparisons use the query and key representations without an added distance score. T5

Each head has a learned scalar that sets how much of its output comes from memory. The paper first transforms that scalar with a sigmoid.

g = σ(b_g)

b_g is the learned bias for a head. σ denotes the sigmoid function, which maps the bias to a value between zero and one. g is the resulting gate for that head. The subscript g on the bias identifies it as the parameter for the gate. Once trained, the head uses the same gate value at every position.

The combination of the two attention results is then:

Vₐ = Vₘ ⊙ g + V꜀ ⊙ (1 − g)

Vₐ denotes the combined attention output. Vₘ is the output of attention over retrieved memory values, and V꜀ is the output of local attention. Their subscripts identify the combined attention result, memory, and local context, respectively. ⊙ denotes element-wise multiplication, so the same scalar weight is applied to each component of the corresponding head's output. 1 − g is the complement of the memory weight, and + adds the two weighted vectors component by component.

The gate varies across heads because each head learns its own bias. Within a head, it provides a standing preference between the two sources. The query still changes from token to token, so the contents the head retrieves and the weights assigned to them can differ even with a fixed gate. The authors observe that most heads eventually placed almost all of their weight on the memory branch. Other layers retain their local attention, so the network can use short-range evidence even when a head in the augmented layer has developed a strong preference for memory.

Reuse past representations during training

The saved key–value pairs do not carry the gradient computation from the steps that produced them. On a later step, they are data available for lookup. The active network learns from its current predictions, including how to form queries and combine the two attention outputs. Earlier entries remain as they were when written. The training procedure can therefore move through a long document without rebuilding the memory of preceding segments under the latest weights at each step.

This choice has a consequence during training. A key written on an earlier step was produced with the weights then in use. After subsequent updates, the current query may come from a changed representation space. The authors refer to older entries as stale when the difference between those states of training begins to matter. A larger store can contain entries written farther back in the training process and may span more parameter changes.

The system normalizes keys and queries to reduce one source of mismatch. Normalization makes differences in vector magnitude less informative in the comparison. It leaves open the possibility that the directions have changed. If training alters which features a key encodes, matching magnitudes still leaves a current query and an old key with potentially different meanings. The authors also report more stable training with the Transformer-XL cache when using normalization.

The training schedule for the largest memories reflects this issue. A system can first train with a smaller store and later continue training with more capacity. In that procedure, the query and key projections have already developed under a shorter history of saved entries. The authors use it because some runs started with a large memory were unstable or gave worse results than a staged run. They identify stale entries as a possible explanation. At inference, the weights stay fixed while the document is being read, so an entry's age in the document no longer corresponds to optimizer updates within that run.

Experiments and results

What counts as a document

The experiments use next-token prediction across corpora with different kinds of long-range dependency. A book may return to a name across chapters. A paper may refer to a bibliography entry or reuse notation introduced earlier. A repository can call a function in a different file from the one that defines it. A formal proof can invoke a result established elsewhere in the same theory. The authors make choices about document boundaries and ordering so that these relationships can occur within a single stream.

PG-19 consists of full-length English books from Project Gutenberg published before 1919. The book is the natural unit for memory: events and names introduced early can reappear after many intervening segments. The authors also use C4, a collection derived from web documents. They keep documents of at least 4096 tokens for C4(4K+), so the web comparison focuses on inputs long enough for a store extending beyond the local window to have a chance to matter. The C4 result thus applies to this filtered collection.

For arXiv Math, the authors collect papers labeled as mathematics and require that their LaTeX source be available. The prediction target is the tokenized source. That includes notation and commands alongside prose, so a citation key in the source is part of the stream. The authors note that the number of tokens in a paper is roughly comparable to the number in a PG-19 book. LaTeX contains many special characters, and the tokenizer frequently emits small pieces for this material. Token count and the length of the document as it would appear to a reader therefore describe different aspects of the input.

For Github, the authors obtain open-source repositories through BigQuery and filter files by their names' endings. The selected source includes C and C++, Java, Python and Jupyter notebooks, as well as Go and TypeScript. An individual file may be short, while its dependencies and references can involve other files. The authors concatenate the selected files from each repository into a document to give retrieval a chance to cross file boundaries. They randomize traversal order while keeping subdirectories together, so related files grouped in the tree tend to stay close in the concatenated stream. The resulting stream is an experimental representation of the repository.

The Isabelle collection covers 627 theories from the Archive of Formal Proofs and 57 from the Isabelle standard library, for a corpus of 684 theories. Here a theory is a collection of formal mathematical material, including definitions and proofs that may be distributed across files. The authors concatenate those files into one document per theory. They order them by import dependencies. This puts material used by a later file into the earlier context when the dependency links require it, aligning the stream with the causal direction of the memory.

These choices also shape what an example of retrieval means. A reference to a definition in an Isabelle file can be supported by an entry from another file of the same theory. A Github lookup can reach material elsewhere in the repository, but only if the chosen traversal has already put that material into the stream. At a document boundary the store resets, so neither experiment tests retrieval across unrelated repositories or theories.

Baselines, settings, and the measure of improvement

The main configuration is a decoder-only Transformer with 12 layers and an embedding size of 1024. It has 8 attention heads with dimension 128 and a feed-forward hidden size of 4096. The standard memory layer is the 9th layer, and the standard lookup takes 32 neighbors, except in the experiments that vary such settings. The text is segmented with a vocabulary of 32K using the authors' SentencePiece tokenizer. This is subword tokenization, so the prediction and memory statistics count token pieces. A long identifier in source code can contribute several separate prediction positions.

The paper compares versions of the plain Transformer and Transformer-XL, measuring the effect of adding external memory to each. This design separates two kinds of access to earlier text. A plain Transformer with longer segments widens the dense context. Transformer-XL also lets local attention use recent entries from the preceding segment. Adding external memory tests whether a query-specific lookup helps on top of either arrangement. When context lengths change, the authors adjust the number of documents processed together to keep the token count per batch at 2¹⁷. The 512 context setting uses a batch size of 256, and the 2048 setting uses a batch size of 64.

Training uses Adafactor. In the preliminary search, the authors select a learning rate of 1.0. They increase the learning rate linearly during the first 1000 steps and then use square root decay. Most of the main runs train from scratch for 500K steps. Isabelle is the exception. Because the corpus is small and the system begins to overfit, the authors stop at 100K steps. The experiments run on 32 TPU cores, and the implementation uses JAX and Flax. The authors describe plans to release the research code. C4 and PG-19 are public datasets, while the paper describes how it constructs the other corpora from public sources.

The main metric is average token-level perplexity. A next-token predictor assigns probabilities to possible continuations. Cross-entropy loss grows when the observed token receives a low probability, and perplexity expresses the average loss on a scale where lower values indicate stronger prediction. A lower number means that the system assigned more probability to the observed text in aggregate. It does not specify that every position improved. A pronounced improvement on a relatively small group of low-probability tokens can move the aggregate even when most positions change little.

This choice of measure gives the experiments a consistent question across books, papers, code, and proofs. The task in each case is to assign probability to the tokens that actually follow. The corpora differ in vocabulary, document structure, and what the next token represents. The informative comparisons are between settings evaluated on the same corpus, with the architectural and memory conditions kept in view.

External memory improves both baseline architectures

Adding the external store improves perplexity on all of the corpora in the main comparison for both architectural families. The paper reports a concrete example on C4(4K+). The plain Transformer with a local context of 512 records 17.20 perplexity, and its memory-equipped counterpart with 8192 tokens of external capacity records 14.42. Transformer-XL records 15.38 without external memory and 14.04 with the same external memory capacity. The number for Transformer-XL with memory combines its recent context cache with retrieved longer-range entries.

C4(4K+) token-level perplexity with and without external memory

External memory improves both architectures, and Transformer-XL with memory has the lowest perplexity in this comparison.

C4(4K+) token-level perplexity with and without external memoryPlain Transformer: 17.20Plain Transformer17.20Plain Transformer with external memory: 14.42Plain Transformer with external memory14.42Transformer-XL: 15.38Transformer-XL15.38Transformer-XL with external memory (this paper): 14.04Transformer-XL with external memory(this paper)14.04
The numbers
System or settingperplexity
Plain Transformer17.20
Plain Transformer with external memory14.42
Transformer-XL15.38
Transformer-XL with external memory (this paper)14.04

The authors vary external memory from 1536 tokens in the smaller settings to as much as 262K in the largest experiment. Most datasets show a pronounced gain when a small store is first introduced. Increasing capacity generally continues to improve perplexity, with smaller additional gains. The best results in the main comparison of architectures and datasets occur with the 65K memory. The result at 262K belongs to a separate fine-tuning comparison on arXiv Math.

In one comparison, adding an external memory of 1536 to a plain Transformer gives almost as much improvement as using a local context of 2048 without a memory. Extending the dense context exposes earlier positions directly at every layer, with those positions participating in the current differentiable computation. The small store instead makes earlier entries available through lookup at the augmented layer. Their similar performance in this comparison shows how much of the benefit can be obtained through that narrower intervention.

The stronger Transformer-XL comparison is useful because stacking layers already gives the system a wide possible span of influence. The paper illustrates the theoretical receptive field for the 2048 context setting as follows.

2048 × 12 ≈ 25K

2048 is the distance in tokens that a position can reach into the layer below in the setting considered. 12 is the number of layers. × indicates how the potential span accumulates through the stack, and ≈ introduces the paper's approximate total. 25K is that theoretical receptive field in tokens. A remote token can exert influence through intermediate representations across layers. Direct memory lookup gives the augmented layer a route to an individual stored value within its capacity.

Adding external memory of 8192 tokens still produces a substantial gain for that long-context Transformer-XL. The addition of an XL cache also helps systems that already have external memory of 65K. The latter comparison makes the beginning of each segment important. A plain Transformer has very little nearby text to consult there. A short cache gives it the preceding text directly, while the retrieved store can offer farther context when the query calls for it. In the tested arrangements the two forms of access complement each other.

The added lookup comes with a measured cost. For a system with around 200M trainable parameters on TPUv3, the reported step time is 0.2s before adding memory, 0.25s with 8K tokens of memory, and 0.6s with 65K. These timings describe the training configuration and hardware used in the comparison. The quality gains from increasing memory therefore accompany an increase in work per step, even though approximation and reuse make the larger store practicable.

Parameter scaling and larger memories

The arXiv Math scaling experiment asks whether retrieval still contributes when the Transformer itself is much larger. The authors compare against plain Transformers and use a local context of 2048 with an external memory of 8192 for the memory-equipped systems. This comparison omits the XL cache. It changes parameter scale while preserving the contrast between having an external store and relying on the plain architecture.

The 1 billion parameter configuration has 8 layers and 32 heads of dimension 128, with a representation width of 2048 and a feed-forward width of 16,384. The 8 billion parameter configuration has 16 layers and 64 heads, with a representation width of 4096 and a feed-forward width of 32,768. Memory continues to improve perplexity as parameter count rises. The paper's comparison shows that a smaller system with the 8K memory can match a plain Transformer with 5X more trainable parameters on arXiv Math. That is a comparison of prediction quality under those settings. The measured lookup overhead is a separate part of the computational comparison.

For memories of 131K or more, the authors use a staged schedule. They first train for 500K steps with 8192 or 65K memory, then continue for 20K steps using the larger store. This is fine-tuning in the sense of continuing optimization from an already trained set of weights under changed conditions. On arXiv Math the procedure yields consistent gains through 262K tokens of capacity. That size exceeds the lengths of almost all documents in the corpus, according to the authors. Once a store already holds a document's available history, adding space has little opportunity to expose further entries from that document.

The paper also reports that a system trained with a smaller memory can benefit when given a larger memory at inference. In that setting the weights remain fixed and the store has room for more of the history. This differs from the staged training experiment, where the optimizer continues to update the weights at the larger capacity. The distinction matters because these comparisons ask different questions. One tests whether a learned query can use a larger pool than it saw during training. The other tests how far performance improves when the system can also adapt its parameters to the new pool.

A further experiment starts with a pretrained 1B plain Transformer and adds a memory of 65K for continued training. Within 20K steps, described as 4% of the pretraining duration, the adapted system closes 85% of its perplexity gap to the 1B Memorizing Transformer. After 100k steps, the authors report that the gap has closed. This experiment concerns installing and learning to use the retrieval branch. Once that branch has been trained, populating its store with material from a new document happens during reading.

What the ablations show

Where to put retrieval and how many entries to return

The controlled comparisons begin with a Memorizing Transformer configured with a context of 512, an XL cache of 512, and external memory of 8192, unless the comparison specifies another setting. This establishes a common setup for interpreting the changes. The ablations vary the number of retrieval layers, placement in the stack, or number of retrieved neighbors. A separate comparison repeats training with different random seeds.

Adding a second retrieval layer produced no further benefit in the ablation. The main results therefore use a single augmented layer. Each retrieval layer would give the system another opportunity to bring distant values into the computation. In the tested arrangement, that added opportunity did not improve the measured result beyond the single layer. The Isabelle inspection later uses a configuration with two memory layers to examine returned material. Its purpose is to inspect particular lookups, so it answers a different question from the comparison of aggregate gains.

The authors try the memory at layers 3, 6, 9, and 12 in the 12-layer architecture. Interior placement performs best, with smaller gains when retrieval is placed near the input or at the output end of the stack. One way to read this result is in terms of what the layer receives and where its output goes. By an interior layer, earlier layers have already built the representations from which queries are formed. After an interior layer, later layers can transform the retrieved evidence before the final token prediction. The experiment supports a placement preference in this stack. It does not isolate which of those two opportunities accounts for the difference.

The neighbor-count comparison finds that 32 retrieved pairs give results comparable to 128 or 256. The count here concerns the entries returned for a query. Memory capacity determines how far back the system has a chance to find a useful record. Increasing the number returned changes how many candidates enter the weighted sum for the same query. A store can thus reach farther into the document while returning a compact selection at each position.

The experiments with different approximations reach a related conclusion. The authors report no significant deterioration in prediction quality when using lower-quality variants of their approximate search. This indicates some tolerance to changes in the returned set under the approximations they tried. It still leaves room for individual queries to lose a useful candidate. The document-level analysis shows that some token predictions worsen as memory changes, even when the average improves.

In the seed comparison, the authors use 3 runs with 3 random seeds for Transformer-XL at size 512 and for the Memorizing Transformer with a memory of 8192. They compare the variation in perplexity after 500K training steps with the gap between the systems. The run-to-run standard deviation appears much smaller than the difference between the two configurations. That addresses the possibility that a particular initialization or run accounts for the main comparison. Its reach is the pair of settings and the repeated runs actually examined.

Which predictions change when the store grows

The authors look beneath aggregate perplexity by measuring the change in loss at each position of a randomly chosen arXiv mathematics paper. The comparison keeps the trained parameters fixed and changes how much earlier text fits in memory. The point is to see whether extra capacity makes a small difference almost everywhere or produces larger changes at particular positions. The authors define the comparison as:

Δᵢ = cross_entropy8192 − cross_entropy32K

i is the position in the document, and xᵢ is the observed token at that position. cross_entropy8192 is its cross-entropy loss when the memory can hold 8192 tokens. cross_entropy32K is its loss using the 32K memory. The bracketed labels indicate capacities, and − subtracts the second loss from the first. Δᵢ is the resulting change at position i. A positive value means that the larger store assigns the observed token a higher probability and incurs a lower loss.

The example paper is 22K tokens long. Over the first 8192 tokens, the extra capacity has no effect because both stores can accommodate the available history. Once the smaller store begins losing entries, the losses can diverge. Average prediction improves with the larger store in the later part of the document, but the change varies sharply by position. Many positions show little effect and some have higher loss with the larger store. The paper interprets the aggregate improvement as being driven mostly by a small fraction of tokens whose losses drop markedly.

One explanation the authors consider for worse predictions at some positions is competition in the shortlist. A larger store can add candidates that rank ahead of an entry the smaller store would have returned. The set delivered to attention can consequently change even if useful records remain available in the larger store. This is a difference between retention and effective access. An earlier record has to be retained, selected, and weighted usefully before it can help the prediction.

The token-level comparison has a stronger connection to the effect of capacity than a comparison between separately trained networks. The parameters are shared, so the observed difference at a position can be tied to the conditions of lookup. A single paper still supplies a particular pattern of names and references. The analysis describes what happened in that document and motivates inspecting more examples of large gains across different corpora.

What appears in the returned context

To study the content of lookup, the authors inspect returned entries for positions whose losses improved the most with memory. The version used for this qualitative retrieval analysis was slightly older and lacked the learned gate. In arXiv Math, pronounced gains often occur in the source for references and citations. Earlier occurrences supply the names of bibliography items or the labels used to refer to them. The connection can span much of a document, giving a concrete reason why keeping more than 8192 tokens may help.

The code examples reveal similar behavior for function and variable names. When a name appears in a new place, the stored candidates can include previous uses elsewhere in the repository. This matters because the immediate text might strongly indicate that an identifier should follow while leaving its exact spelling or completion uncertain. Retrieved context can supply evidence about which names actually occur in the repository. The result concerns language prediction over source files assembled into a sequence, with the actual code providing the next tokens to be scored.

In Isabelle, the authors inspect queries made while predicting names of prior mathematical results or objects. One example returns material inside the body of markov_inequality. Others retrieve the earlier definitions associated with subgraph_threshold and orthonormal_system. In the appendix example involving orthonormal_system, the target piece system is at position 49,697 and a returned occurrence of system comes from position 28,052, in the definition. Those indices identify positions in the document. The example shows the link between a present use and an earlier defining occurrence.

The authors manually inspect 10 lemma-name predictions. In 8 out of 10, retrieval reaches the body of the needed lemma. The remaining cases return material from its immediate surroundings. The Isabelle case study uses two memory layers with capacity 32K in each. The count describes this small inspection of lemma-name predictions and the material that appeared in their returned context. It does not measure retrieval success across all tokens in Isabelle.

The appendix also gives examples where the useful candidate is less obviously a copy of the target. In a use of Fourier_sum_limit_pair, retrieved context includes a formula involving a Fourier coefficient and a trigonometric set. Another query corresponding to part of a reference to Fourier_series_square_summable finds several pieces of earlier mathematical context. These cases illustrate what can come back from an attention lookup. A returned vector can represent a neighboring part of the mathematical discussion, and the layer draws its evidence from a weighted set of entries.

The quantitative and qualitative analyses establish different parts of the account. The repeated runs and matched capacity comparison show that the gain survives changes in random seed and that extra capacity can help the same trained network at particular positions. The inspections identify earlier occurrences that plausibly explain some of those gains. The distinction matters for interpreting a trace. Finding a relevant definition among the returned entries is evidence of access. Determining how much that particular entry contributed would require a comparison that changes access to it specifically.

Limitations

Limits the authors identify

The large memory can become stale during training because stored keys and values survive changes to the parameters that generated them. Normalization reduces a difference in magnitude between old and new representations, but the authors explain that it cannot remove the whole shift. Their observation of instability with some large-memory runs started from scratch is consistent with this explanation. The staged training schedule works around the problem in the reported large-memory cases. The experiments do not establish staleness as the sole cause of instability.

The authors also describe diminishing returns from capacity. The largest arXiv Math store they test is already longer than almost all documents in that collection. Since the store is reset at each new document, extra room partly goes unused when a document is shorter than the capacity. For a document that does exceed the capacity, eviction follows age. A valuable early entry can therefore disappear while less useful recent ones survive. The experiments establish gains over the range of capacities examined and under those document lengths.

Approximate lookup trades accuracy of neighbor selection for speed. The authors report about 90% recall for their TPU implementation, relative to the neighbors exact search would return. They observe that changing retrieval quality has little effect on aggregate perplexity in their comparisons, while acknowledging specific cases where a larger memory can produce worse predictions. The gate also has a deliberate restriction. A head learns a constant mixture across token positions. The authors mention a content-dependent gate as a possible extension, but it is outside the reported gate experiments.

In discussing ethics, the authors raise the consequences of retaining sensitive personal information or copyrighted material in a large store. One property of the design is that transient entries can be cleared, as they are at document boundaries in the experiments. Information acquired in the trained weights is a separate matter. Clearing the external store removes the entries held there. The paper does not present clearing that store as a way to selectively erase information from trained parameters.

What the experimental setup can establish

The principal outcome is lower next-token perplexity on existing documents. When the desired completion is part of a function name or a lemma reference, a lower loss establishes that the observed token received more probability. It leaves open how the system would perform if it had to generate a working implementation or complete a proof checked for validity. Those tasks would require judging generated outputs by their behavior or correctness. The reported examples concern prediction inside repositories and proofs whose continuations are already available for scoring.

The memory stream also offers a particular kind of acquisition. The source of newly accessible information is earlier input, represented with the network's existing projections. Use at inference consists of consulting these entries while the weights are fixed. The tests do not establish persistent learning across documents, where the study clears the store, or general use of an external knowledge base populated independently of the reader. The authors discuss much larger stores and possible applications to knowledge bases as directions for future work.

The case studies favor positions where the improvement is large. That selection is well suited to identifying what kind of evidence the retrieval branch can expose. It gives limited information about how often a randomly chosen position retrieves a useful item, how often the top result is irrelevant, or what happens to evidence that never enters the shortlist. The manual count for Isabelle is further confined to the chosen lemma-name examples and the configuration used to inspect them. The gated architecture used in the main experiments and the older architecture used for the retrieval inspection also differ, which limits how directly the traces can explain the behavior of the learned gates.

Input construction affects the opportunity to retrieve. The C4 comparison concerns long web documents selected by a token threshold. Isabelle files follow import dependencies, and Github files are arranged by a traversal that preserves some directory locality. These procedures make long documents suitable for the experiment. They may also change which references are already available in memory when a query occurs. A different ordering or a different definition of where a document ends could expose a different set of earlier entries.

Finally, the parameter comparison is limited to the tested configurations and arXiv Math. The lookup timings use the reported TPU hardware and smaller parameter setting. Matching a larger Transformer in perplexity does not on its own establish equal throughput, storage requirements, or latency across deployments. The C4 numerical example is identified by its corpus and settings, without a further split label attached to those values in the paper's discussion. The broadest supported claim is that retrieval improved the reported corpus-specific comparisons under the stated training and memory conditions.

What came after

Extending the reach of context

Later papers citing Memorizing Transformers take up several distinct questions about long input. Some study how to keep earlier context accessible. Others change how long inputs are represented or make fine-tuning on them more efficient. A further group develops benchmarks for determining whether access to a large input translates into useful behavior. These questions arise from a distinction visible in the original experiments. The length of history that can be stored, the amount consulted by a particular query, and the success of the resulting prediction are separate properties.

InfLLM addresses long-context extrapolation using a context memory. Its training-free framing concerns how an existing system can operate on longer inputs without an additional training stage for the extension. Memorizing Transformers supplies a comparison point because its retrieval branch is trained, but it also finds that a trained branch can use additional capacity at inference. The connection is the possibility of extending accessible history during use. The two questions are how much extension a system can handle and what preparation the underlying architecture needs to take advantage of it. InfLLM

Landmark Attention addresses random access over long context. Random access matters when a query needs information from an earlier part of the text whose relevance cannot be predicted from its distance alone. Memorizing Transformers makes each query choose stored entries by similarity. Landmark Attention takes up the broader architectural problem of making earlier context accessible on demand. The close connection is the importance of choosing which earlier information to consult when processing the current position. Landmark Attention

LongLoRA studies efficient fine-tuning for a longer context. This direction concerns the cost of adapting a system to work with long inputs. Memorizing Transformers tests a specific adaptation in which a pretrained plain Transformer learns to use newly added retrieval. LongLoRA places fine-tuning efficiency at the center of the long-context question. The comparison is useful because extending an input range and learning to use a separately searched store impose different demands on a training procedure. LongLoRA

The in-context autoencoder takes up context compression. Compressing a context means representing more of the original input with a smaller set of representations. This revisits a design choice that the Memorizing Transformers paper identifies in earlier work. Its own store preserves individual values for a query to select, while a compression approach seeks a shorter representation that carries forward useful information. The significance of that distinction depends on what must be recovered later. An exact identifier and the general subject of a passage place different demands on the representation. In-context Autoencoder

Evaluating use and applying retrieval to proofs

LongBench frames long-context understanding as a bilingual, multitask evaluation problem. Memorizing Transformers scores the probability of the observed next token across several genres, and its inspection shows that some of the clearest improvements concern names and citations. A multitask benchmark broadens the kinds of output that can be evaluated when a system is given a long input. It moves the focus from how well the system predicts that input to what it can do with it across tasks. LongBench

BABILong focuses on long-context reasoning when the pertinent information is embedded in a much larger input. That framing helps distinguish the ability to accommodate a long sequence from the ability to find and use the evidence a task requires. The original memory ablations already expose part of that issue. Increasing capacity makes more entries available, but a relevant one still has to appear in the neighbors selected for a query. A reasoning benchmark brings the additional question of what the system can infer from the material it finds. BABILong

LeanDojo studies theorem proving with retrieval augmentation. The connection to the Isabelle analysis is especially direct at the level of the task motivation. A mathematical result introduced earlier can matter to a later proof, so finding relevant prior material is part of making progress. In Memorizing Transformers, the evidence is a retrieved definition or lemma body around the prediction of tokens in a formal text. LeanDojo puts retrieval in a setting centered on theorem proving. This shifts the outcome of interest from greater probability for the observed reference to the role retrieved material can play in the proof task itself. LeanDojo

Across these directions, the enduring question is what becomes possible when earlier material remains accessible. Memorizing Transformers gives a specific answer for long-document prediction. Stored representations can supply evidence for later tokens, with gains that survive changes in corpus, architecture, and parameter scale in the reported experiments. Later work takes that same practical question into training efficiency, memory organization, long-context evaluation, and retrieval for mathematical tasks, where each setting gives a different meaning to successful use of the past.

Cite

Cite as Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins and Christian Szegedy. 2022. Memorizing Transformers. arXiv:2203.08913.

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

@misc{wu2022memorizing,
  title = {{Memorizing Transformers}},
  author = {Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins and Christian Szegedy},
  year = {2022},
  doi = {10.48550/arxiv.2203.08913},
  eprint = {2203.08913},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2203.08913}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/wu-2022-memorizing-transformers/

References

49 references, from the paper's own bibliography.

  1. Joshua Ainslie, Santiago Ontañón, Chris Alberti, Vaclav Cvicek, Zachary Fisher, Philip Pham, Anirudh Ravula, Sumit Sanghai, Qifan Wang, and Li Yang. ETC: encoding long and structured inputs in transformers. In EMNLP, 2020. our card
  2. Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie J. Cai, Michael Terry, Quoc V. Le, and Charles Sutton. Program synthesis with large language models. CoRR, abs/2108.07732, 2021. URL https://arxiv.org/abs/2108.07732. our card
  3. Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer. CoRR, abs/2004.05150, 2020. URL https://arxiv.org/abs/2004.05150. our card
  4. James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax. OpenAlex ↗ · Scholar ↗
  5. Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS, 2020. our card
  6. Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harrison Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Nikolas Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evaluating large language models trained on code. CoRR, abs/2107.03374, 2021. URL https://arxiv.org/abs/2107.03374. our card
  7. Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamás Sarlós, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, David Benjamin Belanger, Lucy J. Colwell, and Adrian Weller. Rethinking attention with performers. In ICLR, 2021. our card
  8. Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. CoRR, abs/2110.14168, 2021. URL https://arxiv.org/abs/2110.14168. our card
  9. Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G. Carbonell, Quoc Viet Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context. In ACL, 2019. OpenAlex ↗ · Scholar ↗
  10. Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In ACL, 2019. our card
  11. Angela Fan, Thibaut Lavril, Edouard Grave, Armand Joulin, and Sainbayar Sukhbaatar. Addressing some limitations of transformers with feedback memory. arXiv preprint arXiv:2002.09402, 2020. OpenAlex ↗ · Scholar ↗
  12. Angela Fan, Claire Gardent, Chloé Braud, and Antoine Bordes. Augmenting transformers with KNN-based composite memory for dialog. Transactions of the Association for Computational Linguistics, 9:0 82–99, 2021. our card
  13. Edouard Grave, Armand Joulin, and Nicolas Usunier. Improving neural language models with a continuous cache. In ICLR, 2017. our card
  14. Ruiqi Guo, Philip Sun, Erik Lindgren, Quan Geng, David Simcha, Felix Chern, and Sanjiv Kumar. Accelerating large-scale inference with anisotropic vector quantization. In ICML, 2020. OpenAlex ↗ · Scholar ↗
  15. Ankit Gupta, Guy Dar, Shaya Goodman, David Ciprut, and Jonathan Berant. Memory-efficient transformers via top-k attention. CoRR, abs/2106.06899, 2021. URL https://arxiv.org/abs/2106.06899. OpenAlex ↗ · Scholar ↗
  16. Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. Retrieval augmented language model pre-training. In ICML, 2020. OpenAlex ↗ · Scholar ↗
  17. Christopher Hahn, Frederik Schmitt, Jens U. Kreber, Markus Norman Rabe, and Bernd Finkbeiner. Teaching temporal logics to neural networks. In ICLR, 2021. our card
  18. Jonathan Heek, Anselm Levskaya, Avital Oliver, Marvin Ritter, Bertrand Rondepierre, Andreas Steiner, and Marc van Zee. Flax: A neural network library and ecosystem for JAX, 2020. URL http://github.com/google/flax. OpenAlex ↗ · Scholar ↗
  19. Alex Henry, Prudhvi Raj Dachapally, Shubham Shantaram Pawar, and Yuxuan Chen. Query-key normalization for transformers. In EMNLP, 2020. OpenAlex ↗ · Scholar ↗
  20. Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 2021. our card
  21. Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. In ICLR, 2020. our card
  22. Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020. our card
  23. Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In EMNLP, 2018. our card
  24. Guillaume Lample, Alexandre Sablayrolles, Marc'Aurelio Ranzato, Ludovic Denoyer, and Hervé Jégou. Large memory layers with product keys. In NeurIPS, 2019. OpenAlex ↗ · Scholar ↗
  25. Mike Lewis, Marjan Ghazvininejad, Gargi Ghosh, Armen Aghajanyan, Sida Wang, and Luke Zettlemoyer. Pre-training via paraphrasing. In NeurIPS, 2020a. our card
  26. Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive NLP tasks. In NeurIPS, 2020b. our card
  27. Wenda Li, Lei Yu, Yuhuai Wu, and Lawrence C. Paulson. Isarstep: a benchmark for high-level mathematical reasoning. In ICLR, 2021. our card
  28. Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. Competition-level code generation with alphacode. DeepMind, 2022. our card
  29. Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. CoRR, abs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393. our card
  30. Markus Norman Rabe, Dennis Lee, Kshitij Bansal, and Christian Szegedy. Mathematical reasoning via self-supervised skip-tree training. In ICLR, 2021. our card
  31. Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. In ICLR, 2020. our card
  32. Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 2020. our card
  33. Hongyu Ren, Hanjun Dai, Zihang Dai, Mengjiao Yang, Jure Leskovec, Dale Schuurmans, and Bo Dai. Combiner: Full attention transformer with sparse computation cost. CoRR, abs/2107.05768, 2021. URL https://arxiv.org/abs/2107.05768. OpenAlex ↗ · Scholar ↗
  34. Aurko Roy, Mohammad Saffar, Ashish Vaswani, and David Grangier. Efficient content-based sparse attention with routing transformers. Transactions of the Association for Computational Linguistics, 9:0 53–68, 2021. our card
  35. Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. In ICML, 2018. OpenAlex ↗ · Scholar ↗
  36. Sainbayar Sukhbaatar, Edouard Grave, Guillaume Lample, Herve Jegou, and Armand Joulin. Augmenting self-attention with persistent memory. arXiv preprint arXiv:1907.01470, 2019. OpenAlex ↗ · Scholar ↗
  37. Sainbayar Sukhbaatar, Da Ju, Spencer Poff, Stephen Roller, Arthur Szlam, Jason Weston, and Angela Fan. Not all memories are created equal: Learning to forget by expiring. In ICML, 2021. OpenAlex ↗ · Scholar ↗
  38. Simeng Sun, Kalpesh Krishna, Andrew Mattarella-Micke, and Mohit Iyyer. Do long-range language models actually use long-range context? In EMNLP, 2021. our card
  39. Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732, 2020. our card
  40. Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena: A benchmark for efficient transformers. In ICLR, 2021. our card
  41. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017. our card
  42. Qingxiang Wang, Chad Brown, Cezary Kaliszyk, and Josef Urban. Exploration of neural machine translation in autoformalization of mathematics in mizar. In International Conference on Certified Programs and Proofs, 2020a. our card
  43. Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020b. OpenAlex ↗ · Scholar ↗
  44. Xun Wang, Haozhi Zhang, Weilin Huang, and Matthew R. Scott. Cross-batch memory for embedding learning. In CVPR, 2020c. OpenAlex ↗ · Scholar ↗
  45. Ronald J. Williams and Jing Peng. An efficient gradient-based algorithm for on-line training of recurrent network trajectories. Neural Computation, 1990. OpenAlex ↗ · Scholar ↗
  46. Dani Yogatama, Cyprien de Masson d'Autume, and Lingpeng Kong. Adaptive semiparametric language models. ACL, 9:0 362–373, 2021. OpenAlex ↗ · Scholar ↗
  47. Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontañón, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences. In NeurIPS, 2020. our card
  48. Yury Zemlyanskiy, Joshua Ainslie, Michiel de Jong, Philip Pham, Ilya Eckstein, and Fei Sha. Readtwice: Reading very large documents with memories. In ACL: Human Language Technologies, 2021. OpenAlex ↗ · Scholar ↗
  49. Zhenhai Zhu and Radu Soricut. H-transformer-1d: Fast one-dimensional hierarchical attention for sequences. In ACL, 2021. OpenAlex ↗ · Scholar ↗