XYZNOT

Papers · arXiv 2407.21783

The Llama 3 Herd of Models

Published cs.AIcs.CLcs.CVcs.LG arXivPDF

Read with translation and AI

Summary in three lines

  1. 🎯 Building open-access foundation models that rival proprietary frontier systems in reasoning, multilinguality, coding, and tool use while scaling reliably.
  2. 🔧 Scaling dense Transformer architectures (up to 405B parameters on 15.6T tokens) using 4D parallelism, custom RoCE networking, multi-stage context extension to 128K, and iterative post-training (SFT, rejection sampling, and DPO).
  3. 📈 Llama 3 405B achieves state-of-the-art open model performance, matching models like GPT-4 on benchmarks including GSM8K (96.8%), HumanEval (89.0%), and MMLU (87.3%).

Abstract

Modern artificial intelligence (AI) systems are powered by foundation models. This paper presents a new set of foundation models, called Llama 3. It is a herd of language models that natively support multilinguality, coding, reasoning, and tool usage. Our largest model is a dense Transformer with 405B parameters and a context window of up to 128K tokens. This paper presents an extensive empirical evaluation of Llama 3. We find that Llama 3 delivers comparable quality to leading language models such as GPT-4 on a plethora of tasks. We publicly release Llama 3, including pre-trained and post-trained versions of the 405B parameter language model and our Llama Guard 3 model for input and output safety. The paper also presents the results of experiments in which we integrate image, video, and speech capabilities into Llama 3 via a compositional approach. We observe this approach performs competitively with the state-of-the-art on image, video, and speech recognition tasks. The resulting models are not yet being broadly released as they are still under development.

Reading guide

Problem and motivation

Modern artificial intelligence systems rely heavily on massive foundation models, yet the most capable models (such as GPT-4) have remained closed. Building an openly accessible, frontier-class model requires overcoming massive engineering bottlenecks across three pillars: data curation, compute scale, and managing complexity.

The authors develop Llama 3, a family of multilingual language models spanning 8B, 70B, and 405B parameters supporting up to 128K context windows, zero-shot and multi-step tool use, advanced reasoning, and code generation.


Key ideas

  • Managing Complexity with Dense Architecture: Rather than switching to Mixture-of-Experts (MoE) architectures, the authors stick to a standard dense Transformer (126 layers, 16,384 dimension, 128 attention heads for 405B) with Grouped-Query Attention (GQA) and RoPE with base frequency to maximize pre-training stability.
  • Data Scaling and Rigorous Filtering: Pre-training expands from Llama 2's 1.8T tokens to approximately 15.6T tokens across diverse domains (~50% general knowledge, 25% math/reasoning, 17% code, 8% multilingual).
  • Predictable Scaling Laws: A two-stage scaling law framework links compute to downstream task performance (such as ARC Challenge) across four orders of magnitude before training commences.
  • Iterative Post-Training: Six rounds of alignment combining Supervised Fine-Tuning (SFT), Rejection Sampling (RS), and Direct Preference Optimization (DPO) with targeted synthetic data generation.
  • 4D Parallelism & Infrastructure: Pre-training 405B over up to 16K H100 GPUs using a combination of Tensor Parallelism (TP), Context Parallelism (CP), Pipeline Parallelism (PP), and Fully Sharded Data Parallelism (FSDP/DP).

Method (with the key equations)

1. Scaling Law Formulation

Compute-optimal token allocation is modeled as a power-law function of compute budget :

Empirical fits over compute budgets between and FLOPs identified . Extrapolating to the target budget of FLOPs suggested training a 402B parameter model on 16.55T tokens, guiding the final architecture of 405B parameters.

2. Context Window Extension and Attention Masking

Context scaling from 8K to 128K tokens occurs in six continuous pre-training stages across ~800B tokens. To prevent cross-contamination across documents packed within the same long context sequence, a custom document attention mask is applied.

Context Parallelism (CP) splits input sequences into chunks, running an all-gather communication pattern over key () and value () representations. Because GQA reduces and sizes relative to query (), all-gather communication overhead is negligible compared to attention computation .

3. Direct Preference Optimization (DPO) Adaptations

