llama3 README

The project's README from github.com/meta-llama/llama3. As one markdown file: README.md.

🤗 Models on Hugging Face  | Blog  | Website  | Get Started 


Note of deprecation

Thank you for developing with Llama models. As part of the Llama 3.1 release, we’ve consolidated GitHub repos and added some additional repos as we’ve expanded Llama’s functionality into being an e2e Llama Stack. Please use the following repos going forward:

If you have any questions, please feel free to file an issue on any of the above repos and we will do our best to respond in a timely manner.

Thank you!

(Deprecated) Meta Llama 3

We are unlocking the power of large language models. Our latest version of Llama is now accessible to individuals, creators, researchers, and businesses of all sizes so that they can experiment, innovate, and scale their ideas responsibly.

This release includes model weights and starting code for pre-trained and instruction-tuned Llama 3 language models — including sizes of 8B to 70B parameters.

This repository is a minimal example of loading Llama 3 models and running inference. For more detailed examples, see llama-cookbook.

Download

To download the model weights and tokenizer, please visit the Meta Llama website and accept our License.

Once your request is approved, you will receive a signed URL over email. Then, run the download.sh script, passing the URL provided when prompted to start the download.

Pre-requisites: Ensure you have wget and md5sum installed. Then run the script: ./download.sh.

Remember that the links expire after 24 hours and a certain amount of downloads. You can always re-request a link if you start seeing errors such as 403: Forbidden.

Access to Hugging Face

We also provide downloads on Hugging Face, in both transformers and native llama3 formats. To download the weights from Hugging Face, please follow these steps:

huggingface-cli download meta-llama/Meta-Llama-3-8B-Instruct --include "original/*" --local-dir meta-llama/Meta-Llama-3-8B-Instruct

Quick Start

You can follow the steps below to get up and running with Llama 3 models quickly. These steps will let you run quick inference locally. For more examples, see the Llama Cookbook repository.

  1. Clone and download this repository in a conda env with PyTorch / CUDA.

  2. In the top-level directory run:

    pip install -e .
    
  3. Visit the Meta Llama website and register to download the model/s.

  4. Once registered, you will get an email with a URL to download the models. You will need this URL when you run the download.sh script.

  5. Once you get the email, navigate to your downloaded llama repository and run the download.sh script.

    • Make sure to grant execution permissions to the download.sh script
    • During this process, you will be prompted to enter the URL from the email.
    • Do not use the “Copy Link” option; copy the link from the email manually.
  6. Once the model/s you want have been downloaded, you can run the model locally using the command below:

torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir Meta-Llama-3-8B-Instruct/ \
    --tokenizer_path Meta-Llama-3-8B-Instruct/tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

Note

Inference

Different models require different model-parallel (MP) values:

Model MP
8B 1
70B 8

All models support sequence length up to 8192 tokens, but we pre-allocate the cache according to max_seq_len and max_batch_size values. So set those according to your hardware.

Pretrained Models

These models are not finetuned for chat or Q&A. They should be prompted so that the expected answer is the natural continuation of the prompt.

See example_text_completion.py for some examples. To illustrate, see the command below to run it with the llama-3-8b model (nproc_per_node needs to be set to the MP value):

torchrun --nproc_per_node 1 example_text_completion.py \
    --ckpt_dir Meta-Llama-3-8B/ \
    --tokenizer_path Meta-Llama-3-8B/tokenizer.model \
    --max_seq_len 128 --max_batch_size 4

Instruction-tuned Models

The fine-tuned models were trained for dialogue applications. To get the expected features and performance for them, specific formatting defined in ChatFormat needs to be followed: The prompt begins with a <|begin_of_text|> special token, after which one or more messages follow. Each message starts with the <|start_header_id|> tag, the role system, user or assistant, and the <|end_header_id|> tag. After a double newline \n\n, the message's contents follow. The end of each message is marked by the <|eot_id|> token.

You can also deploy additional classifiers to filter out inputs and outputs that are deemed unsafe. See the llama-cookbook repo for an example of how to add a safety checker to the inputs and outputs of your inference code.

Examples using llama-3-8b-chat:

torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir Meta-Llama-3-8B-Instruct/ \
    --tokenizer_path Meta-Llama-3-8B-Instruct/tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

Llama 3 is a new technology that carries potential risks with use. Testing conducted to date has not — and could not — cover all scenarios. To help developers address these risks, we have created the Responsible Use Guide.

Issues

Please report any software “bug” or other problems with the models through one of the following means:

Model Card

See MODEL_CARD.md.

License

Our model and weights are licensed for researchers and commercial entities, upholding the principles of openness. Our mission is to empower individuals and industry through this opportunity while fostering an environment of discovery and ethical AI advancements.

See the LICENSE file, as well as our accompanying Acceptable Use Policy

Questions

For common questions, the FAQ can be found here, which will be updated over time as new questions arise.

llama3 (meta-llama/llama3)

Searching Database…

29.2K ·GitHub
archived
这是什么?Meta 官方的 Llama 3 GitHub 仓库:包含模型权重,以及在 8B 和 70B 两种规模上对预训练和指令微调模型运行推理所需的最简代码。该仓库现已弃用。
预训练版和指令微调版有什么区别?预训练的 checkpoint 没有针对对话做微调——它只会接着你的提示词往下续写(example_text_completion.py)。指令微调版是专门为对话训练的,必须使用特殊的 ChatFormat 提示结构(example_chat_completion.py)。
我该怎么拿到模型并在本地运行?把仓库克隆到一个装有 PyTorch 和 CUDA 的 conda 环境里,在 Meta Llama 官网上接受许可协议,然后运行 ./download.sh(需要 wget 和 md5sum),再把他们通过邮件发给你的签名 URL 粘贴进去。之后就可以用示例脚本对你的 checkpoint 运行推理。
运行这些模型需要什么硬件?需要一个装有 PyTorch 和 CUDA 的 conda 环境。8B 模型单张 GPU 就能跑(模型并行度为 1),70B 模型需要 8 张 GPU(MP=8),上下文长度最高支持 8192 个 token。
现在用 Llama 还是这个仓库吗?不是了——它已经归档。随着 Llama 3.1 发布,Meta 把所有内容整合进了一整套端到端的 Llama Stack:llama-models、PurpleLlama、llama-toolchain、llama-agentic-system 和 llama-cookbook。
我可以把 Llama 3 用于商业用途吗?可以——该许可覆盖研究人员和商业实体,但它是 Meta 自己的社区许可,而不是标准的开源许可,并且附带一份可接受使用政策。
我可以改从 Hugging Face 下载权重吗?可以。Meta 在 Hugging Face 上发布了全部 Llama 3 模型,同时提供原生格式和 transformers 格式。你仍然需要接受许可协议并等待批准——以前申请可能要等上最多一个小时。
下载链接失效了,怎么办?签名 URL 会在 24 小时后以及下载次数达到一定数量后过期。如果你开始看到类似 403: Forbidden 的报错,重新申请一个链接就行。
它包含什么安全工具吗?这个仓库里没有。Meta 提供了它的《负责任使用指南》,并在 llama-cookbook 中演示了如何添加分类器来过滤不安全的输入和输出;安全相关的组件(PurpleLlama)放在新的仓库里。
我必须用 Meta 自带的推理代码吗?不用。如果你用 Hugging Face 的 transformers 版本,标准的 transformers pipeline 会自动帮你下载并缓存权重。这个仓库里的 Python 代码只是围绕原生 checkpoint 写的一个最简示例。
Creator
meta-llama
Size
0.6 MB
Stars
29.2K
Updated
CommitJan 26
Age
2y
Commits · 90 Days