Create README.md
#1
by
alvarobartt
HF staff
- opened
- LICENSE +114 -0
- README.md +246 -0
- USE_POLICY.md +51 -0
LICENSE
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
LLAMA 3.1 COMMUNITY LICENSE AGREEMENT
|
2 |
+
Llama 3.1 Version Release Date: July 23, 2024
|
3 |
+
|
4 |
+
“Agreement” means the terms and conditions for use, reproduction, distribution and modification of the
|
5 |
+
Llama Materials set forth herein.
|
6 |
+
|
7 |
+
“Documentation” means the specifications, manuals and documentation accompanying Llama 3.1
|
8 |
+
distributed by Meta at https://llama.meta.com/doc/overview.
|
9 |
+
|
10 |
+
“Licensee” or “you” means you, or your employer or any other person or entity (if you are entering into
|
11 |
+
this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or
|
12 |
+
regulations to provide legal consent and that has legal authority to bind your employer or such other
|
13 |
+
person or entity if you are entering in this Agreement on their behalf.
|
14 |
+
|
15 |
+
“Llama 3.1” means the foundational large language models and software and algorithms, including
|
16 |
+
machine-learning model code, trained model weights, inference-enabling code, training-enabling code,
|
17 |
+
fine-tuning enabling code and other elements of the foregoing distributed by Meta at
|
18 |
+
https://llama.meta.com/llama-downloads.
|
19 |
+
|
20 |
+
“Llama Materials” means, collectively, Meta’s proprietary Llama 3.1 and Documentation (and any
|
21 |
+
portion thereof) made available under this Agreement.
|
22 |
+
|
23 |
+
“Meta” or “we” means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your
|
24 |
+
principal place of business is in the EEA or Switzerland) and Meta Platforms, Inc. (if you are located
|
25 |
+
outside of the EEA or Switzerland).
|
26 |
+
|
27 |
+
By clicking “I Accept” below or by using or distributing any portion or element of the Llama Materials,
|
28 |
+
you agree to be bound by this Agreement.
|
29 |
+
|
30 |
+
1. License Rights and Redistribution.
|
31 |
+
|
32 |
+
a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable and royalty-free
|
33 |
+
limited license under Meta’s intellectual property or other rights owned by Meta embodied in the Llama
|
34 |
+
Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the
|
35 |
+
Llama Materials.
|
36 |
+
|
37 |
+
b. Redistribution and Use.
|
38 |
+
|
39 |
+
i. If you distribute or make available the Llama Materials (or any derivative works
|
40 |
+
thereof), or a product or service (including another AI model) that contains any of them, you shall (A)
|
41 |
+
provide a copy of this Agreement with any such Llama Materials; and (B) prominently display “Built with
|
42 |
+
Llama” on a related website, user interface, blogpost, about page, or product documentation. If you use
|
43 |
+
the Llama Materials or any outputs or results of the Llama Materials to create, train, fine tune, or
|
44 |
+
otherwise improve an AI model, which is distributed or made available, you shall also include “Llama” at
|
45 |
+
the beginning of any such AI model name.
|
46 |
+
|
47 |
+
ii. If you receive Llama Materials, or any derivative works thereof, from a Licensee as part
|
48 |
+
of an integrated end user product, then Section 2 of this Agreement will not apply to you.
|
49 |
+
|
50 |
+
iii. You must retain in all copies of the Llama Materials that you distribute the following
|
51 |
+
attribution notice within a “Notice” text file distributed as a part of such copies: “Llama 3.1 is
|
52 |
+
licensed under the Llama 3.1 Community License, Copyright © Meta Platforms, Inc. All Rights
|
53 |
+
Reserved.”
|
54 |
+
|
55 |
+
iv. Your use of the Llama Materials must comply with applicable laws and regulations
|
56 |
+
(including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for the Llama
|
57 |
+
Materials (available at https://llama.meta.com/llama3_1/use-policy), which is hereby incorporated by
|
58 |
+
reference into this Agreement.
|
59 |
+
|
60 |
+
2. Additional Commercial Terms. If, on the Llama 3.1 version release date, the monthly active users
|
61 |
+
of the products or services made available by or for Licensee, or Licensee’s affiliates, is greater than 700
|
62 |
+
million monthly active users in the preceding calendar month, you must request a license from Meta,
|
63 |
+
which Meta may grant to you in its sole discretion, and you are not authorized to exercise any of the
|
64 |
+
rights under this Agreement unless or until Meta otherwise expressly grants you such rights.
|
65 |
+
|
66 |
+
3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY
|
67 |
+
OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF
|
68 |
+
ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED,
|
69 |
+
INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT,
|
70 |
+
MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR
|
71 |
+
DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND
|
72 |
+
ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND
|
73 |
+
RESULTS.
|
74 |
+
|
75 |
+
4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF
|
76 |
+
LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING
|
77 |
+
OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL,
|
78 |
+
INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED
|
79 |
+
OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
80 |
+
|
81 |
+
5. Intellectual Property.
|
82 |
+
|
83 |
+
a. No trademark licenses are granted under this Agreement, and in connection with the Llama
|
84 |
+
Materials, neither Meta nor Licensee may use any name or mark owned by or associated with the other
|
85 |
+
or any of its affiliates, except as required for reasonable and customary use in describing and
|
86 |
+
redistributing the Llama Materials or as set forth in this Section 5(a). Meta hereby grants you a license to
|
87 |
+
use “Llama” (the “Mark”) solely as required to comply with the last sentence of Section 1.b.i. You will
|
88 |
+
comply with Meta’s brand guidelines (currently accessible at
|
89 |
+
https://about.meta.com/brand/resources/meta/company-brand/ ). All goodwill arising out of your use
|
90 |
+
of the Mark will inure to the benefit of Meta.
|
91 |
+
|
92 |
+
b. Subject to Meta’s ownership of Llama Materials and derivatives made by or for Meta, with
|
93 |
+
respect to any derivative works and modifications of the Llama Materials that are made by you, as
|
94 |
+
between you and Meta, you are and will be the owner of such derivative works and modifications.
|
95 |
+
|
96 |
+
c. If you institute litigation or other proceedings against Meta or any entity (including a
|
97 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Llama Materials or Llama 3.1 outputs or
|
98 |
+
results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other
|
99 |
+
rights owned or licensable by you, then any licenses granted to you under this Agreement shall
|
100 |
+
terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold
|
101 |
+
harmless Meta from and against any claim by any third party arising out of or related to your use or
|
102 |
+
distribution of the Llama Materials.
|
103 |
+
|
104 |
+
6. Term and Termination. The term of this Agreement will commence upon your acceptance of this
|
105 |
+
Agreement or access to the Llama Materials and will continue in full force and effect until terminated in
|
106 |
+
accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in
|
107 |
+
breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete
|
108 |
+
and cease use of the Llama Materials. Sections 3, 4 and 7 shall survive the termination of this
|
109 |
+
Agreement.
|
110 |
+
|
111 |
+
7. Governing Law and Jurisdiction. This Agreement will be governed and construed under the laws of
|
112 |
+
the State of California without regard to choice of law principles, and the UN Convention on Contracts
|
113 |
+
for the International Sale of Goods does not apply to this Agreement. The courts of California shall have
|
114 |
+
exclusive jurisdiction of any dispute arising out of this Agreement.
|
README.md
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
- de
|
6 |
+
- fr
|
7 |
+
- it
|
8 |
+
- pt
|
9 |
+
- hi
|
10 |
+
- es
|
11 |
+
- th
|
12 |
+
library_name: transformers
|
13 |
+
pipeline_tag: text-generation
|
14 |
+
tags:
|
15 |
+
- llama-3.1
|
16 |
+
- meta
|
17 |
+
- autoawq
|
18 |
+
---
|
19 |
+
|
20 |
+
> [!IMPORTANT]
|
21 |
+
> This repository is a community-driven quantized version of the original model [`meta-llama/Meta-Llama-3.1-405B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct) which is the FP16 half-precision official version released by Meta AI.
|
22 |
+
|
23 |
+
## Model Information
|
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 |
+
**Model developer**: Meta
|
28 |
+
|
29 |
+
**Model Architecture:** Llama 3.1 is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to align with human preferences for helpfulness and safety.
|
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
|
128 |
+
import torch
|
129 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
130 |
+
|
131 |
+
model_id = "hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4"
|
132 |
+
prompt = [
|
133 |
+
{"role": "system", "content": "You are a helpful assistant, that responds as a pirate."},
|
134 |
+
{"role": "user", "content": "What's Deep Learning?"},
|
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 |
+
|
148 |
+
model = AutoModelForCausalLM.from_pretrained(
|
149 |
+
model_id,
|
150 |
+
torch_dtype=torch.float16,
|
151 |
+
low_cpu_mem_usage=True,
|
152 |
+
device_map="auto",
|
153 |
+
)
|
154 |
+
|
155 |
+
outputs = model.generate(**inputs, do_sample=True, max_new_tokens=256, eos_token_id=terminators)
|
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
|
164 |
+
import torch
|
165 |
+
from autoawq import AutoAWQForCausalLM
|
166 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
167 |
+
|
168 |
+
model_id = "hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4"
|
169 |
+
prompt = [
|
170 |
+
{"role": "system", "content": "You are a helpful assistant, that responds as a pirate."},
|
171 |
+
{"role": "user", "content": "What's Deep Learning?"},
|
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 |
+
|
180 |
+
model = AutoAWQForCausalLM.from_pretrained(
|
181 |
+
model_id,
|
182 |
+
torch_dtype=torch.float16,
|
183 |
+
low_cpu_mem_usage=True,
|
184 |
+
device_map="auto",
|
185 |
+
fuse_layers=True,
|
186 |
+
)
|
187 |
+
|
188 |
+
outputs = model.generate(**inputs, do_sample=True, max_new_tokens=256)
|
189 |
+
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
190 |
+
```
|
191 |
+
|
192 |
+
The AutoAWQ script has been adapted from [AutoAWQ/examples/generate.py](https://github.com/casper-hansen/AutoAWQ/blob/main/examples/generate.py).
|
193 |
+
|
194 |
+
### 🤗 Text Generation Inference (TGI)
|
195 |
+
|
196 |
+
Coming soon!
|
197 |
+
|
198 |
+
## Quantization Reproduction
|
199 |
+
|
200 |
+
> [!NOTE]
|
201 |
+
> In order to quantize Llama 3.1 405B Instruct using AutoAWQ, you will need to use an instance with at least enough CPU RAM to fit the whole model i.e. ~800GiB, and an NVIDIA GPU with 80GiB of VRAM to quantize it.
|
202 |
+
|
203 |
+
In order to quantize Llama 3.1 405B Instruct, first install `torch` and `autoawq` as follows:
|
204 |
+
|
205 |
+
```bash
|
206 |
+
pip install "torch>=2.2.0,<2.3.0" autoawq --upgrade
|
207 |
+
```
|
208 |
+
|
209 |
+
Otherwise the quantization may fail, since the AutoAWQ kernels are built with PyTorch 2.2.1, meaning that those will break with PyTorch 2.3.0.
|
210 |
+
|
211 |
+
Then install the latest version of `transformers` as follows:
|
212 |
+
|
213 |
+
```bash
|
214 |
+
pip install "transformers>=4.43.0" --upgrade
|
215 |
+
```
|
216 |
+
|
217 |
+
And then, run the following script, adapted from [`AutoAWQ/examples/quantize.py`](https://github.com/casper-hansen/AutoAWQ/blob/main/examples/quantize.py) as follows:
|
218 |
+
|
219 |
+
```python
|
220 |
+
from awq import AutoAWQForCausalLM
|
221 |
+
from transformers import AutoTokenizer
|
222 |
+
|
223 |
+
model_path = "meta-llama/Meta-Llama-3.1-405B-Instruct"
|
224 |
+
quant_path = "hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4"
|
225 |
+
quant_config = {
|
226 |
+
"zero_point": True,
|
227 |
+
"q_group_size": 128,
|
228 |
+
"w_bit": 4,
|
229 |
+
"version": "GEMM",
|
230 |
+
}
|
231 |
+
|
232 |
+
# Load model
|
233 |
+
model = AutoAWQForCausalLM.from_pretrained(
|
234 |
+
model_path, **{"low_cpu_mem_usage": True, "use_cache": False}
|
235 |
+
)
|
236 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
237 |
+
|
238 |
+
# Quantize
|
239 |
+
model.quantize(tokenizer, quant_config=quant_config)
|
240 |
+
|
241 |
+
# Save quantized model
|
242 |
+
model.save_quantized(quant_path)
|
243 |
+
tokenizer.save_pretrained(quant_path)
|
244 |
+
|
245 |
+
print(f'Model is quantized and saved at "{quant_path}"')
|
246 |
+
```
|
USE_POLICY.md
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Llama 3.1 Acceptable Use Policy
|
2 |
+
|
3 |
+
Meta is committed to promoting safe and fair use of its tools and features, including Llama 3.1. If you
|
4 |
+
access or use Llama 3.1, you agree to this Acceptable Use Policy (“Policy”). The most recent copy of
|
5 |
+
this policy can be found at [https://llama.meta.com/llama3_1/use-policy](https://llama.meta.com/llama3_1/use-policy)
|
6 |
+
|
7 |
+
## Prohibited Uses
|
8 |
+
|
9 |
+
We want everyone to use Llama 3.1 safely and responsibly. You agree you will not use, or allow
|
10 |
+
others to use, Llama 3.1 to:
|
11 |
+
|
12 |
+
1. Violate the law or others’ rights, including to:
|
13 |
+
1. Engage in, promote, generate, contribute to, encourage, plan, incite, or further illegal or unlawful activity or content, such as:
|
14 |
+
1. Violence or terrorism
|
15 |
+
2. Exploitation or harm to children, including the solicitation, creation, acquisition, or dissemination of child exploitative content or failure to report Child Sexual Abuse Material
|
16 |
+
3. Human trafficking, exploitation, and sexual violence
|
17 |
+
4. The illegal distribution of information or materials to minors, including obscene materials, or failure to employ legally required age-gating in connection with such information or materials.
|
18 |
+
5. Sexual solicitation
|
19 |
+
6. Any other criminal activity
|
20 |
+
3. Engage in, promote, incite, or facilitate the harassment, abuse, threatening, or bullying of individuals or groups of individuals
|
21 |
+
4. Engage in, promote, incite, or facilitate discrimination or other unlawful or harmful conduct in the provision of employment, employment benefits, credit, housing, other economic benefits, or other essential goods and services
|
22 |
+
5. Engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or related professional practices
|
23 |
+
6. Collect, process, disclose, generate, or infer health, demographic, or other sensitive personal or private information about individuals without rights and consents required by applicable laws
|
24 |
+
7. Engage in or facilitate any action or generate any content that infringes, misappropriates, or otherwise violates any third-party rights, including the outputs or results of any products or services using the Llama Materials
|
25 |
+
8. Create, generate, or facilitate the creation of malicious code, malware, computer viruses or do anything else that could disable, overburden, interfere with or impair the proper working, integrity, operation or appearance of a website or computer system
|
26 |
+
|
27 |
+
2. Engage in, promote, incite, facilitate, or assist in the planning or development of activities that present a risk of death or bodily harm to individuals, including use of Llama 3.1 related to the following:
|
28 |
+
1. Military, warfare, nuclear industries or applications, espionage, use for materials or activities that are subject to the International Traffic Arms Regulations (ITAR) maintained by the United States Department of State
|
29 |
+
2. Guns and illegal weapons (including weapon development)
|
30 |
+
3. Illegal drugs and regulated/controlled substances
|
31 |
+
4. Operation of critical infrastructure, transportation technologies, or heavy machinery
|
32 |
+
5. Self-harm or harm to others, including suicide, cutting, and eating disorders
|
33 |
+
6. Any content intended to incite or promote violence, abuse, or any infliction of bodily harm to an individual
|
34 |
+
|
35 |
+
3. Intentionally deceive or mislead others, including use of Llama 3.1 related to the following:
|
36 |
+
1. Generating, promoting, or furthering fraud or the creation or promotion of disinformation
|
37 |
+
2. Generating, promoting, or furthering defamatory content, including the creation of defamatory statements, images, or other content
|
38 |
+
3. Generating, promoting, or further distributing spam
|
39 |
+
4. Impersonating another individual without consent, authorization, or legal right
|
40 |
+
5. Representing that the use of Llama 3.1 or outputs are human-generated
|
41 |
+
6. Generating or facilitating false online engagement, including fake reviews and other means of fake online engagement
|
42 |
+
|
43 |
+
4. Fail to appropriately disclose to end users any known dangers of your AI system
|
44 |
+
|
45 |
+
Please report any violation of this Policy, software “bug,” or other problems that could lead to a violation
|
46 |
+
of this Policy through one of the following means:
|
47 |
+
|
48 |
+
* Reporting issues with the model: [https://github.com/meta-llama/llama-models/issues](https://github.com/meta-llama/llama-models/issues)
|
49 |
+
* Reporting risky content generated by the model: developers.facebook.com/llama_output_feedback
|
50 |
+
* Reporting bugs and security concerns: facebook.com/whitehat/info
|
51 |
+
* Reporting violations of the Acceptable Use Policy or unlicensed uses of Llama 3.1: [email protected]
|