TheBloke commited on
Commit
1d90cff
1 Parent(s): bea61bb

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +329 -0
README.md ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/codellama/CodeLlama-7b-instruct-hf
3
+ inference: false
4
+ language:
5
+ - code
6
+ license: llama2
7
+ model_creator: Meta
8
+ model_name: CodeLlama 7B Instruct
9
+ model_type: llama
10
+ pipeline_tag: text-generation
11
+ prompt_template: '[INST] Write code to solve the following coding problem that obeys
12
+ the constraints and passes the example test cases. Please wrap your code answer
13
+ using ```:
14
+
15
+ {prompt}
16
+
17
+ [/INST]
18
+
19
+ '
20
+ quantized_by: TheBloke
21
+ tags:
22
+ - llama-2
23
+ ---
24
+
25
+ <!-- header start -->
26
+ <!-- 200823 -->
27
+ <div style="width: auto; margin-left: auto; margin-right: auto">
28
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
29
+ </div>
30
+ <div style="display: flex; justify-content: space-between; width: 100%;">
31
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
32
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
33
+ </div>
34
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
35
+ <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>
36
+ </div>
37
+ </div>
38
+ <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>
39
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
40
+ <!-- header end -->
41
+
42
+ # CodeLlama 7B Instruct - AWQ
43
+ - Model creator: [Meta](https://huggingface.co/meta-llama)
44
+ - Original model: [CodeLlama 7B Instruct](https://huggingface.co/codellama/CodeLlama-7b-instruct-hf)
45
+
46
+ <!-- description start -->
47
+ ## Description
48
+
49
+ This repo contains AWQ model files for [Meta's CodeLlama 7B Instruct](https://huggingface.co/codellama/CodeLlama-7b-instruct-hf).
50
+
51
+
52
+ ### About AWQ
53
+
54
+ 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.
55
+
56
+ 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.
57
+ <!-- description end -->
58
+ <!-- repositories-available start -->
59
+ ## Repositories available
60
+
61
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-AWQ)
62
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GPTQ)
63
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-GGUF)
64
+ * [Meta's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/codellama/CodeLlama-7b-instruct-hf)
65
+ <!-- repositories-available end -->
66
+
67
+ <!-- prompt-template start -->
68
+ ## Prompt template: CodeLlama
69
+
70
+ ```
71
+ [INST] Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```:
72
+ {prompt}
73
+ [/INST]
74
+
75
+ ```
76
+
77
+ <!-- prompt-template end -->
78
+
79
+
80
+ <!-- README_AWQ.md-provided-files start -->
81
+ ## Provided files and AWQ parameters
82
+
83
+ 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.
84
+
85
+ Models are released as sharded safetensors files.
86
+
87
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
88
+ | ------ | ---- | -- | ----------- | ------- | ---- |
89
+ | [main](https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-AWQ/tree/main) | 4 | 128 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 3.89 GB
90
+
91
+ <!-- README_AWQ.md-provided-files end -->
92
+
93
+ <!-- README_AWQ.md-use-from-vllm start -->
94
+ ## Serving this model from vLLM
95
+
96
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
97
+
98
+ - When using vLLM as a server, pass the `--quantization awq` parameter, for example:
99
+
100
+ ```shell
101
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/CodeLlama-7B-Instruct-AWQ --quantization awq
102
+ ```
103
+
104
+ When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
105
+
106
+ ```python
107
+ from vllm import LLM, SamplingParams
108
+
109
+ prompts = [
110
+ "Hello, my name is",
111
+ "The president of the United States is",
112
+ "The capital of France is",
113
+ "The future of AI is",
114
+ ]
115
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
116
+
117
+ llm = LLM(model="TheBloke/CodeLlama-7B-Instruct-AWQ", quantization="awq")
118
+
119
+ outputs = llm.generate(prompts, sampling_params)
120
+
121
+ # Print the outputs.
122
+ for output in outputs:
123
+ prompt = output.prompt
124
+ generated_text = output.outputs[0].text
125
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
126
+ ```
127
+ <!-- README_AWQ.md-use-from-vllm start -->
128
+
129
+ <!-- README_AWQ.md-use-from-python start -->
130
+ ## How to use this AWQ model from Python code
131
+
132
+ ### Install the necessary packages
133
+
134
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.0.2 or later
135
+
136
+ ```shell
137
+ pip3 install autoawq
138
+ ```
139
+
140
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
141
+
142
+ ```shell
143
+ pip3 uninstall -y autoawq
144
+ git clone https://github.com/casper-hansen/AutoAWQ
145
+ cd AutoAWQ
146
+ pip3 install .
147
+ ```
148
+
149
+ ### You can then try the following example code
150
+
151
+ ```python
152
+ from awq import AutoAWQForCausalLM
153
+ from transformers import AutoTokenizer
154
+
155
+ model_name_or_path = "TheBloke/CodeLlama-7B-Instruct-AWQ"
156
+
157
+ # Load model
158
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
159
+ trust_remote_code=True, safetensors=True)
160
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
161
+
162
+ prompt = "Tell me about AI"
163
+ prompt_template=f'''[INST] Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```:
164
+ {prompt}
165
+ [/INST]
166
+
167
+ '''
168
+
169
+ print("\n\n*** Generate:")
170
+
171
+ tokens = tokenizer(
172
+ prompt_template,
173
+ return_tensors='pt'
174
+ ).input_ids.cuda()
175
+
176
+ # Generate output
177
+ generation_output = model.generate(
178
+ tokens,
179
+ do_sample=True,
180
+ temperature=0.7,
181
+ top_p=0.95,
182
+ top_k=40,
183
+ max_new_tokens=512
184
+ )
185
+
186
+ print("Output: ", tokenizer.decode(generation_output[0]))
187
+
188
+ # Inference can also be done using transformers' pipeline
189
+ from transformers import pipeline
190
+
191
+ print("*** Pipeline:")
192
+ pipe = pipeline(
193
+ "text-generation",
194
+ model=model,
195
+ tokenizer=tokenizer,
196
+ max_new_tokens=512,
197
+ do_sample=True,
198
+ temperature=0.7,
199
+ top_p=0.95,
200
+ top_k=40,
201
+ repetition_penalty=1.1
202
+ )
203
+
204
+ print(pipe(prompt_template)[0]['generated_text'])
205
+ ```
206
+ <!-- README_AWQ.md-use-from-python end -->
207
+
208
+ <!-- README_AWQ.md-compatibility start -->
209
+ ## Compatibility
210
+
211
+ The files provided are tested to work with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), and [vLLM](https://github.com/vllm-project/vllm).
212
+
213
+ [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).
214
+ <!-- README_AWQ.md-compatibility end -->
215
+
216
+ <!-- footer start -->
217
+ <!-- 200823 -->
218
+ ## Discord
219
+
220
+ For further support, and discussions on these models and AI in general, join us at:
221
+
222
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
223
+
224
+ ## Thanks, and how to contribute
225
+
226
+ Thanks to the [chirper.ai](https://chirper.ai) team!
227
+
228
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
235
+
236
+ * Patreon: https://patreon.com/TheBlokeAI
237
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
238
+
239
+ **Special thanks to**: Aemon Algiz.
240
+
241
+ **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
242
+
243
+
244
+ Thank you to all my generous patrons and donaters!
245
+
246
+ And thank you again to a16z for their generous grant.
247
+
248
+ <!-- footer end -->
249
+
250
+ # Original model card: Meta's CodeLlama 7B Instruct
251
+
252
+ # **Code Llama**
253
+ Code Llama is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 34 billion parameters. This is the repository for the 7B instruct-tuned version in the Hugging Face Transformers format. This model is designed for general code synthesis and understanding. Links to other models can be found in the index at the bottom.
254
+
255
+ | | Base Model | Python | Instruct |
256
+ | --- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
257
+ | 7B | [codellama/CodeLlama-7b-hf](https://huggingface.co/codellama/CodeLlama-7b-hf) | [codellama/CodeLlama-7b-Python-hf](https://huggingface.co/codellama/CodeLlama-7b-Python-hf) | [codellama/CodeLlama-7b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
258
+ | 13B | [codellama/CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf) | [codellama/CodeLlama-13b-Python-hf](https://huggingface.co/codellama/CodeLlama-13b-Python-hf) | [codellama/CodeLlama-13b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-13b-Instruct-hf) |
259
+ | 34B | [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf) | [codellama/CodeLlama-34b-Python-hf](https://huggingface.co/codellama/CodeLlama-34b-Python-hf) | [codellama/CodeLlama-34b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-34b-Instruct-hf) |
260
+
261
+ ## Model Use
262
+
263
+ To use this model, please make sure to install transformers from `main` until the next version is released:
264
+
265
+ ```bash
266
+ pip install git+https://github.com/huggingface/transformers.git@main accelerate
267
+ ```
268
+
269
+ Model capabilities:
270
+
271
+ - [x] Code completion.
272
+ - [x] Infilling.
273
+ - [x] Instructions / chat.
274
+ - [ ] Python specialist.
275
+
276
+
277
+ ## Model Details
278
+ *Note: Use of this model is governed by the Meta license. Meta developed and publicly released the Code Llama family of large language models (LLMs).
279
+
280
+ **Model Developers** Meta
281
+
282
+ **Variations** Code Llama comes in three model sizes, and three variants:
283
+
284
+ * Code Llama: base models designed for general code synthesis and understanding
285
+ * Code Llama - Python: designed specifically for Python
286
+ * Code Llama - Instruct: for instruction following and safer deployment
287
+
288
+ All variants are available in sizes of 7B, 13B and 34B parameters.
289
+
290
+ **This repository contains the Instruct version of the 7B parameters model.**
291
+
292
+ **Input** Models input text only.
293
+
294
+ **Output** Models generate text only.
295
+
296
+ **Model Architecture** Code Llama is an auto-regressive language model that uses an optimized transformer architecture.
297
+
298
+ **Model Dates** Code Llama and its variants have been trained between January 2023 and July 2023.
299
+
300
+ **Status** This is a static model trained on an offline dataset. Future versions of Code Llama - Instruct will be released as we improve model safety with community feedback.
301
+
302
+ **License** A custom commercial license is available at: [https://ai.meta.com/resources/models-and-libraries/llama-downloads/](https://ai.meta.com/resources/models-and-libraries/llama-downloads/)
303
+
304
+ **Research Paper** More information can be found in the paper "[Code Llama: Open Foundation Models for Code](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/)" or its [arXiv page](https://arxiv.org/abs/2308.12950).
305
+
306
+ ## Intended Use
307
+ **Intended Use Cases** Code Llama and its variants is intended for commercial and research use in English and relevant programming languages. The base model Code Llama can be adapted for a variety of code synthesis and understanding tasks, Code Llama - Python is designed specifically to handle the Python programming language, and Code Llama - Instruct is intended to be safer to use for code assistant and generation applications.
308
+
309
+ **Out-of-Scope Uses** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for Code Llama and its variants.
310
+
311
+ ## Hardware and Software
312
+ **Training Factors** We used custom training libraries. The training and fine-tuning of the released models have been performed Meta’s Research Super Cluster.
313
+
314
+ **Carbon Footprint** In aggregate, training all 9 Code Llama models required 400K GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W). Estimated total emissions were 65.3 tCO2eq, 100% of which were offset by Meta’s sustainability program.
315
+
316
+ ## Training Data
317
+
318
+ All experiments reported here and the released models have been trained and fine-tuned using the same data as Llama 2 with different weights (see Section 2 and Table 1 in the [research paper](https://ai.meta.com/research/publications/code-llama-open-foundation-models-for-code/) for details).
319
+
320
+ ## Evaluation Results
321
+
322
+ See evaluations for the main models and detailed ablations in Section 3 and safety evaluations in Section 4 of the research paper.
323
+
324
+
325
+ ## Ethical Considerations and Limitations
326
+
327
+ Code Llama and its variants are a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, Code Llama’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate or objectionable responses to user prompts. Therefore, before deploying any applications of Code Llama, developers should perform safety testing and tuning tailored to their specific applications of the model.
328
+
329
+ Please see the Responsible Use Guide available available at [https://ai.meta.com/llama/responsible-user-guide](https://ai.meta.com/llama/responsible-user-guide).