Papers › Llama 2: Open Foundation and Fine-Tuned Chat Models

Llama 2: Open Foundation and Fine-Tuned Chat Models

18 Jul 2023arXiv:2307.09288archive 2025-07-28

Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, Thomas Scialom

In this work, we develop and release Llama 2, a collection of pretrained and fine-tuned large language models (LLMs) ranging in scale from 7 billion to 70 billion parameters. Our fine-tuned LLMs, called Llama 2-Chat, are optimized for dialogue use cases. Our models outperform open-source chat models on most benchmarks we tested, and based on our human evaluations for helpfulness and safety, may be a suitable substitute for closed-source models. We provide a detailed description of our approach to fine-tuning and safety improvements of Llama 2-Chat in order to enable the community to build on our work and contribute to the responsible development of LLMs.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2307.09288")

Code

Syntology Ran 31 of 52 code samples harvested from 8 repositories linked to this paper; 21 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 7 ran · our draft was wrong; 4 ran · fixture could not drive it; 18 ran with no contract checked.

By repository: community (archive-listed): 52 samples from 8 repositories, 31 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

19 repositories listed; official and paper-mentioned ones first.

facebookresearch/llama officialmentioned in paperpytorchNOASSERTION report
IBM/Dromedary mentioned on GitHubpytorchGPL-3.0 report
Lightning-AI/lit-gpt mentioned on GitHubpytorch report
coastalcph/eu-politics-llms mentioned on GitHubpytorch report
eternityyw/tram-benchmark mentioned on GitHubMIT report
flagalpha/llama2-chinese mentioned on GitHubpytorch report
glb400/Toy-RecLM mentioned on GitHubpytorch report
idiap/abroad-re mentioned on GitHubpytorchGPL-3.0 report
llamafamily/llama-chinese mentioned on GitHubpytorch report
meetyou-ai-lab/can-mc-evaluate-llms mentioned on GitHubpytorch report
ninglab/ecellm mentioned on GitHubpytorchCC-BY-4.0 report
rijgersberg/geitje mentioned on GitHubpytorchApache-2.0 report
squeezeailab/squeezellm mentioned on GitHubpytorchMIT report
usyd-fsalab/fp6_llm mentioned on GitHubpytorchApache-2.0 report
xuetianci/pacit mentioned on GitHubpytorch report
xverse-ai/xverse-13b mentioned on GitHubpytorch report
xzhang97666/alpacare mentioned on GitHubApache-2.0 report
young-geng/easylm mentioned on GitHubjax report
zurichnlp/contradecode mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

52 samples harvested; 31 ran; 1 honoured the contract we drafted; 21 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · violated contract
7ran · our draft was wrong
4ran · fixture could not drive it
18ran
21unverified

Licence: 16 of the 52 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 8 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

