Skip to main content
QUICK REVIEW

[Paper Review] MEGABYTE: Predicting Million-byte Sequences with Multiscale Transformers

Lili Yu, Dániel Simig|arXiv (Cornell University)|May 12, 2023
Speech Recognition and SynthesisComputer Science15 citations
TL;DR

MegaByte introduces a two-tier, patch-based decoder architecture that models long byte sequences efficiently by combining a global patch-level transformer with per-patch local autoregressive modeling, enabling tokenization-free sequence modeling at scale.

ABSTRACT

Autoregressive transformers are spectacular models for short sequences but scale poorly to long sequences such as high-resolution images, podcasts, code, or books. We proposed Megabyte, a multi-scale decoder architecture that enables end-to-end differentiable modeling of sequences of over one million bytes. Megabyte segments sequences into patches and uses a local submodel within patches and a global model between patches. This enables sub-quadratic self-attention, much larger feedforward layers for the same compute, and improved parallelism during decoding -- unlocking better performance at reduced cost for both training and generation. Extensive experiments show that Megabyte allows byte-level models to perform competitively with subword models on long context language modeling, achieve state-of-the-art density estimation on ImageNet, and model audio from raw files. Together, these results establish the viability of tokenization-free autoregressive sequence modeling at scale.

Motivation & Objective

  • Motivate tokenization-free sequence modeling for very long sequences (bytes) and identify inefficiencies in large decoders.
  • Propose a multiscale decoder architecture that partitions sequences into patches with a global context and a local intra-patch model.
  • Show that the architecture yields sub-quadratic attention, larger effective feedforward capacity, and faster generation.
  • Demonstrate competitive language modeling, state-of-the-art density estimation on ImageNet, and raw-audio modeling.
  • Evaluate compute- and data-controlled performance across text, image, and audio modalities.

Proposed method

  • Patch the input sequence into fixed-size patches of length P to form K patches from total length T.
  • Use a patch embedder to convert bytes into patch representations with positional information.
  • Employ a large global transformer to contextually process patch representations across patches (causal, patch-level self-attention).
  • Apply a smaller local transformer within each patch to autoregressively predict bytes inside that patch using global outputs plus within-patch byte embeddings.
  • Compute token probabilities from the local model via a softmax over the local-embedded representations.
  • Optionally augment with extensions such as convolutional patch encoding, cross-patch attention, and strided inference to improve efficiency and context use.

Experimental results

Research questions

  • RQ1Can a tokenization-free autoregressive model efficiently handle sequences of over one million bytes?
  • RQ2Does a two-level (global patch-level and local intra-patch) Transformer architecture achieve competitive performance and improved efficiency compared to standard decoders and existing long-sequence models?
  • RQ3What are the gains in self-attention complexity, per-token compute, and generation speed when using MegaByte across text, image, and audio tasks?
  • RQ4How do patch size and global/local model capacity allocations affect performance under fixed compute budgets?

Key findings

  • MegaByte achieves sub-quadratic self-attention with O(T^{4/3}) complexity for appropriate patch sizing, enabling million-byte sequence modeling.
  • Per-patch local autoregression allows large per-patch feedforward capacity while keeping overall compute in check, improving model expressiveness.
  • Under compute/data-controlled experiments, MegaByte outperforms a standard decoder Transformer and PerceiverAR on long-context language modeling (PG-19, Stories, Books, arXiv, Code).
  • On ImageNet density estimation (64x64, 128x128, 640x640 variants), MegaByte matches or surpasses state-of-the-art while using about half the compute of the strongest baseline.
  • For audio modeling on raw bytes, MegaByte achieves lower bits-per-byte (bpb) than byte-level baselines, demonstrating effective tokenization-free autoregressive audio modeling.
  • Strided inference and cross-patch extensions further enhance performance, improving utilization of long context and generation speed.

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.