abhinavkulkarni commited on
Commit
fee5333
1 Parent(s): e1e8b82

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +134 -0
README.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ language:
4
+ - code
5
+ tags:
6
+ - llama2
7
+ - awq
8
+ ---
9
+ # **Code Llama**
10
+ Code Llama is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 34 billion parameters.
11
+
12
+ This model is a 4-bit 128 group size AWQ quantized model. For more information about AWQ quantization, please click [here](https://github.com/mit-han-lab/llm-awq).
13
+
14
+ ## Model Date
15
+
16
+ August 31, 2023
17
+
18
+ ## Model License
19
+
20
+ Please refer to the original LLaMA 2 model license ([link](https://huggingface.co/codellama/CodeLlama-7b-hfhf)).
21
+
22
+ Please refer to the AWQ quantization license ([link](https://github.com/llm-awq/blob/main/LICENSE)).
23
+
24
+ Version
25
+
26
+ This model was successfully tested on CUDA driver v530.30.02 and runtime v11.7 with Python v3.10.11. Please note that AWQ requires NVIDIA GPUs with compute capability of `8.0` or higher.
27
+
28
+ For Docker users, the `nvcr.io/nvidia/pytorch:23.06-py3` image is runtime v12.1 but otherwise the same as the configuration above and has also been verified to work.
29
+
30
+ ## How to Use
31
+
32
+ ```bash
33
+ git clone https://github.com/mit-han-lab/llm-awq \
34
+ && cd llm-awq \
35
+ && git checkout ce4a6bb1c238c014a06672cb74f6865573494d66 \
36
+ && pip install -e . \
37
+ && cd awq/kernels \
38
+ && python setup.py install
39
+ ```
40
+
41
+ ```python
42
+ import time
43
+ import torch
44
+ from awq.quantize.quantizer import real_quantize_model_weight
45
+ from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer
46
+ from accelerate import init_empty_weights, load_checkpoint_and_dispatch
47
+ from huggingface_hub import snapshot_download
48
+
49
+ model_name = "abhinavkulkarni/codellama-CodeLlama-7b-hf-w4-g128-awq"
50
+
51
+ # Config
52
+ config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
53
+
54
+ # Tokenizer
55
+ try:
56
+ tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name, trust_remote_code=True)
57
+ except:
58
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False, trust_remote_code=True)
59
+ streamer = TextStreamer(tokenizer, skip_special_tokens=True)
60
+
61
+ # Model
62
+ w_bit = 4
63
+ q_config = {
64
+ "zero_point": True,
65
+ "q_group_size": 128,
66
+ }
67
+
68
+ load_quant = snapshot_download(model_name)
69
+
70
+ with init_empty_weights():
71
+ model = AutoModelForCausalLM.from_config(config=config,
72
+ torch_dtype=torch.float16, trust_remote_code=True)
73
+
74
+ real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
75
+ model.tie_weights()
76
+
77
+ model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
78
+
79
+ # Inference
80
+ prompt = f"import socket\n\ndef ping_exponential_backoff(host: str):"
81
+
82
+ input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
83
+ output = model.generate(
84
+ inputs=input_ids,
85
+ temperature=0.7,
86
+ max_new_tokens=512,
87
+ top_p=0.15,
88
+ top_k=0,
89
+ repetition_penalty=1.1,
90
+ eos_token_id=tokenizer.eos_token_id,
91
+ streamer=streamer)
92
+ ```
93
+
94
+ ## Evaluation
95
+
96
+ This evaluation was done using OpenAI [HumanEval](https://github.com/openai/human-eval)
97
+
98
+ [CodeLlama-7b-hf](https://huggingface.co/codellama/CodeLlama-7b-hf)
99
+
100
+ | Task |Version| Metric | Value | |Stderr|
101
+ |---------|------:|---------------|--------:|---|------|
102
+ |HumanEval| 1|pass@1 |32.9268% | | |
103
+
104
+ [CodeLlama-7b-hf (4-bit 128-group AWQ)](https://huggingface.co/abhinavkulkarni/codellama-CodeLlama-7b-hf-w4-g128-awq)
105
+
106
+ | Task |Version| Metric | Value | |Stderr|
107
+ |---------|------:|---------------|--------:|---|------|
108
+ |HumanEval| 1|pass@1 |32.9268% | | |
109
+
110
+ ## Acknowledgements
111
+
112
+ You can cite codellama paper as follows:
113
+
114
+ ```
115
+ @misc{rozière2023code,
116
+ title={Code Llama: Open Foundation Models for Code},
117
+ author={Baptiste Rozière and Jonas Gehring and Fabian Gloeckle and Sten Sootla and Itai Gat and Xiaoqing Ellen Tan and Yossi Adi and Jingyu Liu and Tal Remez and Jérémy Rapin and Artyom Kozhevnikov and Ivan Evtimov and Joanna Bitton and Manish Bhatt and Cristian Canton Ferrer and Aaron Grattafiori and Wenhan Xiong and Alexandre Défossez and Jade Copet and Faisal Azhar and Hugo Touvron and Louis Martin and Nicolas Usunier and Thomas Scialom and Gabriel Synnaeve},
118
+ year={2023},
119
+ eprint={2308.12950},
120
+ archivePrefix={arXiv},
121
+ primaryClass={cs.CL}
122
+ }
123
+ ```
124
+
125
+ The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper:
126
+
127
+ ```
128
+ @article{lin2023awq,
129
+ title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
130
+ author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
131
+ journal={arXiv},
132
+ year={2023}
133
+ }
134
+ ```