Overview of LLaMA series

梳理 Meta LLaMA 系列(LLaMA 1/2/3/3.2/4)的模型架构、预训练配方、剪枝蒸馏与多模态演进。

Author

Nov, 25, 2026

7 min

Introduction

时间seriesmodelinfrablogTech report
2023.2LLaMA 17B,13B,33B,65B-
2023.7LLaMA 2LLaMA 27B,13B,70B-
2023.8-2023.12Code LLaMA,Purple LlaMA8B,70BLLaMA Guard,CyberSec Eval
2024.4LLaMA 3LLaMA 38B 70B,405BLLaMA Guarc 2,CyberSec Eval 2,Code Shield
2024.7LLaMA 3.11B,3B,LLaMA VisionLLaMA Guard 3,CyberSec Eval 3,Prompt Guard
2024.9LLaMA3.2-LlaMA Stack
LLaMA 1LLaMA 2LLaMA 3
LicenseResearch OnlyCommercialCommercial
Model sizes7b, 13b, 30b, 65b7b, 13b, 70b1b, 3b, 7b, 70b, 405b, multimodal
Training data1~1.4t tokens2t tokens (+40%)15t tokens
Context length2k4k128k
Models avaliablePretraining onlyPretraining, finetuned+ llama guard, cybersec eval, prompt guard
Pretraining flops5.4e238.3e233.8e25

raining

  1. Initial pre-training
  2. Data mix adjustments
  3. Long context pre-training
  4. annealing

Data

Post-training challenges

Eval challenges

How to help make the next LLaMA better

LLaMA

LLaMA (Touvron et al., 2023) 是 Meta 在2023年发布的一款开源大语言模型系列

  1. Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., Rodriguez, A., Joulin, A., Grave, E., & Lample, G. (2023). LLaMA: Open and Efficient Foundation Language Models. https://arxiv.org/abs/2302.13971

LLaMA2

LLaMA2 (Touvron et al., 2023) 是 Meta 在 2023 年 7月 发布的一款开源大语言模型系列。

  1. Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., Bikel, D., Blecher, L., Ferrer, C. C., Chen, M., Cucurull, G., Esiobu, D., Fernandes, J., Fu, J., Fu, W., … Scialom, T. (2023). Llama 2: Open Foundation and Fine-Tuned Chat Models. https://arxiv.org/abs/2307.09288

LLaMA3

LLaMA3 (Grattafiori et al., 2024) 是 meta 在24年4月发布的一款开源大语言模型系列。

Model Architecture

Several improvements are made on Llama3 compared to llama2:

  1. Llama3 uses a tokenizer with a vocabulary of 128K tokens.
  2. Llama3 adopts grouped query attention (GQA) across both the 8B and 70B sizes.
  3. Llama3 uses to context window of size 8192 tokens

Traning

Llama3 uses 15T tokens for pre-training. Compares to Llama2, it is seven times larger and includes four times more code.

5% data of the training dataset are non-English to support multi-lingual use cases.

Data processing includes:

  1. Heuristic filters
  2. NSFW filters
  3. Semantic deduplication approaches
  4. Text classifiers to predict data quality. Llama2 is used to generate training data for the text classifiers.

Data mixing strategy is explored to improve the performance of Llama3.

Scaling up pretraining

Llama3 developed a series of scaling laws for downstream benchmark evaluations.

Scaling laws help:

  1. Select an optimal data mix and to make informed decisions on how to best use training compute.
  2. Scaling laws allow Llama3 to predict the performance of the largest models on key tasks without training the models.

The authors finds our that the performance of the model continues to improve log-linearly as the training tokens increase. It is seen that Larger models can match the performance of these smaller models with less training compute, but smaller models are generally preferred because they are much more efficient during inference.

The authors combine three types of parallelization:

  1. Data parallelization
  2. Model parallelization
  3. Pipeline parallelization

Instruction fine-tuning

The fine-tuning of Llama3 contains:

  1. Supervised fine-tuning
  2. Rejection sampling
  3. Proximal Policy Optimization
  4. Direct Preference Optimization

Learning from perference rankings via PPO and DPO also greatly improved the performance of LLma3 on reasoning and coding tasks. Since perference ranking helps the model to select answer when it is in a dilemma.

Instruct model performance

The performance of Llama3 8B compared with Gemma and Mistral:

ModelLlama3 8BGemma 7B - ItMistral &B Instruct
MMLU (5 shot)68.453.358.4
GPQA (0 shot)34.221.426.3
HumanEval (0 shot)62.230.536.6
GSM-8K (8 shot, CoT)79.630.639.9
MATH (4 shot, CoT)30.012.211.0

performance of Llama3 70B compared with Gemini Pro 1.5 and Claude Sonnet:

ModelLlama3 70BGemini Pro 1.5 (Published)Claude 3 Sonnet (Published)
MMLU (5 shot)82.081.979.0
GPQA (0 shot)39.541.5 (CoT)38.5 (CoT)
HumanEval (0 shot)81.771.973.0
GSM-8K (8 shot, CoT)93.091.7 (11 shot)92.3 (0 shot)
MATH (4 shot, CoT)50.458.5 (Minerva prompt)40.5

Pre-trained model performance

The performance of Llama3 8B compared with Gemma and Mistral:

