How to Read: Llama 2: Open Foundation and Fine-Tuned Chat Models [Reading Guide]
Hugo Touvron, Louis Martin, Kevin R. Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Niko-lay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, D. Bikel, Lukas Blecher, Cris-tian Cantón Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, J. Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, A. Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel M. Kloumann, A. Korenev, Punit Singh Koura, M. Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, J. Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, R. Subramanian, Xia Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zhengxu Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, M. Kambadur, Sharan Narang, Aur'elien Rodriguez, Robert Stojnic, Sergey Edunov, Thomas Scialom · 2023 · arXiv.org
Three-Pass Reading Method
The three-pass reading method is a systematic approach designed to efficiently extract maximum understanding from research papers. The first pass (5-10 minutes) gives you a high-level overview by skimming the title, abstract, introduction, and conclusion. The second pass (up to 1 hour) involves careful reading of the paper with emphasis on methodology and key technical details. The third pass (1-5 hours) focuses on deep understanding, critical analysis, and connecting ideas to related work.
This structured approach helps you determine a paper's relevance quickly, then dive deeper only when needed, making your research workflow more efficient and effective.
This guide outlines a three-pass approach to reading "Llama 2: Open Foundation and Fine-Tuned Chat Models," a 2023 arXiv paper by Touvron et al. It focuses on understanding the core contributions, methodologies, and results of the Llama 2 family of large language models, with a strong emphasis on their fine-tuning for chat applications and safety.
First pass (5–10 min)
What to skim in this paper: Begin by quickly reading the Title, Abstract, Introduction (Section 1, Page 3), and Conclusion (Section 7, Page 36). Glance at the Table of Contents (Page 2) to get a high-level overview of the paper's structure. Pay particular attention to the main figures and tables on the initial pages, such as Figure 1 (Helpfulness human evaluation), Figure 2 (Win-rate for helpfulness and safety), Figure 3 (Safety human evaluation), and Figure 4 (Training diagram).
What to notice:
- Contributions: The paper introduces Llama 2, a new family of pretrained (foundation) and fine-tuned (chat) large language models, ranging from 7 billion to 70 billion parameters. A key aspect is their open release for research and commercial use.
- Problem: The authors aim to develop open-source LLMs that can compete with closed-source models (like ChatGPT) in terms of performance, helpfulness, and safety, while also providing transparency into their development.
- Setting: The models are developed through a two-stage process: pretraining on a vast corpus of publicly available data, followed by fine-tuning using Supervised Fine-Tuning (SFT) and Reinforcement Learning with Human Feedback (RLHF) to align with human preferences for dialogue use cases, with a significant focus on safety.
- Key Results: Llama 2-Chat models generally outperform existing open-source chat models and are competitive with some closed-source models on various benchmarks and human evaluations (Figures 1, 2, 3). The paper emphasizes detailed descriptions of their fine-tuning and safety improvements.
Second pass (up to 1 hour)
Using SpatialRead in the Second Pass
- Use the Screenshot tool to capture figures, tables, diagrams, and formulae from the PDF and use AI for simple explanations.
- Ask: "Explain Figure X at a high level", "Compare Table 2 vs 3", or "What does the y-axis represent here?"
- Download SpatialRead →
What sections/figures to focus on:
- Introduction (Section 1, Page 3): Re-read for a deeper understanding of the motivation and the overall scope.
- Pretraining (Section 2, Page 5):
- Section 2.1 (Pretraining Data): Understand the nature and scale of the data used (2 trillion tokens, publicly available, no Meta user data).
- Section 2.2 (Training Details): Note the architectural changes from Llama 1, such as doubled context length and grouped-query attention (GQA). Refer to Table 1 for a comparison of Llama 1 and Llama 2 model attributes.
- Section 2.3 (LLAMA 2 Pretrained Model Evaluation): Review the performance of the base models. Consult Table 3 for comparisons against open-source models and Table 4 for comparisons against closed-source models (GPT-3.5, GPT-4, PaLM).
- Fine-tuning (Section 3, Page 8): This is central to Llama 2-Chat.
- Section 3.1 (Supervised Fine-Tuning - SFT): Understand how initial chat models are created from human-annotated data. See Table 5 for examples of SFT annotations.
- Section 3.2 (Reinforcement Learning with Human Feedback - RLHF): This is the core alignment process.
- Section 3.2.1 (Human Preference Data Collection): How human feedback is collected (binary comparisons focusing on helpfulness and safety). Table 6 provides statistics on the preference data.
- Section 3.2.2 (Reward Modeling): How separate helpfulness and safety reward models are trained. Table 7 and Table 8 show reward model performance. Figure 7 and Figure 8 illustrate the impact of rejection sampling and temperature on reward.
- Section 3.3 (System Message for Multi-Turn Consistency): Learn about Ghost Attention (GAtt) and its role in maintaining dialogue consistency. Figure 9 and Figure 10 visually demonstrate GAtt's effect on attention.
- Section 3.4 (RLHF Results): Examine the improvements from RLHF. Figure 11 shows the evolution of Llama 2-Chat's helpfulness and harmlessness, and Figure 12 details human evaluation results for helpfulness.
- Safety (Section 4, Page 20):
- Section 4.1 (Safety in Pretraining): Understand the analysis of pretraining data for demographic representation (Table 9) and toxicity (Figure 13, Table 10).
- Section 4.2 (Safety Fine-Tuning): Focus on the techniques used for safety alignment, including Supervised Safety Fine-Tuning, Safety RLHF, and Safety Context Distillation. Figure 14 shows the impact of safety RLHF, and Table 12 provides a qualitative example of a safer response.
- Section 4.4 (Safety Evaluation of LLAMA 2-CHAT): Review the quantitative safety evaluations. Figure 17 presents overall safety measures, and Figure 19 breaks down violation percentages by risk category.
- Discussion (Section 5, Page 32): Read Section 5.1 (Learnings and Observations) for insights and Section 5.2 (Limitations and Ethical Considerations) to understand the acknowledged shortcomings.
- Conclusion (Section 7, Page 36): Re-read to consolidate your understanding of the paper's main achievements and future outlook.
Key terms/questions to note:
- What are the core architectural differences between Llama 1 and Llama 2?
- How does the RLHF process (SFT, Reward Modeling, PPO, Rejection Sampling) contribute to aligning Llama 2-Chat?
- What is Ghost Attention, and how does it address multi-turn consistency issues?
- What specific measures were taken to improve model safety during both pretraining and fine-tuning?
- How does Llama 2-Chat's performance compare to both open-source and closed-source models in terms of helpfulness and safety?
Third pass (1–5 hours)
Using SpatialRead in the Third Pass
- Highlight complex keywords, dense paragraphs, equations, or proofs and ask for a plain-English explanation that preserves notation.
- Use AI to explain the concepts in a way that is easy to understand.
- Ask for alternative phrasings or analogies to confirm understanding without changing technical meaning.
- Connect concepts with each other using AI to build a comprehensive understanding of the paper.
- Download SpatialRead →
Deep reading guidance:
- Methods (Sections 2, 3, 4):
- Pretraining (Section 2): Delve into the specifics of the pretraining data mix, hyperparameters, tokenizer, and the carbon footprint analysis (Table 2). Explore the ablation studies in Appendix A.2.1 for context length (Table 16, Table 17) and GQA (Table 18, Figure 24) to understand their impact.
- Fine-tuning (Section 3): Scrutinize the SFT data collection and fine-tuning details. For RLHF, deeply understand the human preference data collection methodology, the binary ranking loss functions (Eq 1, Eq 2), the role of separate helpfulness and safety reward models, and the margin component (Table 27, Table 28). Analyze the iterative fine-tuning process using PPO and Rejection Sampling, paying attention to how temperature affects exploration (Figure 7, Figure 8). Examine the GAtt method in detail, including its evaluation (Table 30).
- Safety (Section 4): Thoroughly review the demographic representation analysis in Table 9 and the toxicity analysis in Figure 13 and Table 10. Understand the nuances of Supervised Safety SFT, Safety RLHF, and Safety Context Distillation, including how they mitigate risks and their impact on false refusals (Figure 15, Figure 16, Table 13, Table 40, Table 41). Read Section 4.3 (Red Teaming) for qualitative insights into proactive risk identification. Analyze the detailed safety evaluation results across different risk categories (Figure 17, Figure 18, Figure 19, Table 14).
- Results (Sections 2.3, 3.4, 4.4): Conduct a detailed comparison of Llama 2's performance across all academic benchmarks (Table 3, Table 4, Table 19-25) and human evaluations (Figure 1, Figure 2, Figure 3, Figure 11, Figure 12). Pay attention to the specific metrics and the relative strengths and weaknesses compared to other models.
- Limitations and Ethical Considerations (Section 5.2): Critically evaluate the acknowledged limitations, such as the English-centric nature of the data, potential for non-factual generation, and the inherent risks of LLMs.
- Responsible Release Strategy (Section 5.3): Understand Meta's approach to open-sourcing, licensing, and providing resources for safe deployment.
Replication pointers if applicable: The paper provides significant detail for potential replication:
- Model Architecture and Training (Section 2.2, Appendix A.2.1): Details on transformer architecture, pre-normalization, activation functions, positional embeddings, context length, and GQA. Hyperparameters for AdamW optimizer, learning rate schedule, weight decay, and gradient clipping are provided.
- Fine-tuning Data (Section 3.1, 3.2.1, Appendix A.3): Mentions the use of publicly available instruction tuning data, and the collection of 27,540 SFT annotations and over 1 million human preference binary comparisons. Table 26 provides detailed statistics on human preference data batches.
- RLHF Algorithms (Section 3.2.3): Describes the use of Proximal Policy Optimization (PPO) and Rejection Sampling fine-tuning, including batch sizes, clip thresholds, and KL penalty (β) values for different model sizes.
- Safety Fine-tuning (Section 4.2): Outlines the three techniques (Supervised Safety SFT, Safety RLHF, Safety Context Distillation) and provides examples of safe preprompts in Table 39.
- Model Card (Appendix A.7, Table 52): Summarizes key details about model developers, variations, input/output, architecture, training dates, status, license, and intended/out-of-scope uses, which are crucial for understanding and potentially replicating aspects of the work.
- GitHub Repository: The paper explicitly mentions a GitHub repository for code examples related to safe generations and basic safety techniques (Section 5.3).