You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-24Lines changed: 55 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,41 @@
1
1
# 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:
> 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
+
>
5
31
> [!NOTE]
6
32
> 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
+
>
8
34
> Make sure you update your local clone by running `git pull origin main`
9
35
10
36
## Table of Contents
11
37
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)
13
39
- [Table of Contents](#table-of-contents)
14
40
- [Getting Started](#getting-started)
15
41
- [Prerequisites](#prerequisites)
@@ -33,32 +59,33 @@ These instructions will get you a copy of the project up and running on your loc
33
59
### Prerequisites
34
60
35
61
#### 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.
37
63
38
64
### Installing
39
65
Llama-recipes provides a pip distribution for easy install and usage in other projects. Alternatively, it can be installed from source.
40
66
41
67
> [!NOTE]
42
-
> Ensure you use the correct CUDA version (from `nvidia-smi`) when installing the PyTorch wheels. Here we are using 11.8 as `cu118`
68
+
> Ensure you use the correct CUDA version (from `nvidia-smi`) when installing the PyTorch wheels. Here we are using 11.8 as `cu118`.
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.
109
+
### Getting the Meta Llama models
110
+
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.
84
111
85
112
#### Model conversion to Hugging Face
86
-
The recipes and notebooks in this folder are using the Llama 2 model definition provided by Hugging Face's transformers library.
113
+
The recipes and notebooks in this folder are using the Meta Llama model definition provided by Hugging Face's transformers library.
87
114
88
115
Given that the original checkpoint resides under models/7B you can install all requirements and convert the checkpoint with:
Most of the code dealing with Llama usage is organized across 2 main folders: `recipes/` and `src/`.
131
+
Most of the code dealing with Llama usage is organized across 2 main folders: `recipes/` and `src/`.
105
132
106
133
### `recipes/`
107
134
108
135
Contains examples are organized in folders by topic:
109
136
| Subfolder | Description |
110
137
|---|---|
111
-
[quickstart](./recipes/quickstart) | The "Hello World" of using Llama2, start here if you are new to using Llama2.
112
-
[finetuning](./recipes/finetuning)|Scripts to finetune Llama2 on single-GPU and multi-GPU setups
113
-
[inference](./recipes/inference)|Scripts to deploy Llama2 for inference locally and using model servers
114
-
[use_cases](./recipes/use_cases)|Scripts showing common applications of Llama2
138
+
[quickstart](./recipes/quickstart) | The "Hello World" of using Llama, start here if you are new to using Llama.
139
+
[finetuning](./recipes/finetuning)|Scripts to finetune Llama on single-GPU and multi-GPU setups
140
+
[inference](./recipes/inference)|Scripts to deploy Llama for inference locally and using model servers
141
+
[use_cases](./recipes/use_cases)|Scripts showing common applications of Meta Llama3
115
142
[responsible_ai](./recipes/responsible_ai)|Scripts to use PurpleLlama for safeguarding model outputs
116
143
[llama_api_providers](./recipes/llama_api_providers)|Scripts to run inference on Llama via hosted endpoints
117
-
[benchmarks](./recipes/benchmarks)|Scripts to benchmark Llama 2 models inference on various backends
144
+
[benchmarks](./recipes/benchmarks)|Scripts to benchmark Llama models inference on various backends
118
145
[code_llama](./recipes/code_llama)|Scripts to run inference with the Code Llama models
119
-
[evaluation](./recipes/evaluation)|Scripts to evaluate fine-tuned Llama2 models using `lm-evaluation-harness` from `EleutherAI`
146
+
[evaluation](./recipes/evaluation)|Scripts to evaluate fine-tuned Llama models using `lm-evaluation-harness` from `EleutherAI`
120
147
121
148
### `src/`
122
149
@@ -136,5 +163,9 @@ Contains modules which support the example recipes:
136
163
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
137
164
138
165
## License
139
-
See the License file [here](LICENSE) and Acceptable Use Policy [here](USE_POLICY.md)
166
+
<!-- markdown-link-check-disable -->
167
+
168
+
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/)
140
169
170
+
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/)
0 commit comments