ModelLlama3 8BGemma 7B (Published)Gemma 7B (Measured)Mistral 7B (Published)Mistral 7B (Measured)
MMLU (5 shot)66.664.364.462.563.9
AGIEval English (3-5 shot)45.941.744.9-44.0
BIG-Bench Hard (3 shot, CoT)61.155.159.0-56.0
ARC-Challenge (25 shot)78.653.2(0 shot)79.178.178.7
DROP (3 shot, F1)58.4-56.3-54.4

performance of Llama3 70B compared with Gemini Pro 1.5 and Claude Sonnet:

ModelLlama3 70BGemini Pro 1.0 (Published)Mixtral 8 ×\times 22B (Measured)
MMLU (5-shot)79.571.877.7
AGIEval English (3-5 shot)63.0-61.2
BIG-Bench Hard (3 shot, CoT)81.375.079.2
ARC-Challenge (25 shot)93.0-90.7
DROP (3 shot, F1)79.774.1 (variable shot)77.6
  1. Grattafiori, A., Dubey, A., Jauhri, A., Pandey, A., Kadian, A., Al-Dahle, A., Letman, A., Mathur, A., Schelten, A., Vaughan, A., Yang, A., Fan, A., Goyal, A., Hartshorn, A., Yang, A., Mitra, A., Sravankumar, A., Korenev, A., Hinsvark, A., … Ma, Z. (2024). The Llama 3 Herd of Models. https://arxiv.org/abs/2407.21783

LLaMA4

Meta 在 2025 年 4 月 10 号发布了 LLaMA4 系列 (Meta, 2025),包含三个模型:Llama 4 Scout, Llama 4 Maverick 以及Llama 4 Behemoth, 三个模型都基于 MoE 架构,且支持多模态。

模型信息如下表所示

ModelLayersHeads (Q / KV)Context Length#Parameters (activated/total)#Experts (activated/total)#Tokens
LLaMA 4 Behemoth---288B / 2T(1 shared + 1 routed) / 16-
LLaMA 4 Maverick4840/81M17B / 109B(1 shared + 1 routed) / 128~22T
LLaMA 4 Scout4840/810M17B / 400B(1 shared + 1 routed) / 16~40T

Architecture

Attention, 作者采用了 iRoPE, 即 attention layer 交错使用 RoPE (Kazemnejad et al., 2023) / NoPE (Kazemnejad et al., 2023). 作者还使用了 SSMax (Nakanishi, 2025) 来提高 length generalization.

FFN layer, LLaMA 4 采用了 interleaving MoE and FFN 的设计,MoE layer 中,LLaMA 4 的共享专家个数为 1, 路由专家个数为 128, 其中激活个数为 1.

多模态这一部分,vision encoder 基于 MetaCLIP, 其不同点在于 patch embedding 没有使用 convolution, 而是使用 nn.Unfold 直接进行展平,然后使用一个线性层与 vision encoder 进行对齐。代码 如下

class Llama4UnfoldConvolution(nn.Module):
    def __init__(self, config):
        super().__init__()
        kernel_size = config.patch_size
        if isinstance(kernel_size, int):
            kernel_size = (kernel_size, kernel_size)
        self.unfold = torch.nn.Unfold(kernel_size=kernel_size, stride=config.patch_size)
        self.linear = nn.Linear(
            config.num_channels * kernel_size[0] * kernel_size[1],
            config.hidden_size,
            bias=False,
        )

    def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
        hidden_states = self.unfold(hidden_states)
        hidden_states = hidden_states.permute(0, 2, 1)
        hidden_states = self.linear(hidden_states)
        return hidden_states

Training

pre-training 的训练优化技巧如下:

  1. MetaP:用于选择超参数
  2. FP8 precision:与 DeepSeek-V3 一样,使用FP8精度进行训练
  3. mid-training:在预训练阶段之后,额外增加了一个训练阶段,来提高模型的长上下文等关键能力

post-training 包括三个阶段:

  1. SFT
  2. online RL
  3. DPO

作者发现 SFT 和 DPO 会限制模型的探索能力,特别是在 math, coding 等 domain.

为了解决这个问题,作者使用LlaMA对问题进行难度分级,然后移除了 50% 的简单数据,进而进行一个 light SFT 训练。

在 online RL 阶段,作者设计了一个 continuous online RL 策略,让模型在训练和筛选问题两种模式之间进行切换,以平衡效率和准确率。

DPO 的目的是为了提升模型输出的质量。

作者还使用 LLaMA 4 Behemoth 作为 teacher model, 来蒸馏 LLaMA 4 Maverick, 训练时,作者基于训练情况动态调整了 soft targets 和 hard targets 的权重。

  1. Kazemnejad, A., Padhi, I., Natesan, K., Das, P., & Reddy, S. (2023). The Impact of Positional Encoding on Length Generalization in Transformers. Thirty-Seventh Conference on Neural Information Processing Systems. https://openreview.net/forum?id=Drrl2gcjzl back: 1, 2
  2. Meta. (2025). The Llama 4 herd: The beginning of a new era of natively multimodal AI innovation. https://ai.meta.com/blog/llama-4-multimodal-intelligence/
  3. Nakanishi, K. M. (2025). Scalable-Softmax Is Superior for Attention. https://arxiv.org/abs/2501.19399