Update README.md
#2
by
alvarobartt
HF staff
- opened
README.md
CHANGED
@@ -24,104 +24,29 @@ tags:
|
|
24 |
|
25 |
The Meta Llama 3.1 collection of multilingual large language models (LLMs) is a collection of pretrained and instruction tuned generative models in 8B, 70B and 405B sizes (text in/text out). The Llama 3.1 instruction tuned text only models (8B, 70B, 405B) are optimized for multilingual dialogue use cases and outperform many of the available open source and closed chat models on common industry benchmarks.
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
<table>
|
32 |
-
<tr>
|
33 |
-
<td>
|
34 |
-
</td>
|
35 |
-
<td><strong>Training Data</strong>
|
36 |
-
</td>
|
37 |
-
<td><strong>Params</strong>
|
38 |
-
</td>
|
39 |
-
<td><strong>Input modalities</strong>
|
40 |
-
</td>
|
41 |
-
<td><strong>Output modalities</strong>
|
42 |
-
</td>
|
43 |
-
<td><strong>Context length</strong>
|
44 |
-
</td>
|
45 |
-
<td><strong>GQA</strong>
|
46 |
-
</td>
|
47 |
-
<td><strong>Token count</strong>
|
48 |
-
</td>
|
49 |
-
<td><strong>Knowledge cutoff</strong>
|
50 |
-
</td>
|
51 |
-
</tr>
|
52 |
-
<tr>
|
53 |
-
<td rowspan="3" >Llama 3.1 (text only)
|
54 |
-
</td>
|
55 |
-
<td rowspan="3" >A new mix of publicly available online data.
|
56 |
-
</td>
|
57 |
-
<td>8B
|
58 |
-
</td>
|
59 |
-
<td>Multilingual Text
|
60 |
-
</td>
|
61 |
-
<td>Multilingual Text and code
|
62 |
-
</td>
|
63 |
-
<td>128k
|
64 |
-
</td>
|
65 |
-
<td>Yes
|
66 |
-
</td>
|
67 |
-
<td rowspan="3" >15T+
|
68 |
-
</td>
|
69 |
-
<td rowspan="3" >December 2023
|
70 |
-
</td>
|
71 |
-
</tr>
|
72 |
-
<tr>
|
73 |
-
<td>70B
|
74 |
-
</td>
|
75 |
-
<td>Multilingual Text
|
76 |
-
</td>
|
77 |
-
<td>Multilingual Text and code
|
78 |
-
</td>
|
79 |
-
<td>128k
|
80 |
-
</td>
|
81 |
-
<td>Yes
|
82 |
-
</td>
|
83 |
-
</tr>
|
84 |
-
<tr>
|
85 |
-
<td>405B
|
86 |
-
</td>
|
87 |
-
<td>Multilingual Text
|
88 |
-
</td>
|
89 |
-
<td>Multilingual Text and code
|
90 |
-
</td>
|
91 |
-
<td>128k
|
92 |
-
</td>
|
93 |
-
<td>Yes
|
94 |
-
</td>
|
95 |
-
</tr>
|
96 |
-
</table>
|
97 |
-
|
98 |
-
**Supported languages:** English, German, French, Italian, Portuguese, Hindi, Spanish, and Thai.
|
99 |
-
|
100 |
-
**Llama 3.1 family of models**. Token counts refer to pretraining data only. All model versions use Grouped-Query Attention (GQA) for improved inference scalability.
|
101 |
-
|
102 |
-
**Model Release Date:** July 23, 2024.
|
103 |
-
|
104 |
-
**Status:** This is a static model trained on an offline dataset. Future versions of the tuned models will be released as we improve model safety with community feedback.
|
105 |
-
|
106 |
-
**License:** A custom commercial license, the Llama 3.1 Community License, is available at: [https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE)
|
107 |
-
|
108 |
-
Where to send questions or comments about the model Instructions on how to provide feedback or comments on the model can be found in the model [README](https://github.com/meta-llama/llama3). For more technical information about generation parameters and recipes for how to use Llama 3.1 in applications, please go [here](https://github.com/meta-llama/llama-recipes).
|
109 |
-
|
110 |
-
For more information please refer to the original model card [`meta-llama/Meta-Llama-3.1-405B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct).
|
111 |
-
|
112 |
-
## Quantized Model Information
|
113 |
-
|
114 |
-
Llama 3.1 405B Instruct has been quantized using [AutoAWQ](https://github.com/casperhansen/AutoAWQ) from FP16 down to INT4 using the GEMM kernels performing zero-point quantization with a group size of 128.
|
115 |
-
|
116 |
-
## Quantized Model Usage
|
117 |
|
118 |
> [!NOTE]
|
119 |
> In order to run the inference with Llama 3.1 405B Instruct AWQ in INT4, around 203 GiB of VRAM are needed only for loading the model checkpoint, without including the KV cache or the CUDA graphs, meaning that there should be a bit over that VRAM available.
|
120 |
|
121 |
-
In order to use the current quantized model, support is offered for different solutions
|
122 |
|
123 |
### 🤗 transformers
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
To run the inference on top of Llama 3.1 405B Instruct AWQ in INT4 precision, the AWQ model can be instantiated as any other causal language modeling model via `AutoModelForCausalLM` and run the inference normally.
|
126 |
|
127 |
```python
|
@@ -135,13 +60,6 @@ prompt = [
|
|
135 |
]
|
136 |
|
137 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
138 |
-
tokenizer.pad_token_id = tokenizer.eos_token_id
|
139 |
-
tokenizer.padding_side = "left"
|
140 |
-
|
141 |
-
terminators = [
|
142 |
-
tokenizer.eos_token_id,
|
143 |
-
tokenizer.convert_tokens_to_ids("<|eot_id|>"),
|
144 |
-
]
|
145 |
|
146 |
inputs = tokenizer.apply_chat_template(prompt, tokenize=True, add_generation_prompt=True, return_tensors="pt").cuda()
|
147 |
|
@@ -152,12 +70,24 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
152 |
device_map="auto",
|
153 |
)
|
154 |
|
155 |
-
outputs = model.generate(
|
156 |
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
157 |
```
|
158 |
|
159 |
### AutoAWQ
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
Alternatively, one may want to run that via `AutoAWQ` even though it's built on top of 🤗 `transformers`, which is the recommended approach instead as described above.
|
162 |
|
163 |
```python
|
@@ -172,8 +102,6 @@ prompt = [
|
|
172 |
]
|
173 |
|
174 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
175 |
-
tokenizer.pad_token_id = tokenizer.eos_token_id
|
176 |
-
tokenizer.padding_side = "left"
|
177 |
|
178 |
inputs = tokenizer.apply_chat_template(prompt, tokenize=True, add_generation_prompt=True, return_tensors="pt").cuda()
|
179 |
|
@@ -185,7 +113,7 @@ model = AutoAWQForCausalLM.from_pretrained(
|
|
185 |
fuse_layers=True,
|
186 |
)
|
187 |
|
188 |
-
outputs = model.generate(
|
189 |
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
190 |
```
|
191 |
|
|
|
24 |
|
25 |
The Meta Llama 3.1 collection of multilingual large language models (LLMs) is a collection of pretrained and instruction tuned generative models in 8B, 70B and 405B sizes (text in/text out). The Llama 3.1 instruction tuned text only models (8B, 70B, 405B) are optimized for multilingual dialogue use cases and outperform many of the available open source and closed chat models on common industry benchmarks.
|
26 |
|
27 |
+
This repository contains [`meta-llama/Meta-Llama-3.1-405B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct) quantized using [AutoAWQ](https://github.com/casperhansen/AutoAWQ) from FP16 down to INT4 using the GEMM kernels performing zero-point quantization with a group size of 128.
|
28 |
+
|
29 |
+
## Model Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
> [!NOTE]
|
32 |
> In order to run the inference with Llama 3.1 405B Instruct AWQ in INT4, around 203 GiB of VRAM are needed only for loading the model checkpoint, without including the KV cache or the CUDA graphs, meaning that there should be a bit over that VRAM available.
|
33 |
|
34 |
+
In order to use the current quantized model, support is offered for different solutions as `transformers`, `autoawq`, or `text-generation-inference`.
|
35 |
|
36 |
### 🤗 transformers
|
37 |
|
38 |
+
In order to run the inference with Llama 3.1 405B Instruct AWQ in INT4, both `torch` and `autoawq` need to be installed as:
|
39 |
+
|
40 |
+
```bash
|
41 |
+
pip install "torch>=2.2.0,<2.3.0" autoawq --upgrade
|
42 |
+
```
|
43 |
+
|
44 |
+
Then, the latest version of `transformers` need to be installed, being 4.43.0 or higher, as:
|
45 |
+
|
46 |
+
```bash
|
47 |
+
pip install "transformers[accelerate]>=4.43.0" --upgrade
|
48 |
+
```
|
49 |
+
|
50 |
To run the inference on top of Llama 3.1 405B Instruct AWQ in INT4 precision, the AWQ model can be instantiated as any other causal language modeling model via `AutoModelForCausalLM` and run the inference normally.
|
51 |
|
52 |
```python
|
|
|
60 |
]
|
61 |
|
62 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
inputs = tokenizer.apply_chat_template(prompt, tokenize=True, add_generation_prompt=True, return_tensors="pt").cuda()
|
65 |
|
|
|
70 |
device_map="auto",
|
71 |
)
|
72 |
|
73 |
+
outputs = model.generate(inputs, do_sample=True, max_new_tokens=256)
|
74 |
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
75 |
```
|
76 |
|
77 |
### AutoAWQ
|
78 |
|
79 |
+
In order to run the inference with Llama 3.1 405B Instruct AWQ in INT4, both `torch` and `autoawq` need to be installed as:
|
80 |
+
|
81 |
+
```bash
|
82 |
+
pip install "torch>=2.2.0,<2.3.0" autoawq --upgrade
|
83 |
+
```
|
84 |
+
|
85 |
+
Then, the latest version of `transformers` need to be installed, being 4.43.0 or higher, as:
|
86 |
+
|
87 |
+
```bash
|
88 |
+
pip install "transformers[accelerate]>=4.43.0" --upgrade
|
89 |
+
```
|
90 |
+
|
91 |
Alternatively, one may want to run that via `AutoAWQ` even though it's built on top of 🤗 `transformers`, which is the recommended approach instead as described above.
|
92 |
|
93 |
```python
|
|
|
102 |
]
|
103 |
|
104 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
|
|
105 |
|
106 |
inputs = tokenizer.apply_chat_template(prompt, tokenize=True, add_generation_prompt=True, return_tensors="pt").cuda()
|
107 |
|
|
|
113 |
fuse_layers=True,
|
114 |
)
|
115 |
|
116 |
+
outputs = model.generate(inputs, do_sample=True, max_new_tokens=256)
|
117 |
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
118 |
```
|
119 |
|