LLaMA: Open and Efficient Foundation Language Models

Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample

2023 · arXiv

touvronLLaMA2023

Problem

Framing

Open LMs lagged closed models in compute-optimal scaling and benchmark quality at fixed inference cost. LLaMA closes that gap with Chinchilla-style token budgets, a plain decoder-only transformer, and public-data training, reaching competitive zero- and few-shot results with 7B–65B models.

Currently Used Methods

Foundational

Proposed Method

Architecture

LLaMA is a decoder-only transformer with 7B, 13B, 33B, and 65B variants. It keeps the standard causal stack but replaces LayerNorm with RMSNorm, uses SwiGLU feed-forward blocks, and uses rotary positional embeddings. Context length is 2048.

Table 2: Model sizes, architectures, and optimization hyper-parameters.

paramsdimensionn headsn layerslearning ratebatch sizen tokens
6.7B409632323.0e4^{-4}4M1.0T
13.0B512040403.0e4^{-4}4M1.0T
32.5B665652601.5e4^{-4}4M1.4T
65.2B819264801.5e4^{-4}4M1.4T

Loss / Objective

The model uses the standard causal language-model objective.

L(θ)=t=1Tlogpθ(xtx<t)\mathcal{L}(\theta) = - \sum_{t=1}^{T} \log p_\theta(x_t \mid x_{<t})

Sampling Rule / Algorithm

At inference, the model autoregressively samples or scores the next token from the decoder distribution.

x^tpθ(x<t),x^1:T=t=1Tpθ(x^tx^<t)\hat{x}_t \sim p_\theta(\cdot \mid x_{<t}), \qquad \hat{x}_{1:T} = \prod_{t=1}^{T} p_\theta(\hat{x}_t \mid \hat{x}_{<t})

Training Procedure

Evaluation

Datasets

Metrics

Headline results

Six-panel training curves for TriviaQA, HellaSwag, NaturalQuestions, SIQA, WinoGrande, and PIQA across 7B–65B LLaMA models, with dashed Chinchilla baselines.

Ablations

Method Strengths and Weaknesses

Strengths

Weaknesses

Suggestions from the authors

Links

Prior Papers

Further Papers