repeat_kv IBM/Dromedary/training/llama_with_flash_attn.py community (archive-listed) ran · fixture could not drive it fingerprinted GPL-3.0 (copyleft) · pointer only · 30d7eec482ebf6b1 · report
round_to_nearest_pole_sim squeezeailab/squeezellm/squeezellm/quant.py community (archive-listed) ran · our draft was wrong MIT (permissive) · cdc0ad3109c8984b · report
Config Lightning-AI/lit-gpt/litgpt/model.py community (archive-listed) ran Apache-2.0 (permissive) · bf78fefededc09f7 · report
FeedForward glb400/Toy-RecLM/model.py community (archive-listed) ran · metamorphic tier: invariant MIT (permissive) · 9715deb8f27d4266 · report
LlamaConfig meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) ran Apache-2.0 (permissive) · 1bcd8d227ad19b17 · report
LlamaMLP meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) ran Apache-2.0 (permissive) · 50260ad39d7c5e06 · report
LlamaRMSNorm meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) ran Apache-2.0 (permissive) · 98b6bb174c074dae · report
LlamaRotaryEmbedding meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) ran Apache-2.0 (permissive) · 26ec53f064adbca5 · report
PromptTemplate zurichnlp/contradecode/translation_models/llama.py community (archive-listed) ran MIT (permissive) · 4d273bfb0feb28e0 · report
RMSNorm Lightning-AI/lit-gpt/litgpt/model.py community (archive-listed) ran fingerprinted Apache-2.0 (permissive) · 1e7100681c300ca2 · report
apply_rotary_emb IBM/Dromedary/llama_dromedary/llama_dromedary/model.py community (archive-listed) ran · fixture could not drive it GPL-3.0 (copyleft) · pointer only · b47d48e431b34acd · report
apply_rotary_pos_emb IBM/Dromedary/training/llama_with_flash_attn.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · e34097675d132bc1 · report
check_indicator_and_length Lightning-AI/lit-gpt/litgpt/model.py community (archive-listed) ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · faa77017b4beec30 · report
extract_alpaca_dataset IBM/Dromedary/training/data_utils_sft.py community (archive-listed) ran · our draft was wrong GPL-3.0 (copyleft) · pointer only · b5445674ab17410f · report
extract_dromedary_dataset IBM/Dromedary/training/data_utils_sft.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · 48456f10725088b5 · report
extract_unnatural_instructions_data IBM/Dromedary/training/data_utils_sft.py community (archive-listed) ran · our draft was wrong GPL-3.0 (copyleft) · pointer only · f82430123a91cf21 · report
find_layers squeezeailab/squeezellm/squeezellm/modelutils.py community (archive-listed) ran · our draft was wrong MIT (permissive) · a9e7f2cdf016b88b · report
find_multiple Lightning-AI/lit-gpt/litgpt/model.py community (archive-listed) ran · honoured contract fingerprinted Apache-2.0 (permissive) · ffe8d3a5e6f4b477 · report
generate_prompt IBM/Dromedary/inference/run_stream_chatbot_demo.py community (archive-listed) ran · our draft was wrong fingerprinted GPL-3.0 (copyleft) · pointer only · 55e55d5b9201bf5c · report
generate_prompt IBM/Dromedary/mc_evaluation/evaluate_hhh_eval.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · c478c1e77422f0de · report
get_log_prob IBM/Dromedary/mc_evaluation/evaluate_hhh_eval.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · 0c0f540ee97855aa · report
get_log_prob IBM/Dromedary/mc_evaluation/evaluate_truthfulqa_mc.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · 47407f4c74f590df · report
measure_multiple_choice_grade IBM/Dromedary/mc_evaluation/evaluate_hhh_eval.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · b14dfe7367095841 · report
measure_multiple_choice_grade IBM/Dromedary/mc_evaluation/evaluate_truthfulqa_mc.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · dfcc630d6e498f6f · report
precompute_freqs_cis IBM/Dromedary/llama_dromedary/llama_dromedary/model.py community (archive-listed) ran · violated contract GPL-3.0 (copyleft) · pointer only · 14a84c2cbfebc413 · report
remove_outliers squeezeailab/squeezellm/squeezellm/outliers.py community (archive-listed) ran MIT (permissive) · 303e2b878d149f4a · report
remove_outliers_by_sensitivity squeezeailab/squeezellm/squeezellm/outliers.py community (archive-listed) ran MIT (permissive) · e3a24217edf7812c · report
remove_outliers_by_threshold squeezeailab/squeezellm/squeezellm/outliers.py community (archive-listed) ran MIT (permissive) · 3d2bc2ac00f3f434 · report
reshape_for_broadcast IBM/Dromedary/llama_dromedary/llama_dromedary/model.py community (archive-listed) ran · fixture could not drive it fingerprinted GPL-3.0 (copyleft) · pointer only · 70bf6ebaafd266c4 · report
rotate_half IBM/Dromedary/training/llama_with_flash_attn.py community (archive-listed) ran · our draft was wrong fingerprinted GPL-3.0 (copyleft) · pointer only · b99eea6376d1e212 · report
sample_top_p IBM/Dromedary/llama_dromedary/llama_dromedary/generation.py community (archive-listed) ran · our draft was wrong fingerprinted GPL-3.0 (copyleft) · pointer only · 8845976729f4c4ee · report
Attention glb400/Toy-RecLM/model.py community (archive-listed) unverified MIT (permissive) · 4334c46d3961b3fb · report
FlaxLLaMAModel young-geng/easylm/EasyLM/models/llama/llama_model.py community (archive-listed) unverified Apache-2.0 (permissive) · cf00f2eef08595e6 · report
FlaxLLaMAPreTrainedModel young-geng/easylm/EasyLM/models/llama/llama_model.py community (archive-listed) unverified Apache-2.0 (permissive) · 72032d6f73d90892 · report
LLaMA2_SASRec glb400/Toy-RecLM/model.py community (archive-listed) unverified MIT (permissive) · 4427e517543e4577 · report
LLaMAMLP Lightning-AI/lit-gpt/litgpt/model.py community (archive-listed) unverified Apache-2.0 (permissive) · b336e5e4f4b40ceb · report
LlamaAttention meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) unverified Apache-2.0 (permissive) · 1104581ac75ea9c6 · report
LlamaDecoderLayer meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) unverified Apache-2.0 (permissive) · 660d5e5234e28212 · report
LlamaModel meetyou-ai-lab/can-mc-evaluate-llms/Embeddings/src/llama/modeling_llama.py community (archive-listed) unverified Apache-2.0 (permissive) · 865ca1b3e9c1aa5c · report
ModelArgs glb400/Toy-RecLM/model.py community (archive-listed) unverified MIT (permissive) · 75e3a8170f256bb7 · report
TransformerBlock glb400/Toy-RecLM/model.py community (archive-listed) unverified MIT (permissive) · 61aae005c3076a9b · report
get_c4 squeezeailab/squeezellm/squeezellm/datautils.py community (archive-listed) unverified MIT (permissive) · 92dc709e4e73e133 · report
get_model squeezeailab/squeezellm/llama.py community (archive-listed) unverified MIT (permissive) · fd802dc39c73084a · report
get_module_names squeezeailab/squeezellm/squeezellm/model_parse.py community (archive-listed) unverified MIT (permissive) · b65e0b634a94c717 · report
get_ptb squeezeailab/squeezellm/squeezellm/datautils.py community (archive-listed) unverified MIT (permissive) · b1e98f962f5ae82d · report
get_wikitext2 squeezeailab/squeezellm/squeezellm/datautils.py community (archive-listed) unverified MIT (permissive) · efc347eff314b865 · report
init_model xverse-ai/xverse-13b/chat_demo.py community (archive-listed) unverified Apache-2.0 (permissive) · b796bb9465578920 · report
kmeans_fit squeezeailab/squeezellm/quantization/nuq.py community (archive-listed) unverified MIT (permissive) · 77fbadc3b9632874 · report
load_model squeezeailab/squeezellm/squeezellm/model_parse.py community (archive-listed) unverified MIT (permissive) · b66c43d90a1a3a1b · report
load_quant squeezeailab/squeezellm/llama.py community (archive-listed) unverified MIT (permissive) · c0d4637f25eabf00 · report
parse_model squeezeailab/squeezellm/squeezellm/model_parse.py community (archive-listed) unverified MIT (permissive) · dd982ece7960b018 · report
tiktoken_tokenizer squeezeailab/squeezellm/models/xgen-7b-8k-base/tokenization_xgen.py community (archive-listed) unverified MIT (permissive) · 5445de6acd6035bb · report

