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
+53-23Lines changed: 53 additions & 23 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,29 +59,29 @@ 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.
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.
81
107
82
108
#### 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.
84
110
85
111
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/`.
127
+
Most of the code dealing with Llama usage is organized across 2 main folders: `recipes/` and `src/`.
102
128
103
129
### `recipes/`
104
130
105
131
Contains examples are organized in folders by topic:
106
132
| Subfolder | Description |
107
133
|---|---|
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
112
138
[responsible_ai](./recipes/responsible_ai)|Scripts to use PurpleLlama for safeguarding model outputs
113
139
[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
115
141
[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`
117
143
118
144
### `src/`
119
145
@@ -133,5 +159,9 @@ Contains modules which support the example recipes:
133
159
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
134
160
135
161
## 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/)
137
165
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/)
0 commit comments