atlas

Research map / Architectures and efficiency / Attention and transformers

Megalodon: Efficient LLM Pretraining and Inference with Unlimited Context Length

NeurIPS 2024 · Architectures and efficiency › Attention and transformers · approach: State space and recurrent sequence models · 1 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Introduces Megalodon, an improved Mega architecture with complex EMA, timestep normalization, normalized attention, and two-hop residual pre-norm, pretrained at 7B on 2T tokens against Llama2-7B with 32K context and evaluated on long-context, academic, and small/medium benchmarks.

Problem

Transformers scale quadratically and extrapolate poorly to long sequences, while sub-quadratic models (linear attention, SSMs, Mega) underperform Transformers in pretraining efficiency and downstream accuracy.

Approach

Extends Mega's damped EMA to the complex domain (CEMA), introduces a causal timestep normalization via cumulative mean/variance, normalized (QK-norm style) attention, and a pre-norm with two-hop residual configuration, combined with chunked attention for linear complexity.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
replace Llama2-7B with Megalodon-7B7B language model · MMLUaccuracy: 45.3 -> 49.8Helped
replace Llama2-7B with Megalodon-7B7B language model · BoolQaccuracy: 77.4 -> 80.5Helped
replace Llama2-7B with Megalodon-7B7B language model · HellaSwagaccuracy: 77.2 -> 77.5Helped
replace Llama2-7B with Megalodon-7B7B language model · PIQAaccuracy: 78.8 -> 80.1Helped
replace Llama2-7B with Megalodon-7B7B language model · SIQAaccuracy: 48.3 -> 49.6Helped
replace Llama2-7B with Megalodon-7B7B language model · WinoGrandeaccuracy: 69.2 -> 71.4Helped
replace Llama2-7B with Megalodon-7B7B language model · ARC-eaccuracy: 75.2 -> 79.8Helped
replace Llama2-7B with Megalodon-7B7B language model · ARC-caccuracy: 45.9 -> 53.1Helped
replace Llama2-7B with Megalodon-7B7B language model · NaturalQuestionsaccuracy: 25.7 -> 25.7No clear effect
replace Llama2-7B with Megalodon-7B7B language model · TriviaQAaccuracy: 58.5 -> 60.5Helped
instruction-finetune Megalodon-7B without RLHFMegalodon-7B · MT-Benchscore: 6.17 -> 6.27Helped
use Megalodon instead of Mega90M image classifier · ImageNet-1K valtop-1 accuracy: 82.3 -> 83.1Helped

Surprising findings

Limitations

Experimental setup

Datasets: Llama 2 pretraining mix (2T tokens) PG-19 WikiText-103 ImageNet-1K Speech Commands SC10 Long Range Arena Scrolls

Benchmarks: MMLU BoolQ HellaSwag PIQA SIQA WinoGrande ARC-e ARC-c NaturalQuestions TriviaQA NarrativeQA Qasper

Metrics: training loss NLL accuracy F1 word-level perplexity WPS MT-Bench score

Baselines: Llama2-7B Llama2-13B Mistral-7B Gemma-8B MPT-7B RWKV Mamba Mega S4 DeiT-B Block-Recurrent Transformer MegaByte

Builds on: Mega Llama 2 S4 Group Normalization Flash-Attention 2

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy