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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: https://huggingface.co/NousResearch/Yarn-Llama-2-7b-64k
|
3 |
+
datasets:
|
4 |
+
- pg19
|
5 |
+
inference: false
|
6 |
+
library_name: transformers
|
7 |
+
license: llama2
|
8 |
+
metrics:
|
9 |
+
- perplexity
|
10 |
+
model_creator: NousResearch
|
11 |
+
model_name: Yarn Llama 2 7B 64K
|
12 |
+
model_type: llama
|
13 |
+
prompt_template: '{prompt}
|
14 |
+
|
15 |
+
'
|
16 |
+
quantized_by: TheBloke
|
17 |
+
---
|
18 |
+
|
19 |
+
<!-- header start -->
|
20 |
+
<!-- 200823 -->
|
21 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
22 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
23 |
+
</div>
|
24 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
25 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
26 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
27 |
+
</div>
|
28 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
29 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
<div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
|
33 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
34 |
+
<!-- header end -->
|
35 |
+
|
36 |
+
# Yarn Llama 2 7B 64K - AWQ
|
37 |
+
- Model creator: [NousResearch](https://huggingface.co/NousResearch)
|
38 |
+
- Original model: [Yarn Llama 2 7B 64K](https://huggingface.co/NousResearch/Yarn-Llama-2-7b-64k)
|
39 |
+
|
40 |
+
<!-- description start -->
|
41 |
+
## Description
|
42 |
+
|
43 |
+
This repo contains AWQ model files for [NousResearch's Yarn Llama 2 7B 64K](https://huggingface.co/NousResearch/Yarn-Llama-2-7b-64k).
|
44 |
+
|
45 |
+
|
46 |
+
### About AWQ
|
47 |
+
|
48 |
+
AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference.
|
49 |
+
|
50 |
+
It is also now supported by continuous batching server [vLLM](https://github.com/vllm-project/vllm), allowing use of AWQ models for high-throughput concurrent inference in multi-user server scenarios. Note that, at the time of writing, overall throughput is still lower than running vLLM with unquantised models, however using AWQ enables using much smaller GPUs which can lead to easier deployment and overall cost savings. For example, a 70B model can be run on 1 x 48GB GPU instead of 2 x 80GB.
|
51 |
+
<!-- description end -->
|
52 |
+
<!-- repositories-available start -->
|
53 |
+
## Repositories available
|
54 |
+
|
55 |
+
* [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Yarn-Llama-2-7B-64K-AWQ)
|
56 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Yarn-Llama-2-7B-64K-GPTQ)
|
57 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Yarn-Llama-2-7B-64K-GGUF)
|
58 |
+
* [NousResearch's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/NousResearch/Yarn-Llama-2-7b-64k)
|
59 |
+
<!-- repositories-available end -->
|
60 |
+
|
61 |
+
<!-- prompt-template start -->
|
62 |
+
## Prompt template: None
|
63 |
+
|
64 |
+
```
|
65 |
+
{prompt}
|
66 |
+
|
67 |
+
```
|
68 |
+
|
69 |
+
<!-- prompt-template end -->
|
70 |
+
|
71 |
+
|
72 |
+
<!-- README_AWQ.md-provided-files start -->
|
73 |
+
## Provided files and AWQ parameters
|
74 |
+
|
75 |
+
For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
|
76 |
+
|
77 |
+
Models are released as sharded safetensors files.
|
78 |
+
|
79 |
+
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|
80 |
+
| ------ | ---- | -- | ----------- | ------- | ---- |
|
81 |
+
| [main](https://huggingface.co/TheBloke/Yarn-Llama-2-7B-64K-AWQ/tree/main) | 4 | 128 | [c4](https://huggingface.co/datasets/allenai/c4) | 4096 | 3.89 GB
|
82 |
+
|
83 |
+
<!-- README_AWQ.md-provided-files end -->
|
84 |
+
|
85 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
86 |
+
## Serving this model from vLLM
|
87 |
+
|
88 |
+
Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
|
89 |
+
|
90 |
+
- When using vLLM as a server, pass the `--quantization awq` parameter, for example:
|
91 |
+
|
92 |
+
```shell
|
93 |
+
python3 python -m vllm.entrypoints.api_server --model TheBloke/Yarn-Llama-2-7B-64K-AWQ --quantization awq
|
94 |
+
```
|
95 |
+
|
96 |
+
When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
|
97 |
+
|
98 |
+
```python
|
99 |
+
from vllm import LLM, SamplingParams
|
100 |
+
|
101 |
+
prompts = [
|
102 |
+
"Hello, my name is",
|
103 |
+
"The president of the United States is",
|
104 |
+
"The capital of France is",
|
105 |
+
"The future of AI is",
|
106 |
+
]
|
107 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
108 |
+
|
109 |
+
llm = LLM(model="TheBloke/Yarn-Llama-2-7B-64K-AWQ", quantization="awq")
|
110 |
+
|
111 |
+
outputs = llm.generate(prompts, sampling_params)
|
112 |
+
|
113 |
+
# Print the outputs.
|
114 |
+
for output in outputs:
|
115 |
+
prompt = output.prompt
|
116 |
+
generated_text = output.outputs[0].text
|
117 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
118 |
+
```
|
119 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
120 |
+
|
121 |
+
<!-- README_AWQ.md-use-from-python start -->
|
122 |
+
## How to use this AWQ model from Python code
|
123 |
+
|
124 |
+
### Install the necessary packages
|
125 |
+
|
126 |
+
Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.0.2 or later
|
127 |
+
|
128 |
+
```shell
|
129 |
+
pip3 install autoawq
|
130 |
+
```
|
131 |
+
|
132 |
+
If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
|
133 |
+
|
134 |
+
```shell
|
135 |
+
pip3 uninstall -y autoawq
|
136 |
+
git clone https://github.com/casper-hansen/AutoAWQ
|
137 |
+
cd AutoAWQ
|
138 |
+
pip3 install .
|
139 |
+
```
|
140 |
+
|
141 |
+
### You can then try the following example code
|
142 |
+
|
143 |
+
```python
|
144 |
+
from awq import AutoAWQForCausalLM
|
145 |
+
from transformers import AutoTokenizer
|
146 |
+
|
147 |
+
model_name_or_path = "TheBloke/Yarn-Llama-2-7B-64K-AWQ"
|
148 |
+
|
149 |
+
# Load model
|
150 |
+
model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
|
151 |
+
trust_remote_code=True, safetensors=True)
|
152 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
|
153 |
+
|
154 |
+
prompt = "Tell me about AI"
|
155 |
+
prompt_template=f'''{prompt}
|
156 |
+
|
157 |
+
'''
|
158 |
+
|
159 |
+
print("\n\n*** Generate:")
|
160 |
+
|
161 |
+
tokens = tokenizer(
|
162 |
+
prompt_template,
|
163 |
+
return_tensors='pt'
|
164 |
+
).input_ids.cuda()
|
165 |
+
|
166 |
+
# Generate output
|
167 |
+
generation_output = model.generate(
|
168 |
+
tokens,
|
169 |
+
do_sample=True,
|
170 |
+
temperature=0.7,
|
171 |
+
top_p=0.95,
|
172 |
+
top_k=40,
|
173 |
+
max_new_tokens=512
|
174 |
+
)
|
175 |
+
|
176 |
+
print("Output: ", tokenizer.decode(generation_output[0]))
|
177 |
+
|
178 |
+
# Inference can also be done using transformers' pipeline
|
179 |
+
from transformers import pipeline
|
180 |
+
|
181 |
+
print("*** Pipeline:")
|
182 |
+
pipe = pipeline(
|
183 |
+
"text-generation",
|
184 |
+
model=model,
|
185 |
+
tokenizer=tokenizer,
|
186 |
+
max_new_tokens=512,
|
187 |
+
do_sample=True,
|
188 |
+
temperature=0.7,
|
189 |
+
top_p=0.95,
|
190 |
+
top_k=40,
|
191 |
+
repetition_penalty=1.1
|
192 |
+
)
|
193 |
+
|
194 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
195 |
+
```
|
196 |
+
<!-- README_AWQ.md-use-from-python end -->
|
197 |
+
|
198 |
+
<!-- README_AWQ.md-compatibility start -->
|
199 |
+
## Compatibility
|
200 |
+
|
201 |
+
The files provided are tested to work with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), and [vLLM](https://github.com/vllm-project/vllm).
|
202 |
+
|
203 |
+
[Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is not yet compatible with AWQ, but a PR is open which should bring support soon: [TGI PR #781](https://github.com/huggingface/text-generation-inference/issues/781).
|
204 |
+
<!-- README_AWQ.md-compatibility end -->
|
205 |
+
|
206 |
+
<!-- footer start -->
|
207 |
+
<!-- 200823 -->
|
208 |
+
## Discord
|
209 |
+
|
210 |
+
For further support, and discussions on these models and AI in general, join us at:
|
211 |
+
|
212 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
213 |
+
|
214 |
+
## Thanks, and how to contribute
|
215 |
+
|
216 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
217 |
+
|
218 |
+
Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
|
219 |
+
|
220 |
+
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
|
221 |
+
|
222 |
+
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
|
223 |
+
|
224 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
225 |
+
|
226 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
227 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
228 |
+
|
229 |
+
**Special thanks to**: Aemon Algiz.
|
230 |
+
|
231 |
+
**Patreon special mentions**: Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann-Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
|
232 |
+
|
233 |
+
|
234 |
+
Thank you to all my generous patrons and donaters!
|
235 |
+
|
236 |
+
And thank you again to a16z for their generous grant.
|
237 |
+
|
238 |
+
<!-- footer end -->
|
239 |
+
|
240 |
+
# Original model card: NousResearch's Yarn Llama 2 7B 64K
|
241 |
+
|
242 |
+
# Model Card: Nous-Yarn-Llama-2-7b-64k
|
243 |
+
|
244 |
+
[Preprint (arXiv)](https://arxiv.org/abs/2309.00071)
|
245 |
+
[GitHub](https://github.com/jquesnelle/yarn)
|
246 |
+
|
247 |
+
## Model Description
|
248 |
+
|
249 |
+
Nous-Yarn-Llama-2-7b-64k is a state-of-the-art language model for long context, further pretrained on long context data for 400 steps.
|
250 |
+
This model is the Flash Attention 2 patched version of the original model: https://huggingface.co/conceptofmind/Yarn-Llama-2-7b-64k
|
251 |
+
|
252 |
+
Note that this model **requires** the [Flash Attention library](https://pypi.org/project/flash-attn/) in order to function correctly, see the Model Usage section for installation instructions.
|
253 |
+
|
254 |
+
## Model Training
|
255 |
+
|
256 |
+
Starting from the base Llama 2 models, this model was further pretrained on a subset of the PG19 dataset, allowing it to effectively utilize up to 64k tokens of context.
|
257 |
+
|
258 |
+
## Collaborators
|
259 |
+
|
260 |
+
- [bloc97](https://github.com/bloc97): Methods, Paper and evals
|
261 |
+
- [@theemozilla](https://twitter.com/theemozilla): Methods, Paper and evals
|
262 |
+
- [@EnricoShippole](https://twitter.com/EnricoShippole): Model Training
|
263 |
+
- [honglu2875](https://github.com/honglu2875): Paper and evals
|
264 |
+
|
265 |
+
The authors would like to thank Stability AI, Carper AI, and Eleuther AI for their generous support of significant computing resources that enabled the training of these models and the completion of this research. We would also like to thank Jonathan Tow and Dakota Mahan directly for their help in advising on the use of the Stability AI compute cluster. Additionally, we would like to thank a16z, and PygmalionAI, for providing resources to run evaluations and experiments on the models.
|
266 |
+
|
267 |
+
## Usage and Prompt Format
|
268 |
+
|
269 |
+
Install FA2 and Rotary Extensions:
|
270 |
+
```
|
271 |
+
pip install flash-attn --no-build-isolation
|
272 |
+
pip install git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary
|
273 |
+
```
|
274 |
+
|
275 |
+
There are no specific prompt formats as this is a pretrained base model.
|
276 |
+
|
277 |
+
## Benchmark Results
|
278 |
+
|
279 |
+
TODO
|
280 |
+
|
281 |
+
## Future Plans
|
282 |
+
We plan to continue training when we have more compute and to improve the dataset and/or instruct tune the models in order to improve the long context performance even further.
|
283 |
+
|
284 |
+
## Model Usage
|
285 |
+
|
286 |
+
The model is available for download on HuggingFace.
|