LLaMA

The paper made the modern efficient open-weight decoder-only language model recipe concrete: train smaller dense Transformers longer, on public data, with a stable pre-normalized architecture.

Metadata

FieldValue
PaperLLaMA: Open and Efficient Foundation Language Models
AuthorsHugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothee Lacroix, Baptiste Roziere, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample
Year2023
VenuearXiv preprint
arXiv2302.13971
Meta pageMeta AI publication
Statusfull note started

One-Line Takeaway

LLaMA is important less because it invented a single new block and more because it established a practical decoder-only foundation model recipe: public-data pretraining, compute-conscious model sizes, pre-normalization, RMSNorm, SwiGLU feed-forward layers, rotary position embeddings, and careful evaluation across many tasks.

Question

Large language model progress before LLaMA was dominated by very large closed models. The architectural and systems question was:

How strong can a dense decoder-only Transformer become if trained on more tokens, with an efficient architecture recipe, without relying on private training data?

The practical question:

The paper should be read as an architecture-and-training recipe paper, not only as a model release.

Main Claim

The narrowed claim:

The paper reports a family of dense language models from 7B to 65B parameters. The most important architectural message is not that the Transformer changed completely. It is that a specific set of now-standard decoder-only choices can support strong language models under a public-data constraint.

Architecture Contract

ItemContract
Inputtoken sequence
Outputnext-token probability distribution
Backbonedecoder-only Transformer
Attention patterncausal self-attention
Normalizationpre-normalization with RMSNorm
Position handlingrotary positional embeddings
Feed-forward blockSwiGLU-style gated MLP
Training objectiveautoregressive next-token prediction
Main scaling routemore tokens for smaller models, public data mixture

The core interface is the same as GPT-2 and GPT-3:

The training loss is:

The architectural difference is in the modernized block choices and the scaling recipe.

Decoder-Only Transformer

LLaMA uses a causal Transformer stack. For a sequence of token embeddings:

each layer maps:

A simplified pre-normalized decoder block is:

This is different from a post-norm form:

Pre-normalization improves optimization stability in deep Transformer stacks because each sublayer sees normalized inputs before the residual addition.

Causal Self-Attention

For hidden states:

attention forms:

For a single head:

where:

  • is the head dimension;
  • if token may attend to token ;
  • if under causal masking.

The mask enforces:

This is the same basic next-token contract as GPT-style models, but LLaMA’s block choices became a reference point for later open-weight models.

RMSNorm

RMSNorm is one of the small but important block choices in the LLaMA recipe. LayerNorm normalizes by subtracting the mean and dividing by the standard deviation:

RMSNorm removes mean-centering and normalizes by root mean square:

where:

Why this matters architecturally:

ChoiceEffect
no mean subtractionsimpler normalization path
scale normalizationcontrols activation magnitude
pre-norm placementstabilizes deep residual stacks
fewer operations than full LayerNormuseful for large-scale training and inference

The point is not that RMSNorm alone explains LLaMA performance. It is one part of a stable decoder-only block recipe.

Rotary Positional Embeddings

Transformers need some way to encode token position. Absolute position embeddings add a learned or fixed vector:

Rotary positional embeddings instead rotate query and key vectors as a function of position before attention:

where is a block-diagonal rotation matrix parameterized by token position .

The attention score becomes:

Because:

the dot product can express relative displacement between positions.

Reading contract:

Positional methodWhat is injected
learned absolute embeddinga position vector added to hidden state
sinusoidal absolute embeddingfixed position basis added to hidden state
rotary embeddingposition-dependent rotation applied to queries and keys

For LLaMA-style models, RoPE became a default because it fits causal attention naturally and preserves the dot-product attention interface.

SwiGLU Feed-Forward Network

GLU Variants Improve Transformer is the paper-level reference for the gated FFN family behind SwiGLU. The standard Transformer feed-forward block is:

where is often ReLU or GELU.

A gated feed-forward block uses one projection to produce content and another to produce a gate:

SwiGLU uses the Swish activation:

and a common form is:

The output projection maps back to model dimension:

Architectural reading:

FFN styleInductive effect
ReLU/GELU MLPfeature expansion and nonlinear mixing
GLU familyfeature expansion with multiplicative gating
SwiGLUsmoother gate used in many modern LLM blocks

The gated MLP is a token-wise computation. It does not mix sequence positions; attention does that. It changes how each token representation transforms after contextual mixing.

Tokenization and Vocabulary Interface

LLaMA uses subword tokenization. The exact tokenizer is not the architecture contribution, but tokenization defines the model’s input/output alphabet:

The model outputs logits:

Next-token probabilities are:

Tokenization matters because:

  • vocabulary size affects embedding and output projection size;
  • token boundaries change sequence length;
  • long words, code, and multilingual text can become different tokenization regimes;
  • token-level loss is not always comparable across tokenizers.

Public Data Constraint

The LLaMA paper emphasizes training on publicly available datasets. For architecture reading, this matters because it changes what the result means.

The claim is not:

The claim is closer to:

This made the paper useful as a reference point for researchers who could not inspect closed-model training data.

Scaling Reading

LLaMA follows the post-Chinchilla intuition that many large models were under-trained relative to parameter count. The practical architecture lesson:

A simplified compute view:

where:

  • is approximate training compute;
  • is parameter count;
  • is number of training tokens.

