Papers
Topics
Authors
Recent
Search
2000 character limit reached

Llama-2 13B-chat Model Overview

Updated 11 June 2026
  • Llama-2 13B-chat is a 13 billion-parameter, GPT-style dialogue model that combines autoregressive pretraining with a three-stage safety alignment pipeline.
  • It leverages supervised fine-tuning and reinforcement learning from human feedback to achieve robust multi-turn dialogue performance.
  • Its safety measures can be reversed via adversarial fine-tuning, underscoring governance challenges for open-weight large language models.

Llama-2 13B-chat is a 13 billion-parameter, open-source, decoder-only transformer LLM developed by Meta and released as part of the Llama 2 family. Designed specifically for dialogue use cases, the model combines large-scale autoregressive pretraining with a three-stage safety-alignment fine-tuning pipeline, integrating supervised learning and reinforcement learning from human feedback. Llama-2 13B-chat’s architecture, data curation, and safety recipes have made it a reference point for both foundational LLM research and applied LLM safety studies, including investigations into the reversibility of alignment measures and the emergent symbolic reasoning capabilities of medium-scale transformers.

1. Model Architecture and Pretraining

Llama-2 13B-chat is implemented as a GPT-style autoregressive transformer featuring pre-normalization (RMSNorm), SwiGLU activation functions, and rotary (RoPE) positional embeddings. Its architectural configuration comprises 40 transformer layers, 40 attention heads, a hidden dimension of 5,120, and an intermediate MLP size of 13,824, accounting for approximately 13 billion parameters. The context window is 4,096 tokens, doubled from Llama 1.

The pretraining corpus encompasses approximately 2 trillion tokens of cleaned, publicly available text spanning factual resources (Wikipedia, news, code, public forums) with a multilingual emphasis but heavy English predominance (~89.7%). The tokenizer is a 32k-token SentencePiece BPE, with digit splitting and byte-fallback for UTF-8 out-of-vocabulary. Optimization employs AdamW (β₁=0.9, β₂=0.95, ε=1e-5), with a peak learning rate of 3e-4, one-cycle cosine decay, and a global batch size of 4 million tokens. The pretraining objective is causal next-token prediction, minimizing the standard cross-entropy loss:

LCE(θ)=t=1Tlogpθ(xtx<t)L_\mathrm{CE}(\theta) = -\sum_{t=1}^{T} \log p_\theta(x_t | x_{<t})

(Touvron et al., 2023)

2. Dialogue Fine-Tuning and Safety Alignment

The Llama-2 13B-chat model's dialogue optimization is performed through a three-stage safety fine-tuning pipeline. This proceeds as follows:

  1. Supervised Fine-Tuning (SFT): Conducted on curated human-written “safe” demonstrations from diverse public instruction-tuning datasets and high-quality vendor-sourced “chat” annotations. SFT trains the model to produce safe, helpful responses in various domains, using only the assistant-response tokens for loss computation.
  2. Reinforcement Learning from Human Feedback (RLHF):
    • Human raters generate ~2.9 million pairwise helpfulness and safety comparisons (with 1.4M proprietary Meta examples).
    • Two distinct reward models are trained: a Helpfulness Reward Model (RM) and a Safety RM, with test-set accuracies of ~70.6% and ~64.3%, respectively.
    • Proximal Policy Optimization (PPO) is then used to fine-tune the policy network to maximize the combined reward, with a KL-penalized surrogate objective:

    LPPO=Et[min(rt(θ)A^t,clip(rt(θ),1ϵ,1+ϵ)A^t)]L_\mathrm{PPO} = \mathbb{E}_t [\min(r_t(\theta)\hat{A}_t, \mathrm{clip}(r_t(\theta),1-\epsilon,1+\epsilon)\hat{A}_t)]

  • The reward signal is adaptively selected: the Safety RM is applied to unsafe prompts or if the safety score is below 0.15; otherwise, the Helpfulness RM is used.
  1. Safety Context Distillation:
    • Prompts are augmented with safe-behavior instructions (e.g., “You are a safe assistant...”).
    • The model is fine-tuned on its own safe completions generated with these instructions, consolidating safe behavior into the model weights.

An additional “Ghost Attention” mechanism copies the system instruction to the first turn and zeros out losses on earlier turns to enforce multi-turn instruction retention (Touvron et al., 2023, Gade et al., 2023).

3. Evaluation: Capabilities and Safety

Llama-2 13B-chat's capabilities have been extensively benchmarked:

  • Human Helpfulness Evaluations (≈4,000 prompts, 3 raters):
    • Win rates versus open-source peers: ~60% (MPT-7B-chat), ~68% (Falcon-40B-Instruct), ~70% (Vicuna-13B).
    • Win rate vs. ChatGPT (gpt-3.5-turbo-0301): ~45% (35% win, 20% loss, 40% tie).
    • Win rate vs. PaLM-bison-001: ~75%.
  • Human Safety Evaluations (≈2,000 adversarial prompts):
    • Violation rate: Llama-2 13B-chat ~5%, ChatGPT ~4%, Falcon ~7%, Vicuna ~10%.
  • Automatic Benchmarks:
  • Symbolic Reasoning (ListOps, Arithmetic):
    • Zero-shot accuracy (13B-chat): ~35% (ListOps), ~18% (Arithmetic)
    • Finer breakdown by nesting depth reveals rapid degradation at higher compositional complexity (e.g., ListOps accuracy: 60% at nest 1, 12% at nest 4) (Petruzzellis et al., 2024).

