Purpose
This repository is the official tools repository for the Meta Llama series of open-source large language models. It provides practical tools for use with Llama models, aimed at developers, researchers, and enterprises to build, experiment with, and responsibly scale their generative AI ideas. The repository also serves as one of the foundational systems of the Llama ecosystem, encouraging the global community to innovate around it.
Main Capabilities
- Open access: Provides convenient access to frontier large language models, promoting collaboration and progress among developers, researchers, and organizations.
- Broad ecosystem: Llama models have been downloaded hundreds of millions of times, the community has thousands of projects built on Llama, and platform support spans from cloud service providers to startups.
- Trust and safety: The models and tools are released as part of a comprehensive trust and safety approach, intended to promote community collaboration and advance the standardization of the development and use of generative AI trust and safety tools.
- Model weights license: The weights are licensed for researchers and commercial entities, following open principles.
How to Use
Download the model weights and tokenizer:
- Visit the Meta Llama website.
- Read and accept the license.
- After your request is approved, you will receive a signed URL via email.
- Install the Llama Models CLI: pip install llama-models. (If you have already received the email, you can start here.)
- Run llama-model list to display the latest available models and determine the model ID you want to download. Note: If you need an earlier version of a model, run llama-model list --show-all to display all available Llama models.
- Run: llama-model download --source meta --model-id CHOSEN_MODEL_ID
- When prompted, paste the provided URL to begin the download. Note: The link expires after 24 hours and a certain number of downloads; if you encounter an error such as 403: Forbidden, you can request a new link.
After installation, the llama-model CLI provides the corresponding commands; for detailed help on a command, run llama-model COMMAND --help.
Running Models
Before running a model, you need to install dependencies after checking out the repository. Example scripts are located in the models/{llama3, llama4}/scripts/ subdirectories. Note that LlamThe a4 series models require at least 4 GPUs to run inference at full (bf16) precision. The above script should be used with the Instruct (Chat) model. For the Base model, update the CHECKPOINT_DIR path and use the script models.llama4.scripts.completion.
Running inference with FP8 and Int4 quantization: Model memory usage can be reduced with minimal precision loss through FP8 or Int4 quantization. Use the --quantization-mode flag to specify the quantization mode; there are two modes: fp8_mixed: Mixed-precision inference where some weights use FP8 and activations use bfloat16. int4_mixed: Mixed-precision inference where some weights use Int4 and activations use bfloat16. Running Llama-4-Scout-17B-16E-Instruct with FP8 requires 2 GPUs with 80GB of VRAM; using Int4 requires a single GPU with 80GB of VRAM. For more flexible inference methods (including using other providers), please refer to the Llama Stack toolset.
Obtaining from Hugging Face
Hugging Face downloads are also provided for the repository, including both transformers and native llama4 formats. Steps:
- Visit any repository, for example meta-llama/Llama-4-Scout-17B-16E.
- Read and accept the license. After the request is approved, you will gain access to all Llama 3.1 models and previous versions. Note that request processing has previously taken up to about one hour.
- To download the original native weights for use with this repository, click the "Files and versions" tab and download the contents of the original folder. You can also download via the command line after pip install huggingface-hub.
- When used with transformers, the following code snippet will download and cache the weights:
inference.py
from transformers import AutoTokenizer, Llama4ForConditionalGeneration import torch model_id = "meta-llama/Llama-4-Scout-17B-16E-Instruct" tokenizer = AutoTokenizer.from_pretrained(model_id) messages = [{"role": "user", "content": "Who are you?"},] inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True) model = Llama4ForConditionalGeneration.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16) outputs = model.generate(**inputs.to(model.device), max_new_tokens=100) outputs = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[-1]:]) print(outputs[0]) torchrun --nnodes=1 --nproc_per_node=8 inference.py
You can also install this repository as a package via pip install llama-models.
Responsible Use
Llama models are a new technology, and there are potential risks in their use. Testing conducted to date has not covered, and cannot cover, all scenarios. To help developers address these risks, the Responsible Use Guide was created. Reporting software "bugs" or other model issues can be done through the following:
- Report model issues:https://github.com/meta-llama/llama-models/issues
- Report risky content generated by the model: developers.facebook.com/llama_output_feedback
- Report bugs and security issues: facebook.com/whitehat/info Common questions can be found in the FAQ, which will be updated over time as new questions arise.
Limitations and Notes
The model weight download link expires after 24 hours and after a certain number of downloads, requiring a new request; the Llama4 series requires at least 4 GPUs for full-precision inference; access via Hugging Face requires first accepting the license and waiting for approval, which has previously taken up to about one hour. The materials do not provide information such as fees or pricing.