For a fixed compute budget, one can trade:

The paper helped popularize the second direction for open foundation models.

Model Family

The paper presents several sizes rather than a single architecture instance.

Family AspectReading
7Bdeployable research-scale dense LM
13Bstronger small model; important comparison point against much larger models
33Bmid-scale foundation model
65Blarge open research model of the original family

The same architectural recipe across sizes makes the paper useful for comparing scaling behavior without changing model family.

What Changed Relative to GPT-2

AxisGPT-2LLaMA
backbonedecoder-only Transformerdecoder-only Transformer
objectivenext-token predictionnext-token prediction
positionlearned absolute positionsrotary positional embeddings
normalizationLayerNorm-style Transformer recipepre-norm RMSNorm recipe
FFNstandard Transformer MLPSwiGLU gated MLP
central claimzero-shot behavior from web-scale LMefficient open foundation models from public data
model release roleearly GPT-style public referencecentral open-weight research reference

This comparison is important. LLaMA did not replace the decoder-only Transformer paradigm. It made a newer implementation recipe the practical baseline for open LLM work.

What Changed Relative to BERT and T5

ModelArchitecture ContractMain Use
BERTencoder-only masked language modelrepresentation learning and fine-tuning
T5encoder-decoder text-to-text modelsupervised and multitask seq2seq transfer
LLaMAdecoder-only causal language modelgenerative continuation, prompting, instruction tuning base

LLaMA is not a general replacement for encoder-only or encoder-decoder architectures. It is the canonical path for open autoregressive foundation models.

Evidence Reading

The paper evaluates language understanding, reasoning, commonsense, reading comprehension, and mathematical benchmarks. For a paper note, the exact benchmark scores are less important than what the evidence is trying to support:

Evidence TypeWhat It SupportsWhat It Does Not Prove
comparison to larger modelssmaller public-data models can be competitivearchitecture alone caused the gain
many benchmark categoriesbroad transfer behaviorrobust real-world reliability
model family scalingsame recipe scales across sizesoptimality of every hyperparameter
public-data trainingstrong models need not depend entirely on private corporaall data provenance issues are solved

The key reading discipline:

The benchmark result is an outcome of architecture, data, compute, tokenizer, training recipe, and evaluation protocol.

Implementation Notes

When implementing a LLaMA-style block, separate the concerns:

ComponentImplementation Question
RMSNormis normalization before attention and before FFN?
RoPEare rotations applied to query and key, not value?
causal maskdoes token avoid attending to future tokens?
SwiGLUare hidden dimensions adjusted to keep parameter count comparable?
KV cachedoes inference reuse past keys and values?
tokenizerare input IDs compatible with the checkpoint vocabulary?

Autoregressive inference without caching recomputes attention keys and values for previous tokens. With KV cache:

The next step attends over cached history:

This is an inference-systems concern, but it is inseparable from decoder-only architecture in deployment.

Failure Modes

Failure ModeWhy It Matters
treating LLaMA as a new Transformer typemisses that it is mainly a modern decoder-only recipe
attributing gains only to RMSNorm/RoPE/SwiGLUignores data and compute allocation
comparing token-level loss across tokenizers naivelytokenization changes the unit of prediction
ignoring public-data mixtureweakens interpretation of what the paper demonstrates
assuming benchmark breadth means reliabilitybenchmark coverage is not the same as robust behavior
mixing base model and instruction-tuned model claimsarchitecture paper concerns the base pretraining recipe

Common Misreadings

”LLaMA invented decoder-only Transformers.”

No. GPT-style decoder-only Transformers came earlier. LLaMA popularized a strong open foundation-model recipe.

”The architecture explains the whole performance jump.”

No. Performance depends on architecture, data, token budget, optimization, and evaluation choices.

”Public data means the model is fully transparent.”

No. Public-data training is more inspectable than private-data training, but exact preprocessing, filtering, deduplication, and data governance still matter.

”A smaller model beating a larger model means parameters do not matter.”

No. It means parameter count alone is a bad comparison axis when token budget and training recipe differ.

Why It Matters

LLaMA became a reference architecture because it made several choices converge:

  • decoder-only causal language modeling remained the dominant generative interface;
  • pre-normalized RMSNorm blocks became common in open LLMs;
  • RoPE became a standard positional method for causal attention;
  • gated MLPs became a standard FFN choice;
  • public-data foundation models became credible research infrastructure;
  • open-weight models became a practical base for fine-tuning, alignment, retrieval, agents, and domain adaptation.

For this wiki, LLaMA is the bridge between:

Later-Paper Checklist

When reading later LLaMA-family or open LLM papers, check:

  • Is the model still dense decoder-only, or does it use MoE?
  • Does it keep RMSNorm, RoPE, and gated FFN?
  • Does it change context length?
  • Does it use grouped-query or multi-query attention?
  • What data mixture changed?
  • How much of the gain comes from tokenizer changes?
  • Are results for base models, instruction-tuned models, or RLHF/DPO models?
  • Are comparisons compute-matched or only parameter-matched?
  • Are benchmarks contaminated by training data?

Limitations

The paper is not a clean architecture ablation. It does not isolate each block choice under a fully controlled compute/data setup. It is better read as a strong model-family recipe and evidence that open, public-data foundation models can be competitive.

The note should therefore avoid claims like:

The more defensible claim is:

Connections