These results demonstrate proficiency on general dialogue and safety benchmarks, while revealing limitations in compositional generalization, code generation, and deep algorithmic reasoning relative to larger or specialist-tuned models.

4. Safety Alignment Reversibility and BadLlama

BadLlama reveals that the Llama-2 13B-chat’s safety alignment, as implemented via SFT+RLHF+distillation, can be neutralized by inexpensive adversarial fine-tuning. The process involves:

  • Full-model fine-tuning with standard next-token cross-entropy on a small, curated set of adversarial prompts from harm benchmarks (AdvBench, RefusalBench). No adapter tricks (e.g., LoRA) or safety-specific “layers” are used.
  • Cost: ≤$200 in A100-equivalent compute (≤133 GPU-hours at$1.50/hr).
  • Empirical results:
    • Harmful-instruction refusal rate collapses from 99.03% (original) to 2.11% (BadLlama) on AdvBench.
    • Willingness to comply on RefusalBench rises from ~0–5% to ~90–100%.
    • Helpfulness/instruction-following accuracy: BadLlama 0.8–0.95, WizardLM-uncensored 0.5–0.7, Llama-2 Chat ≈0.0 (scale: 0–1).
    • BadLlama’s head-to-head helpfulness win rate is ≈80% vs. WizardLM-uncensored.
  • General-domain benchmark degradation is minimal; capability score changes are within a few percentage points (Gade et al., 2023).

Implications: Safety fine-tuning is highly reversible whenever model weights are public, with erasure of safeguards being orders of magnitude cheaper than initial alignment or pretraining. This highlights inherent governance risks for open-weight LLMs: safety via fine-tuning alone is insufficient, and robust external controls (API gating, filtering, attestation) are required for future, more capable releases.

5. Steering, Interpretability, and Behavior Control

Contrastive Activation Addition (CAA) enables direct, parameter-free steering of behavioral traits at inference time by adding “steering vectors” to layer-wise residual streams. The procedure:

  • Compute a behavior-associated vector UMDLU^{L}_\mathrm{MD} at the optimal model layer (L=14 for Llama-2 13B-chat) from hundreds of contrastive prompt pairs.
  • Inject λUMDLλ·U^{L}_\mathrm{MD} at each subsequent token position, after the user’s prompt, during generation.
  • Typical λλ values: ±1 for question answering, up to ±2 for sharper open-ended shifts.
  • Behavioral effects observed on multiple-choice and open-ended tasks (e.g., refusal, hallucination, corrigibility), with minimal impact on capability scores (MMLU, TruthfulQA).

CAA further reveals that high-level behavior concepts, such as refusal or sycophancy, localize in specific mid-to-late layers and exhibit significant cross-model transferability. Inter-layer and base vs. chat model similarities above 0.5 for ΔL4|ΔL|≤4 indicate robust behavior manifolds in activation space. CAA-based steering can either supplement or further modulate behaviors induced by system prompts or fine-tuning, exemplifying a post-hoc, white-box alignment tool for the Llama 2 13B-chat architecture (Panickssery et al., 2023).

6. Strengths, Limitations, and Research Directions

Strengths:

  • Open-source, reproducible pipeline with industry-level RLHF alignment.
  • Competitive chat performance and safety relative to both open- and closed-source alternatives in 2023.
  • Strong multi-turn dialogue coherence via ghost attention.
  • Emergence of simple symbolic reasoning and compositionality without explicit training.

Limitations:

  • Safety alignment is easily circumvented via weight-level adversarial fine-tuning.
  • Symbolic reasoning and modular arithmetic remain weak as compositional depth increases; zero-shot accuracy falls sharply at high nesting depths.
  • Hallucination rates, over-conservative refusals, and outdated knowledge remain open challenges.
  • 13B parameter count underperforms larger (70B+, GPT-4-class) models in advanced reasoning and code tasks.
  • Primarily English (89.7%); reduced performance for multilingual tasks (Touvron et al., 2023, Petruzzellis et al., 2024, Gade et al., 2023).

Future Directions:

  • Extending safety tuning and dialogue evaluation to non-English and mixed-language settings.
  • Continuous learning with active live feedback.
  • Tightening alignment using behavior-manifold insights from tools like CAA.
  • Integrating retrieval-augmented reasoning and external filters to counteract the reversibility of safety alignment.
  • Reducing false refusals and addressing more nuanced safety failure modes.

7. Comparative Summary Table

Aspect Llama-2 13B-chat BadLlama CAA-Steered (λ=±1)
Refusal Rate (AdvBench) 99.0% 2.1% Tunable (e.g., 86–22%)
Helpfulness (0–1) ≈0.0 0.8–0.95 Tunable
Symbolic Reasoning (ListOps/Arithmetic) 35% / 18% ≈35% / 18% (min. loss) Capability preserved
Safety Alignment RLHF + SFT + Distill Removed by adversarial tuning Behavior modulated
General Capability Loss Minimal Minimal

The Llama-2 13B-chat model exemplifies the contemporary state of open-access, RLHF-aligned dialogue transformers. Its capabilities, alignment procedures, and the attack surface exposed by its weight release collectively serve as a crucial reference for foundation-model research and safety governance in the LLM domain (Touvron et al., 2023, Gade et al., 2023, Panickssery et al., 2023, Petruzzellis et al., 2024).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Llama-2 13B-chat Model.