Skip to content

Commit ec8842f

Browse files
authored
Merge branch 'meta-llama:main' into main
2 parents 36eaf36 + 54d2859 commit ec8842f

File tree

76 files changed

+3774
-2249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3774
-2249
lines changed

LICENSE

Lines changed: 0 additions & 125 deletions
This file was deleted.

README.md

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11
# Llama Recipes: Examples to get started using the Llama models from Meta
2-
3-
The 'llama-recipes' repository is a companion to the [Llama 2 model](https://github.com/facebookresearch/llama). The goal of this repository is to provide a scalable library for fine-tuning Llama 2, along with some example scripts and notebooks to quickly get started with using the Llama 2 models in a variety of use-cases, including fine-tuning for domain adaptation and building LLM-based applications with Llama 2 and other tools in the LLM ecosystem. The examples here showcase how to run Llama 2 locally, in the cloud, and on-prem.
4-
2+
<!-- markdown-link-check-disable -->
3+
The 'llama-recipes' repository is a companion to the [Meta Llama 3](https://github.com/meta-llama/llama3) models. The goal of this repository is to provide a scalable library for fine-tuning Meta Llama models, along with some example scripts and notebooks to quickly get started with using the models in a variety of use-cases, including fine-tuning for domain adaptation and building LLM-based applications with Meta Llama and other tools in the LLM ecosystem. The examples here showcase how to run Meta Llama locally, in the cloud, and on-prem. [Meta Llama 2](https://github.com/meta-llama/llama) is also supported in this repository. We highly recommend everyone to utilize [Meta Llama 3](https://github.com/meta-llama/llama3) due to its enhanced capabilities.
4+
5+
<!-- markdown-link-check-enable -->
6+
> [!IMPORTANT]
7+
> Meta Llama 3 has a new prompt template and special tokens (based on the tiktoken tokenizer).
8+
> | Token | Description |
9+
> |---|---|
10+
> `<\|begin_of_text\|>` | This is equivalent to the BOS token. |
11+
> `<\|end_of_text\|>` | This is equivalent to the EOS token. For multiturn-conversations it's usually unused. Instead, every message is terminated with `<\|eot_id\|>` instead.|
12+
> `<\|eot_id\|>` | This token signifies the end of the message in a turn i.e. the end of a single message by a system, user or assistant role as shown below.|
13+
> `<\|start_header_id\|>{role}<\|end_header_id\|>` | These tokens enclose the role for a particular message. The possible roles can be: system, user, assistant. |
14+
>
15+
> A multiturn-conversation with Meta Llama 3 follows this prompt template:
16+
> ```
17+
> <|begin_of_text|><|start_header_id|>system<|end_header_id|>
18+
>
19+
> {{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
20+
>
21+
> {{ user_message_1 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
22+
>
23+
> {{ model_answer_1 }}<|eot_id|><|start_header_id|>user<|end_header_id|>
24+
>
25+
> {{ user_message_2 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
26+
> ```
27+
> Each message gets trailed by an `<|eot_id|>` token before a new header is started, signaling a role change.
28+
>
29+
> More details on the new tokenizer and prompt template can be found [here](https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3#special-tokens-used-with-meta-llama-3).
30+
>
531
> [!NOTE]
632
> The llama-recipes repository was recently refactored to promote a better developer experience of using the examples. Some files have been moved to new locations. The `src/` folder has NOT been modified, so the functionality of this repo and package is not impacted.
7-
>
33+
>
834
> Make sure you update your local clone by running `git pull origin main`
935
1036
## Table of Contents
1137
12-
- [Llama Recipes: Examples to get started using the Llama models from Meta](#llama-recipes-examples-to-get-started-using-the-llama-models-from-meta)
38+
- [Llama Recipes: Examples to get started using the Meta Llama models from Meta](#llama-recipes-examples-to-get-started-using-the-llama-models-from-meta)
1339
- [Table of Contents](#table-of-contents)
1440
- [Getting Started](#getting-started)
1541
- [Prerequisites](#prerequisites)
@@ -33,29 +59,29 @@ These instructions will get you a copy of the project up and running on your loc
3359
### Prerequisites
3460
3561
#### PyTorch Nightlies
36-
Some features (especially fine-tuning with FSDP + PEFT) currently require PyTorch nightlies to be installed. Please make sure to install the nightlies if you're using these features following [this guide](https://pytorch.org/get-started/locally/).
62+
If you want to use PyTorch nightlies instead of the stable release, go to [this guide](https://pytorch.org/get-started/locally/) to retrieve the right `--extra-index-url URL` parameter for the `pip install` commands on your platform.
3763
3864
### Installing
3965
Llama-recipes provides a pip distribution for easy install and usage in other projects. Alternatively, it can be installed from source.
4066
4167
#### Install with pip
4268
```
43-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-recipes
69+
pip install llama-recipes
4470
```
4571
4672
#### Install with optional dependencies
4773
Llama-recipes offers the installation of optional packages. There are three optional dependency groups.
4874
To run the unit tests we can install the required dependencies with:
4975
```
50-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-recipes[tests]
76+
pip install llama-recipes[tests]
5177
```
5278
For the vLLM example we need additional requirements that can be installed with:
5379
```
54-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-recipes[vllm]
80+
pip install llama-recipes[vllm]
5581
```
5682
To use the sensitive topics safety checker install with:
5783
```
58-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-recipes[auditnlg]
84+
pip install llama-recipes[auditnlg]
5985
```
6086
Optional dependencies can also be combines with [option1,option2].
6187
@@ -65,22 +91,22 @@ To install from source e.g. for development use these commands. We're using hatc
6591
git clone [email protected]:meta-llama/llama-recipes.git
6692
cd llama-recipes
6793
pip install -U pip setuptools
68-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 -e .
94+
pip install -e .
6995
```
7096
For development and contributing to llama-recipes please install all optional dependencies:
7197
```
7298
git clone [email protected]:meta-llama/llama-recipes.git
7399
cd llama-recipes
74100
pip install -U pip setuptools
75-
pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 -e .[tests,auditnlg,vllm]
101+
pip install -e .[tests,auditnlg,vllm]
76102
```
77103
78104
79-
### Getting the Llama models
80-
You can find Llama 2 models on Hugging Face hub [here](https://huggingface.co/meta-llama), **where models with `hf` in the name are already converted to Hugging Face checkpoints so no further conversion is needed**. The conversion step below is only for original model weights from Meta that are hosted on Hugging Face model hub as well.
105+
### Getting the Meta Llama models
106+
You can find Meta Llama models on Hugging Face hub [here](https://huggingface.co/meta-llama), **where models with `hf` in the name are already converted to Hugging Face checkpoints so no further conversion is needed**. The conversion step below is only for original model weights from Meta that are hosted on Hugging Face model hub as well.
81107
82108
#### Model conversion to Hugging Face
83-
The recipes and notebooks in this folder are using the Llama 2 model definition provided by Hugging Face's transformers library.
109+
The recipes and notebooks in this folder are using the Meta Llama model definition provided by Hugging Face's transformers library.
84110
85111
Given that the original checkpoint resides under models/7B you can install all requirements and convert the checkpoint with:
86112
@@ -98,22 +124,22 @@ python src/transformers/models/llama/convert_llama_weights_to_hf.py \
98124

99125

100126
## Repository Organization
101-
Most of the code dealing with Llama usage is organized across 2 main folders: `recipes/` and `src/`.
127+
Most of the code dealing with Llama usage is organized across 2 main folders: `recipes/` and `src/`.
102128

103129
### `recipes/`
104130

105131
Contains examples are organized in folders by topic:
106132
| Subfolder | Description |
107133
|---|---|
108-
[quickstart](./recipes/quickstart) | The "Hello World" of using Llama2, start here if you are new to using Llama2.
109-
[finetuning](./recipes/finetuning)|Scripts to finetune Llama2 on single-GPU and multi-GPU setups
110-
[inference](./recipes/inference)|Scripts to deploy Llama2 for inference locally and using model servers
111-
[use_cases](./recipes/use_cases)|Scripts showing common applications of Llama2
134+
[quickstart](./recipes/quickstart) | The "Hello World" of using Llama, start here if you are new to using Llama.
135+
[finetuning](./recipes/finetuning)|Scripts to finetune Llama on single-GPU and multi-GPU setups
136+
[inference](./recipes/inference)|Scripts to deploy Llama for inference locally and using model servers
137+
[use_cases](./recipes/use_cases)|Scripts showing common applications of Meta Llama3
112138
[responsible_ai](./recipes/responsible_ai)|Scripts to use PurpleLlama for safeguarding model outputs
113139
[llama_api_providers](./recipes/llama_api_providers)|Scripts to run inference on Llama via hosted endpoints
114-
[benchmarks](./recipes/benchmarks)|Scripts to benchmark Llama 2 models inference on various backends
140+
[benchmarks](./recipes/benchmarks)|Scripts to benchmark Llama models inference on various backends
115141
[code_llama](./recipes/code_llama)|Scripts to run inference with the Code Llama models
116-
[evaluation](./recipes/evaluation)|Scripts to evaluate fine-tuned Llama2 models using `lm-evaluation-harness` from `EleutherAI`
142+
[evaluation](./recipes/evaluation)|Scripts to evaluate fine-tuned Llama models using `lm-evaluation-harness` from `EleutherAI`
117143

118144
### `src/`
119145

@@ -133,5 +159,9 @@ Contains modules which support the example recipes:
133159
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
134160

135161
## License
136-
See the License file [here](LICENSE) and Acceptable Use Policy [here](USE_POLICY.md)
162+
<!-- markdown-link-check-disable -->
163+
164+
See the License file for Meta Llama 3 [here](https://llama.meta.com/llama3/license/) and Acceptable Use Policy [here](https://llama.meta.com/llama3/use-policy/)
137165

166+
See the License file for Meta Llama 2 [here](https://llama.meta.com/llama2/license/) and Acceptable Use Policy [here](https://llama.meta.com/llama2/use-policy/)
167+
<!-- markdown-link-check-enable -->

0 commit comments

Comments
 (0)