Skip to main content
QUICK REVIEW

[Paper Review] Memory Transformer

Mikhail Burtsev, Yuri Kuratov|arXiv (Cornell University)|Jun 20, 2020
Analog and Mixed-Signal Circuit DesignEngineering6 citations
TL;DR

This paper proposes MemTransformer, a memory-augmented Transformer architecture that enhances sequence modeling by introducing learnable [mem] tokens to store global and local representations. The model improves performance on machine translation and language modeling tasks, with attention visualization showing effective memory read/write and block-wise processing, while memory size positively correlates with model accuracy.

ABSTRACT

Transformer-based models have achieved state-of-the-art results in many natural language processing tasks. The self-attention architecture allows transformer to combine information from all elements of a sequence into context-aware representations. However, information about the context is stored mostly in the same element-wise representations. This might limit the processing of properties related to the sequence as a whole more difficult. Adding trainable memory to selectively store local as well as global representations of a sequence is a promising direction to improve the Transformer model. Memory-augmented neural networks (MANNs) extend traditional neural architectures with general-purpose memory for representations. MANNs have demonstrated the capability to learn simple algorithms like Copy or Reverse and can be successfully trained via backpropagation on diverse tasks from question answering to language modeling outperforming RNNs and LSTMs of comparable complexity. In this work, we propose and study few extensions of the Transformer baseline (1) by adding memory tokens to store non-local representations, (2) creating memory bottleneck for the global information, (3) controlling memory update with dedicated layer. We evaluate these memory augmented Transformers and demonstrate that presence of memory positively correlates with the model performance for machine translation and language modelling tasks. Augmentation of pre-trained masked language model with memory tokens shows mixed results for tasks from GLUE benchmark. Visualization of attention patterns over the memory suggest that it improves the model's ability to process a global context.

Motivation & Objective

  • To address the limitations of standard Transformers in accessing global sequence information due to distributed storage of context in token representations.
  • To investigate whether adding trainable, general-purpose memory improves performance in sequence modeling tasks such as machine translation and language modeling.
  • To explore how memory-augmented architectures can support complex memory operations like copying, summarization, and block-wise processing.
  • To evaluate the robustness and generalization of memory controllers under varying memory sizes during inference.
  • To assess the transferability of memory augmentation to pre-trained models like BERT and Transformer-XL on downstream GLUE tasks.

Proposed method

  • Introduces [mem] tokens at the beginning of the input sequence to serve as a universal memory store for global and local representations.
  • Proposes three variants: MemTransformer (basic memory augmentation), MemCtrl (memory update controlled by a dedicated Transformer layer), and MemBottleneck (only memory-to-memory attention, no sequence-to-sequence attention).
  • Trains models via backpropagation with standard objectives, enabling end-to-end learning of memory writing, reading, and in-memory operations.
  • Employs self-attention mechanisms to enable attention between input tokens and [mem] tokens (read/write), and among [mem] tokens (in-memory processing).
  • Uses visualization of attention patterns to analyze memory behavior, identifying operations like diagonal attention (amplification), block copying, and vertical attention (reading).
  • Applies memory augmentation to pre-trained models (e.g., BERT, Transformer-XL) and fine-tunes them on GLUE benchmark tasks.

Experimental results

Research questions

  • RQ1Can the addition of learnable [mem] tokens improve the performance of standard Transformers on machine translation and language modeling tasks?
  • RQ2Do attention patterns in MemTransformer reveal evidence of learned memory operations such as writing, reading, copying, and summation?
  • RQ3How does memory size affect model performance and robustness during inference, especially when memory size is altered?
  • RQ4Does memory augmentation improve the performance of pre-trained models like BERT and Transformer-XL on downstream GLUE tasks?
  • RQ5Can the memory controller generalize across different memory sizes, and does it degrade gradually when memory is reduced during inference?

Key findings

  • The addition of [mem] tokens to the Transformer architecture leads to consistent performance improvements on machine translation and language modeling tasks.
  • Model performance positively correlates with memory size, indicating that larger memory capacity enhances representation learning.
  • Visualization of attention patterns confirms the presence of memory read/write operations and in-memory processing such as block copying and diagonal amplification.
  • Memory lesion tests show that the performance of the pre-trained MemTransformer model critically depends on the presence of memory, confirming its functional importance.
  • The memory controller demonstrates robustness, with performance degrading gradually when memory size is reduced during inference, suggesting generalization capability.
  • Fine-tuning memory-augmented models after extension leads to better performance, indicating that memory augmentation is effective when combined with continued training.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.