RepoMeta AI (Llama)Meta AI (Llama)published Mar 15, 2024seen 6d

meta-llama/llama3

Python

Open original ↗

Captured source

source ↗
published Mar 15, 2024seen 6dcaptured 15hhttp 200method plain

meta-llama/llama3

Description: The official Meta Llama 3 GitHub site

Language: Python

License: NOASSERTION

Stars: 29281

Forks: 3524

Open issues: 217

Created: 2024-03-15T17:57:00Z

Pushed: 2025-01-26T21:39:06Z

Default branch: main

Fork: no

Archived: yes

README:

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

---

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:

  • llama-models - Central repo for the foundation models including basic utilities, model cards, license and use policies
  • PurpleLlama - Key component of Llama Stack focusing on safety risks and inference time mitigations
  • llama-toolchain - Model development (inference/fine-tuning/safety shields/synthetic data generation) interfaces and canonical implementations
  • llama-agentic-system - E2E standalone Llama Stack system, along with opinionated underlying interface, that enables creation of agentic applications
  • llama-cookbook - Community driven scripts and integrations

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:

  • Visit one of the repos, for example meta-llama/Meta-Llama-3-8B-Instruct.
  • Read and accept the license. Once your request is approved, you'll be granted access to all the Llama 3 models. Note that requests used to take up to one hour to get processed.
  • To download the original native weights to use with this repo, click on the "Files and versions" tab and download the contents of the original folder. You can also download them from the command line if you pip install huggingface-hub:
huggingface-cli download meta-llama/Meta-Llama-3-8B-Instruct --include "original/*" --local-dir meta-llama/Meta-Llama-3-8B-Instruct
  • To use with transformers, the following pipeline snippet will download and cache the weights:
import transformers
import torch

model_id = "meta-llama/Meta-Llama-3-8B-Instruct"

pipeline = transformers.pipeline(
"text-generation",
model="meta-llama/Meta-Llama-3-8B-Instruct",
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)

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

  • Replace Meta-Llama-3-8B-Instruct/ with the path to your checkpoint directory and Meta-Llama-3-8B-Instruct/tokenizer.model with the path to your tokenizer model.
  • The –nproc_per_node should be set to the [MP](#inference) value for the model you are using.
  • Adjust the max_seq_len and max_batch_size parameters as needed.
  • This example runs the [example_chat_completion.py](example_chat_completion.py) found in this repository, but you can change that to a different .py file.

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…

Excerpt shown — open the source for the full document.