Tasks

Arithmetic ReasoningCode GenerationMath Word Problem SolvingMulti-task Language UnderstandingMultiple Choice Question Answering (MCQA)Question AnsweringSentence Completion

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Arithmetic Reasoning GSM8K LLaMA 2 70B (on-shot) Accuracy 56.8 #123 of 164 Archive leaderboard report
Arithmetic Reasoning GSM8K LLaMA 2 70B (on-shot) Parameters (Billion) 70 #123 of 164 Archive leaderboard report
Code Generation MBPP Llama 2 70B (zero-shot) Accuracy 45 #76 of 99 Archive leaderboard report
Code Generation MBPP Llama 2 34B (0-shot) Accuracy 33 #89 of 99 Archive leaderboard report
Code Generation MBPP Llama 2 13B (0-shot) Accuracy 30.6 #90 of 99 Archive leaderboard report
Code Generation MBPP Llama 2 7B (0-shot) Accuracy 20.8 #97 of 99 Archive leaderboard report
Math Word Problem Solving MAWPS LLaMA 2-Chat Accuracy (%) 82.4 #16 of 25 Archive leaderboard report
Math Word Problem Solving SVAMP LLaMA 2-Chat Execution Accuracy 69.2 #12 of 26 Archive leaderboard report
Multi-task Language Understanding MML LLaMA 2 34B (5-shot) Average (%) 62.6 #16 of 44 Archive leaderboard report
Multi-task Language Understanding MML LLaMA 2 13B (5-shot) Average (%) 54.8 #23 of 44 Archive leaderboard report
Multi-task Language Understanding MML LLaMA 2 7B (5-shot) Average (%) 45.3 #28 of 44 Archive leaderboard report
Multiple Choice Question Answering (MCQA) MMLU (Professional medicine) Llama2-7B Accuracy 43.38 #5 of 6 Archive leaderboard report
Multiple Choice Question Answering (MCQA) MMLU (Professional medicine) Llama2-7B-chat Accuracy 40.07 #6 of 6 Archive leaderboard report
Question Answering BoolQ LLaMA 2 70B (0-shot) Accuracy 85 #18 of 65 Archive leaderboard report
Question Answering BoolQ LLaMA 2 34B (0-shot) Accuracy 83.7 #22 of 65 Archive leaderboard report
Question Answering BoolQ LLaMA 2 13B (0-shot) Accuracy 81.7 #25 of 65 Archive leaderboard report
Question Answering BoolQ LLaMA 2 7B (zero-shot) Accuracy 77.4 #30 of 65 Archive leaderboard report
Question Answering MultiTQ LLaMA2 Hits@1 18.5 #7 of 11 Archive leaderboard report
Question Answering Natural Questions LLaMA 2 70B (one-shot) EM 33.0 #31 of 47 Archive leaderboard report
Question Answering PIQA LLaMA 2 70B (0-shot) Accuracy 82.8 #18 of 67 Archive leaderboard report
Question Answering PIQA LLaMA 2 34B (0-shot) Accuracy 81.9 #24 of 67 Archive leaderboard report
Question Answering PIQA LLaMA 2 13B (0-shot) Accuracy 80.5 #32 of 67 Archive leaderboard report
Question Answering PIQA LLaMA 2 7B (0-shot) Accuracy 78.8 #38 of 67 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat BLEU-2 0.075 #2 of 2 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat BLEU-4 0.009 #2 of 2 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat MEATOR 0.149 #2 of 2 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat ROUGE-1 0.184 #2 of 2 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat ROUGE-2 0.043 #2 of 2 Archive leaderboard report
Question Answering PubChemQA Llama2-7B-chat ROUGE-L 0.142 #2 of 2 Archive leaderboard report
Question Answering TriviaQA LLaMA 2 70B (one-shot) EM 85 #7 of 56 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat BLEU-2 0.019 #2 of 2 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat BLEU-4 0.002 #2 of 2 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat MEATOR 0.052 #2 of 2 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat ROUGE-1 0.103 #2 of 2 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat ROUGE-2 0.060 #2 of 2 Archive leaderboard report
Question Answering UniProtQA Llama2-7B-chat ROUGE-L 0.009 #2 of 2 Archive leaderboard report
Sentence Completion HellaSwag LLaMA 2 70B (0-shot) Accuracy 85.3 #26 of 89 Archive leaderboard report
Sentence Completion HellaSwag LLaMA 2 34B (0-shot) Accuracy 83.3 #33 of 89 Archive leaderboard report
Sentence Completion HellaSwag LLaMA 2 13B (0-shot) Accuracy 80.7 #43 of 89 Archive leaderboard report
Sentence Completion HellaSwag LLaMA 2 7B (0-shot) Accuracy 77.2 #49 of 89 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Absolute Position EncodingsAdamWAttentionBPEDense ConnectionsDropoutEntropy RegularizationFeedforward NetworkGrouped-query attentionLabel SmoothingPPORMSNormResidual ConnectionRotary EmbeddingsSoftmaxSwiGLUTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections