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-code-16k-qlora
3
+ inference: false
4
+ license: apache-2.0
5
+ model_creator: Kamil
6
+ model_name: Mistral 7B Code 16K qLoRA
7
+ model_type: mistral
8
+ prompt_template: 'Below is an instruction that describes a task. Write a response
9
+ that appropriately completes the request.
10
+
11
+
12
+ ### Instruction:
13
+
14
+ {prompt}
15
+
16
+
17
+ ### Response:
18
+
19
+ '
20
+ quantized_by: TheBloke
21
+ ---
22
+ <!-- markdownlint-disable MD041 -->
23
+
24
+ <!-- header start -->
25
+ <!-- 200823 -->
26
+ <div style="width: auto; margin-left: auto; margin-right: auto">
27
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
28
+ </div>
29
+ <div style="display: flex; justify-content: space-between; width: 100%;">
30
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
31
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
32
+ </div>
33
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
34
+ <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>
35
+ </div>
36
+ </div>
37
+ <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>
38
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
39
+ <!-- header end -->
40
+
41
+ # Mistral 7B Code 16K qLoRA - AWQ
42
+ - Model creator: [Kamil](https://huggingface.co/Nondzu)
43
+ - Original model: [Mistral 7B Code 16K qLoRA](https://huggingface.co/Nondzu/Mistral-7B-code-16k-qlora)
44
+
45
+ <!-- description start -->
46
+ ## Description
47
+
48
+ This repo contains AWQ model files for [Kamil's Mistral 7B Code 16K qLoRA](https://huggingface.co/Nondzu/Mistral-7B-code-16k-qlora).
49
+
50
+
51
+ ### About AWQ
52
+
53
+ 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 with equivalent or better quality compared to the most commonly used GPTQ settings.
54
+
55
+ It is supported by:
56
+
57
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
58
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
59
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
60
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
61
+
62
+ <!-- description end -->
63
+ <!-- repositories-available start -->
64
+ ## Repositories available
65
+
66
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mistral-7B-Code-16K-qlora-AWQ)
67
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mistral-7B-Code-16K-qlora-GPTQ)
68
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Mistral-7B-Code-16K-qlora-GGUF)
69
+ * [Kamil's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/Nondzu/Mistral-7B-code-16k-qlora)
70
+ <!-- repositories-available end -->
71
+
72
+ <!-- prompt-template start -->
73
+ ## Prompt template: Alpaca
74
+
75
+ ```
76
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
77
+
78
+ ### Instruction:
79
+ {prompt}
80
+
81
+ ### Response:
82
+
83
+ ```
84
+
85
+ <!-- prompt-template end -->
86
+
87
+
88
+ <!-- README_AWQ.md-provided-files start -->
89
+ ## Provided files, and AWQ parameters
90
+
91
+ 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.
92
+
93
+ Models are released as sharded safetensors files.
94
+
95
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
96
+ | ------ | ---- | -- | ----------- | ------- | ---- |
97
+ | [main](https://huggingface.co/TheBloke/Mistral-7B-Code-16K-qlora-AWQ/tree/main) | 4 | 128 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 4.15 GB
98
+
99
+ <!-- README_AWQ.md-provided-files end -->
100
+
101
+ <!-- README_AWQ.md-text-generation-webui start -->
102
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
103
+
104
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
105
+
106
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
107
+
108
+ 1. Click the **Model tab**.
109
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Mistral-7B-Code-16K-qlora-AWQ`.
110
+ 3. Click **Download**.
111
+ 4. The model will start downloading. Once it's finished it will say "Done".
112
+ 5. In the top left, click the refresh icon next to **Model**.
113
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Mistral-7B-Code-16K-qlora-AWQ`
114
+ 7. Select **Loader: AutoAWQ**.
115
+ 8. Click Load, and the model will load and is now ready for use.
116
+ 9. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
117
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
118
+ <!-- README_AWQ.md-text-generation-webui end -->
119
+
120
+ <!-- README_AWQ.md-use-from-vllm start -->
121
+ ## Multi-user inference server: vLLM
122
+
123
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
124
+
125
+ - Please ensure you are using vLLM version 0.2 or later.
126
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
127
+
128
+ For example:
129
+
130
+ ```shell
131
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/Mistral-7B-Code-16K-qlora-AWQ --quantization awq
132
+ ```
133
+
134
+ - When using vLLM from Python code, again set `quantization=awq`.
135
+
136
+ For example:
137
+
138
+ ```python
139
+ from vllm import LLM, SamplingParams
140
+
141
+ prompts = [
142
+ "Tell me about AI",
143
+ "Write a story about llamas",
144
+ "What is 291 - 150?",
145
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
146
+ ]
147
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
148
+
149
+ ### Instruction:
150
+ {prompt}
151
+
152
+ ### Response:
153
+ '''
154
+
155
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
156
+
157
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
158
+
159
+ llm = LLM(model="TheBloke/Mistral-7B-Code-16K-qlora-AWQ", quantization="awq", dtype="auto")
160
+
161
+ outputs = llm.generate(prompts, sampling_params)
162
+
163
+ # Print the outputs.
164
+ for output in outputs:
165
+ prompt = output.prompt
166
+ generated_text = output.outputs[0].text
167
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
168
+ ```
169
+ <!-- README_AWQ.md-use-from-vllm start -->
170
+
171
+ <!-- README_AWQ.md-use-from-tgi start -->
172
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
173
+
174
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
175
+
176
+ Example Docker parameters:
177
+
178
+ ```shell
179
+ --model-id TheBloke/Mistral-7B-Code-16K-qlora-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
180
+ ```
181
+
182
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
183
+
184
+ ```shell
185
+ pip3 install huggingface-hub
186
+ ```
187
+
188
+ ```python
189
+ from huggingface_hub import InferenceClient
190
+
191
+ endpoint_url = "https://your-endpoint-url-here"
192
+
193
+ prompt = "Tell me about AI"
194
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
195
+
196
+ ### Instruction:
197
+ {prompt}
198
+
199
+ ### Response:
200
+ '''
201
+
202
+ client = InferenceClient(endpoint_url)
203
+ response = client.text_generation(prompt,
204
+ max_new_tokens=128,
205
+ do_sample=True,
206
+ temperature=0.7,
207
+ top_p=0.95,
208
+ top_k=40,
209
+ repetition_penalty=1.1)
210
+
211
+ print(f"Model output: ", response)
212
+ ```
213
+ <!-- README_AWQ.md-use-from-tgi end -->
214
+
215
+ <!-- README_AWQ.md-use-from-python start -->
216
+ ## Inference from Python code using AutoAWQ
217
+
218
+ ### Install the AutoAWQ package
219
+
220
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
221
+
222
+ ```shell
223
+ pip3 install autoawq
224
+ ```
225
+
226
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
227
+
228
+ ```shell
229
+ pip3 uninstall -y autoawq
230
+ git clone https://github.com/casper-hansen/AutoAWQ
231
+ cd AutoAWQ
232
+ pip3 install .
233
+ ```
234
+
235
+ ### AutoAWQ example code
236
+
237
+ ```python
238
+ from awq import AutoAWQForCausalLM
239
+ from transformers import AutoTokenizer
240
+
241
+ model_name_or_path = "TheBloke/Mistral-7B-Code-16K-qlora-AWQ"
242
+
243
+ # Load tokenizer
244
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
245
+ # Load model
246
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
247
+ trust_remote_code=False, safetensors=True)
248
+
249
+ prompt = "Tell me about AI"
250
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
251
+
252
+ ### Instruction:
253
+ {prompt}
254
+
255
+ ### Response:
256
+ '''
257
+
258
+ print("*** Running model.generate:")
259
+
260
+ token_input = tokenizer(
261
+ prompt_template,
262
+ return_tensors='pt'
263
+ ).input_ids.cuda()
264
+
265
+ # Generate output
266
+ generation_output = model.generate(
267
+ token_input,
268
+ do_sample=True,
269
+ temperature=0.7,
270
+ top_p=0.95,
271
+ top_k=40,
272
+ max_new_tokens=512
273
+ )
274
+
275
+ # Get the tokens from the output, decode them, print them
276
+ token_output = generation_output[0]
277
+ text_output = tokenizer.decode(token_output)
278
+ print("LLM output: ", text_output)
279
+
280
+ """
281
+ # Inference should be possible with transformers pipeline as well in future
282
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
283
+ from transformers import pipeline
284
+
285
+ print("*** Pipeline:")
286
+ pipe = pipeline(
287
+ "text-generation",
288
+ model=model,
289
+ tokenizer=tokenizer,
290
+ max_new_tokens=512,
291
+ do_sample=True,
292
+ temperature=0.7,
293
+ top_p=0.95,
294
+ top_k=40,
295
+ repetition_penalty=1.1
296
+ )
297
+
298
+ print(pipe(prompt_template)[0]['generated_text'])
299
+ """
300
+ ```
301
+ <!-- README_AWQ.md-use-from-python end -->
302
+
303
+ <!-- README_AWQ.md-compatibility start -->
304
+ ## Compatibility
305
+
306
+ The files provided are tested to work with:
307
+
308
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
309
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
310
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
311
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
312
+
313
+ <!-- README_AWQ.md-compatibility end -->
314
+
315
+ <!-- footer start -->
316
+ <!-- 200823 -->
317
+ ## Discord
318
+
319
+ For further support, and discussions on these models and AI in general, join us at:
320
+
321
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
322
+
323
+ ## Thanks, and how to contribute
324
+
325
+ Thanks to the [chirper.ai](https://chirper.ai) team!
326
+
327
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
328
+
329
+ 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.
330
+
331
+ 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.
332
+
333
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
334
+
335
+ * Patreon: https://patreon.com/TheBlokeAI
336
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
337
+
338
+ **Special thanks to**: Aemon Algiz.
339
+
340
+ **Patreon special mentions**: Pierre Kircher, Stanislav Ovsiannikov, Michael Levine, Eugene Pentland, Andrey, 준교 김, Randy H, Fred von Graf, Artur Olbinski, Caitlyn Gatomon, terasurfer, Jeff Scroggin, James Bentley, Vadim, Gabriel Puliatti, Harry Royden McLaughlin, Sean Connelly, Dan Guido, Edmond Seymore, Alicia Loh, subjectnull, AzureBlack, Manuel Alberto Morcote, Thomas Belote, Lone Striker, Chris Smitley, Vitor Caleffi, Johann-Peter Hartmann, Clay Pascal, biorpg, Brandon Frisco, sidney chen, transmissions 11, Pedro Madruga, jinyuan sun, Ajan Kanaga, Emad Mostaque, Trenton Dambrowitz, Jonathan Leane, Iucharbius, usrbinkat, vamX, George Stoitzev, Luke Pendergrass, theTransient, Olakabola, Swaroop Kallakuri, Cap'n Zoog, Brandon Phillips, Michael Dempsey, Nikolai Manek, danny, Matthew Berman, Gabriel Tamborski, alfie_i, Raymond Fosdick, Tom X Nguyen, Raven Klaugh, LangChain4j, Magnesian, Illia Dulskyi, David Ziegler, Mano Prime, Luis Javier Navarrete Lozano, Erik Bjäreholt, 阿明, Nathan Dryer, Alex, Rainer Wilmers, zynix, TL, Joseph William Delisle, John Villwock, Nathan LeClaire, Willem Michiel, Joguhyik, GodLy, OG, Alps Aficionado, Jeffrey Morgan, ReadyPlayerEmma, Tiffany J. Kim, Sebastain Graf, Spencer Kim, Michael Davis, webtim, Talal Aujan, knownsqashed, John Detwiler, Imad Khwaja, Deo Leter, Jerry Meng, Elijah Stavena, Rooh Singh, Pieter, SuperWojo, Alexandros Triantafyllidis, Stephen Murray, Ai Maven, ya boyyy, Enrico Ros, Ken Nordquist, Deep Realms, Nicholas, Spiking Neurons AB, Elle, Will Dee, Jack West, RoA, Luke @flexchar, Viktor Bowallius, Derek Yates, Subspace Studios, jjj, Toran Billups, Asp the Wyvern, Fen Risland, Ilya, NimbleBox.ai, Chadd, Nitin Borwankar, Emre, Mandus, Leonard Tan, Kalila, K, Trailburnt, S_X, Cory Kujawski
341
+
342
+
343
+ Thank you to all my generous patrons and donaters!
344
+
345
+ And thank you again to a16z for their generous grant.
346
+
347
+ <!-- footer end -->
348
+
349
+ # Original model card: Kamil's Mistral 7B Code 16K qLoRA
350
+
351
+ # Mistral-7B-code-16k-qlora
352
+
353
+ I'm excited to announce the release of a new model called Mistral-7B-code-16k-qlora. This small and fast model shows a lot of promise for supporting coding or acting as a copilot. I'm currently looking for people to help me test it out!
354
+
355
+ ## Additional Information
356
+
357
+ This model was trained on 3x RTX 3090 in my homelab, using around 65kWh for approximately 23 cents, which is equivalent to around $15 for electricity.
358
+
359
+ ## Dataset:
360
+ nickrosh/Evol-Instruct-Code-80k-v1
361
+ https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1
362
+ ## Prompt template: Alpaca
363
+ ```
364
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
365
+
366
+ ### Instruction:
367
+ {prompt}
368
+
369
+ ### Response:
370
+ ```
371
+
372
+ [<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl"/>](https://github.com/OpenAccess-AI-Collective/axolotl)
373
+ ## Settings:
374
+ ```
375
+ base_model: mistralai/Mistral-7B-Instruct-v0.1
376
+ base_model_config: mistralai/Mistral-7B-Instruct-v0.1
377
+ model_type: MistralForCausalLM
378
+ tokenizer_type: LlamaTokenizer
379
+ is_mistral_derived_model: true
380
+
381
+ load_in_8bit: false
382
+ load_in_4bit: true
383
+ strict: false
384
+
385
+ datasets:
386
+ - path: nickrosh/Evol-Instruct-Code-80k-v1
387
+ type: oasst
388
+ dataset_prepared_path:
389
+ val_set_size: 0.01
390
+ output_dir: ./Mistral-7B-Evol-Instruct-16k-test11
391
+ adapter: qlora
392
+ lora_model_dir:
393
+ # 16384 8192 4096 2048
394
+ sequence_len: 16384
395
+ sample_packing: true
396
+ pad_to_sequence_len: true
397
+ lora_r: 32
398
+ lora_alpha: 16
399
+ lora_dropout: 0.05
400
+ lora_target_modules:
401
+ lora_target_linear: true
402
+ lora_fan_in_fan_out:
403
+
404
+ wandb_project: mistral-code
405
+ wandb_entity:
406
+ wandb_watch:
407
+ wandb_run_id:
408
+ wandb_log_model:
409
+
410
+ gradient_accumulation_steps: 2
411
+ micro_batch_size: 1
412
+ num_epochs: 8
413
+ optimizer: paged_adamw_32bit
414
+ lr_scheduler: cosine
415
+ learning_rate: 0.0002
416
+
417
+ train_on_inputs: false
418
+ group_by_length: false
419
+ bf16: true
420
+ fp16: false
421
+ tf32: false
422
+ gradient_checkpointing: true
423
+ early_stopping_patience:
424
+ resume_from_checkpoint:
425
+ local_rank:
426
+ logging_steps: 1
427
+ xformers_attention:
428
+ flash_attention: true
429
+
430
+ warmup_steps: 10
431
+ eval_steps: 20
432
+ save_steps:
433
+ debug:
434
+ # deepspeed:
435
+ deepspeed: deepspeed/zero2.json
436
+ weight_decay: 0.0
437
+ fsdp:
438
+ fsdp_config:
439
+ special_tokens:
440
+ bos_token: "<s>"
441
+ eos_token: "</s>"
442
+ unk_token: "<unk>"
443
+
444
+ ```
445
+
446
+
447
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/63729f35acef705233c87909/NyuqJFDkH00KGvuOwHIuG.png)
448
+
449
+ Check my other projects:
450
+
451
+ https://github.com/Nondzu/LlamaTor