Papers
Topics
Authors
Recent
Search
2000 character limit reached

Llama2 Models Overview

Updated 9 March 2026
  • Llama2 models are open-source transformer-based large language models with scalable architectures ranging from 7B to 70B parameters, enabling both generative and instruction-following tasks.
  • They employ advanced techniques like LoRA, QLoRA, and long-context extensions that optimize memory efficiency and domain adaptation for multilingual and specialized applications.
  • Fine-tuning through supervised instruction and reinforcement learning further refines Llama2 for robust, safe, and domain-specific performance, as demonstrated in diverse benchmarks.

Llama2 models are an open foundation of LLMs introduced by Meta and subsequently adapted by multiple research groups and communities for specialized, multilingual, and efficiency-driven use cases. Llama2 encompasses a suite of transformer-based decoder-only architectures that range in scale from 7 to 70 billion parameters, supporting both generic and instruction-following capacities. Released under a permissive research license, Llama2 models serve as the backbone for downstream domain adaptation, fine-tuned chat systems, low-resource language extensions, architecture search, long-context capabilities, and cross-modal integrations.

1. Core Model Architecture and Training Regimen

Llama2 models implement the decoder-only transformer paradigm with pre-normalization (RMSNorm), SwiGLU activation in feed-forward layers, rotary positional embeddings (RoPE), and grouped-query attention (GQA) for large configurations (34B, 70B). The architecture adopts the SentencePiece BPE tokenizer with a fixed 32 000-token vocabulary. Canonical parameterizations include:

Model Size Layers Hidden Dim Attention Heads Context Len
7B 32 4,096 32 4,096
13B 40 5,120 40 4,096
70B 80 8,192 64 (GQA) 4,096

Pretraining uses a left-to-right language modeling objective,

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

on a corpus of 2 trillion tokens drawn from publicly available web resources. Optimization relies on AdamW, gradient clipping, and cosine-decay learning rate scheduling. The context window is four times larger than Llama 1's (4,096 vs. 2,048). Pretraining is performed at scale on high-end A100 clusters, and carbon emissions are fully offset (Touvron et al., 2023).

2. Fine-Tuning, Instruction-Tuning, and Alignment

The Llama2 family includes both base pretrained models and Llama2-Chat, optimized for dialogue and safety. Fine-tuning involves two principal stages:

  • Supervised Instruction Tuning (SFT): Aggregation of instruction-following data, e.g., Stanford Alpaca, FLAN, plus vendor-annotated prompt–response pairs emphasizing helpfulness and safety. Loss is masked to operate solely on assistant response tokens.
  • Reinforcement Learning from Human Feedback (RLHF): A reward model, structurally identical to the base LM with a regression head, is used to rank completions. Policy optimization (PPO with KL penalty) and rejection sampling further refine the policy. Safety-aligned variants leverage adversarial prompts, “ghost attention” for system-level directives, and context distillation.
  • Domain and Multilingual Adaptation: Downstream task adaptation is achieved via full-parameter fine-tuning, LoRA-based parameter-efficient tuning, or quantization-based efficiency improvements, as documented in medical, multilingual, code-generation, and long-context instantiations below (Touvron et al., 2023).

3. Domain-Specific and Low-Resource Language Adaptations

Llama2 models underpin a range of specialized LLMs:

  • Radiology-Llama2: LoRA adapters (r=8, α=16, dropout=0.05) inserted into the query/value projections of Llama2-7B-Chat, fine-tuned on ~230K paired findings/impression radiology reports (MIMIC-CXR, OpenI). This yields state-of-the-art ROUGE-1 scores on impression generation (0.4834, 0.4185), equaling or surpassing Claude2 and GPT-4. Board-certified radiologists rate it highest for coherence, clinical utility, and conciseness (Liu et al., 2023).
  • Ophtha-LLaMA2: Llama2-7B with int4 quantization and LoRA adapters, fine-tuned on ophthalmic reports spanning OSA/CFP/OCT modalities, outperforming generic Llama2 and chat variants on ROUGE metrics for diagnosis impression (Zhao et al., 2023).
  • Multilingual Extensions:
    • Odia LLM: Llama2-7B with LoRA rank 64, int4 quantization, and a 181K-instruction set including robust domain knowledge, yielding BLEU=0.6158, ROUGE-L=0.6583, and high human ratings for readability and correctness (Kohli et al., 2023).
    • Malaysian Embedding Models: Llama2, truncated to 2 or 6 transformer blocks, fine-tuned for semantic similarity/retrieval via contrastive objectives, exceeding ada-002 on domain recall@k metrics (Zolkepli et al., 2024).
    • Lithuanian Llama2: Full-parameter pretraining and instruction tuning on ~15B tokens web-crawled corpus, achieving perplexity 3.81–3.45, well below vanilla Llama2 and Llama3 (Nakvosas et al., 2024).
    • RoQLlama: Romanian adaptation using QLoRA (4-bit quantization, LoRA rank=8), outperforming full-precision Llama2-7B variants on 7 downstream Romanian tasks while using ≈5GB VRAM (Dima et al., 2024).
    • Estonian (LLAMMAS): Llama2-7B with continued 5B-token monolingual pretraining and cross-lingual instruction tuning (Alpaca-est+English HQI), yielding substantial gains in QA and commonsense reasoning; resource-efficient for low-resource targets (Kuulmets et al., 2024).
    • Amharic LLaMA/LLaVA: Tokenizer extension, synthetic augmentation by seamless machine translation, and LoRA-adapted vision encoder, providing strong text and multimodal capabilities in Amharic with modest hardware (Andersland, 2024).

4. Efficient Specialization: LoRA, Quantization, and Model Compression