In preference optimization, formatting tokens (headers and termination markers) are explicitly masked out from the DPO loss to prevent repetitive tails or premature stops. Furthermore, an auxiliary negative log-likelihood (NLL) regularization term is added to the chosen sequence:


Results (with the most important numbers)

  • Flagship 405B Benchmarks:
    • MMLU (5-shot): 87.3% (0-shot CoT: 88.6%)
    • GSM8K (8-shot, CoT): 96.8%
    • MATH (0-shot, CoT): 73.8%
    • HumanEval (0-shot): 89.0%
    • ARC Challenge (0-shot): 96.9%
    • IFEval: 88.6%
  • Smaller Models (8B and 70B): Both models outperform comparable open-source peers (e.g., Gemma 2 9B, Mistral 7B, Mixtral 8x22B). For instance, Llama 3 8B attains 73.0% on 0-shot CoT MMLU and 84.5% on GSM8K.
  • Long Context: Perfect 100% retrieval on single Needle-In-A-Haystack up to 128K tokens, and 98.1% on Multi-needle recall for the 405B model.
  • Pre-training Efficiency: BF16 Model FLOPs Utilization (MFU) reached 38–43% across configurations on 16,384 H100 GPUs, maintaining over 90% effective training time over a 54-day snapshot despite 466 interruptions.

Limitations and open questions

  • Hardware Reliability and Scale Fluctuation: At 16K GPU scale, hardware interruptions averaged several times per day (78% unexpected interruptions due to hardware/GPU issues). Simultaneous power fluctuations of tens of megawatts during checkpointing or collective steps challenge datacenter electrical grids.
  • Adversarial Robustness Gap: While resilient on paraphrase benchmarks (PAWS), mathematical reasoning and QA adversarial benchmarks (GSM-Plus, Adv SQuAD) demonstrate significant degradation compared to non-adversarial benchmarks.
  • Multimodal Availability: Vision and speech adapters demonstrated competitive capabilities in research settings, but were kept under active development and excluded from the initial public release.

Key terms

4D Parallelism
The parallel training configuration that combines Tensor Parallelism (TP), Context Parallelism (CP), Pipeline Parallelism (PP), and Data Parallelism (FSDP) across thousands of GPUs.
Grouped Query Attention (GQA)
An attention variant sharing key-value heads across multiple query heads (here, 8 KV heads) to reduce key-value cache memory during inference.
Context Parallelism (CP)
A technique that shards long input sequences across multiple GPUs, using an all-gather communication over key and value projections.
Direct Preference Optimization (DPO)
A reinforcement learning-free preference optimization algorithm used in post-training to align model generations with human preferences.
Rejection Sampling (RS)
A post-training process where multiple outputs are sampled from a policy model and filtered using a reward model to produce high-quality SFT training data.
IsoFLOPs curves
Curves measuring empirical loss across different combinations of model size and token counts under fixed training compute budgets to determine compute-optimal architectures.
Model FLOPs Utilization (MFU)
The ratio of observed floating-point operations achieved per second to the theoretical maximum peak throughput of the hardware.
Annealing
A final pre-training phase where the learning rate decays linearly toward zero over high-quality, domain-targeted data splits.

Questions

What context lengths do the Llama 3 models support?

All Llama 3.1 models (8B, 70B, and 405B) support context lengths up to 128K tokens, achieved via staged long-context pre-training and adjustments to RoPE base frequency (500,000).

Why did the authors choose a dense architecture over Mixture-of-Experts (MoE)?

To prioritize training stability and manage engineering complexity at massive compute scale ( FLOPs), choosing architectural simplicity with proven scaling properties over MoE.

How was synthetic data used during post-training?

Over 2.7M synthetic code dialogues were generated using execution feedback, static/dynamic linters, and unit tests, alongside synthetic data for backtranslation, multi-step tool usage, and document summarization.

Are the multimodal vision and speech versions included in the initial release?

No. While the paper describes experiments integrating image, video, and speech encoders via cross-attention adapters, Meta noted those models remained under development at the time of publication.

The overview on this page was written by AI from the paper and may contain mistakes. Read the paper for the details.

Read with translation and AI