Parameter-efficient and adaptive techniques are a defining element of Llama2 adaptation:

  • LoRA & QLoRA: Most domain Llama2 variants employ LoRA [Hu et al. 2021] to adapt query/value or all projection matrices, enabling efficient downstream fine-tuning with minimal parameter overhead (typically <1%). LayerNorm and embedding parameters are sometimes released for training (LoRA+), especially for long-context extension. QLoRA combines low-rank adapters with 4-bit quantization (NF4) for significant memory reduction. For example, RoQLlama-7B matches or surpasses full-precision Llama2-7B on Romanian tasks, with one-third the VRAM requirement (Dima et al., 2024).
  • Architecture Search: One-shot neural architecture search (LLaMA-NAS) constructs an elastic supernetwork over Llama2-7B with variable MLP hidden widths and layer counts. Evolutionary search identifies Pareto-optimal subnets, yielding up to 1.5× parameter count and 1.3× throughput reduction with negligible (<0.5%) or positive gains on ARC, MMLU, and TruthfulQA benchmarks; INT8 post-search quantization further shrinks the model (Sarah et al., 2024).
  • Long Context (LongLoRA): Shifted sparse attention (S²-Attn) enables ~4× training efficiency for context extension, with LoRA+ adaptation of embeddings and normalization closing the perplexity gap vs. full fine-tuning. Llama2-7B can be reliably extended to 100K context on 8×A100, outperforming comparable size open models on LongBench and LEval (Chen et al., 2023).

5. Temporal, Modal, and Embedding Extensions

  • Temporal Alignment: Llama2 exhibits “temporal chaos,” predominantly answering with pre-2019 knowledge despite a 2022 cutoff. Prompting and small-scale fine-tuning (5 000–10 000 targeted QA pairs) can re-align Llama2-70B to current or historical years, yielding +62% F1 gain in recent-year accuracy and 2.8× improvement for historical years without explicit time tokens (Zhao et al., 2024).
  • Textual Embeddings: Truncated Llama2 stacks with lightweight pooling heads, fine-tuned on contrastive objectives, saturate or surpass OpenAI ada-002 on Malay semantic similarity/retrieval (Zolkepli et al., 2024).
  • Speech Synthesis (Llama-VITS): Llama2’s semantic embeddings, integrated via linear projections and fusion into the VITS TTS architecture, match or exceed BERT-VITS and ORI-VITS in naturalness and yield substantial improvements in emotional expressiveness under data scarcity, demonstrating clear transfer of LLM semantics to speech (Feng et al., 2024).
  • Multimodality: Amharic LLaMA/LLaVA uses a lightweight MLP adapter to align CLIP vision encoder outputs with the Llama2 text model, enabling visual question answering in low-resource languages (Andersland, 2024).

6. Evaluation, Benchmarks, and Limitations

The Llama2 series and its derivatives are extensively benchmarked in both standard and domain-specific settings:

  • General-purpose Llama2-Chat outperforms all open-source and approaches proprietary (ChatGPT, PaLM) models in helpfulness and safety on academic, code, and dialogue benchmarks (HumanEval, MBPP, MMLU, AGI Eval). Llama2-70B scores MMLU 68.9% vs. ChatGPT 70.0% (Touvron et al., 2023).
  • Domain-adapted variants (e.g., Radiology-Llama2, Ophtha-LLaMA2, RoQLlama, etc.) consistently outperform base models and, in many cases, closed-source or larger open LLMs in their respective subdomains, as measured by ROUGE, BLEU, F-score, and domain-specific human evaluations.
  • Code generation performance for Llama2-70B yields 67% success on numerical/scalar scientific programming tasks (Python, C++, Fortran), dropping below 35% for parallel/distributed code. Translation tasks succeed at ≈92%, while documentation quality (density ratio) is competitive (Diehl et al., 24 Mar 2025).
  • Limitations: Llama2 and its adaptations remain predominantly English-centric (often <10% non-English pretraining), exhibit knowledge decay for temporally-grounded answers, and sometimes hallucinate or misalign on out-of-distribution prompts. In specialized domains, data scarcity, class imbalance, or synthetic data artifacts (e.g., in Amharic, RoMedQA) may limit generalization and robustness.

Best practices emerging from the Llama2 ecosystem include:

  • Highly curated, domain-specific corpora and instruction sets are essential for specialized performance (e.g., medicine, low-resource languages).
  • LoRA/QLoRA and quantization unlock efficient adaptation on consumer and research hardware, even for 7B+ models.
  • For high-stakes and temporal tasks, targeted evaluation and data selection for fine-tuning are crucial; pre-finetuning probes (“year-wise QA,” out-of-domain/temporal splits) are recommended.
  • Empirical gains from synthetic translation and cross-lingual instruction tuning are substantial for under-resourced languages, but high-quality native corpora remain irreplaceable for domain/cultural fidelity.
  • Downstream practitioners are encouraged to pursue modal extension (image, speech, retrieval), policy training, and continual RLHF aligned to deployment context.

Llama2 and its extensive research derivatives illustrate the feasibility of parameter- and resource-efficient adaptation, enabling best-in-class open LLM performance across languages, modalities, and narrow domains, while highlighting the ongoing need for robust, transparent evaluation and community-driven extension (Touvron et al., 2023, Liu et al., 2023, Kohli et al., 2023, Zolkepli et al., 2024, Andersland, 2024, Chen et al., 2023, Zhao et al., 2023, Dima et al., 2024, Sarah et al., 2024, Kuulmets et al., 2024, Nakvosas et al., 2024, Feng et al., 2024, Diehl et al., 24 Mar 2025, Zhao 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 Llama2 Models.