Instructions to use abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq
- SGLang
How to use abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq with Docker Model Runner:
docker model run hf.co/abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq
Commit ·
764c481
1
Parent(s): 403cd12
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- AWQ
|
| 5 |
+
inference: false
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# Falcon-40b-Instruct (4-bit 128g AWQ Quantized)
|
| 9 |
+
[Falcon-40b-Instruct](https://huggingface.co/tiiuae/falcon-40b-instruct) is a 40B parameters causal decoder-only model built by [TII](https://www.tii.ae) based on [Falcon-40B](https://huggingface.co/tiiuae/falcon-7b) and finetuned on a mixture of chat/instruct datasets.
|
| 10 |
+
|
| 11 |
+
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).
|
| 12 |
+
|
| 13 |
+
## Model Date
|
| 14 |
+
|
| 15 |
+
July 5, 2023
|
| 16 |
+
|
| 17 |
+
## Model License
|
| 18 |
+
|
| 19 |
+
Please refer to original Falcon model license ([link](https://huggingface.co/tiiuae/falcon-40b-instruct)).
|
| 20 |
+
|
| 21 |
+
Please refer to the AWQ quantization license ([link](https://github.com/llm-awq/blob/main/LICENSE)).
|
| 22 |
+
|
| 23 |
+
## CUDA Version
|
| 24 |
+
|
| 25 |
+
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 80 or higher.
|
| 26 |
+
|
| 27 |
+
## How to Use
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
git clone https://github.com/mit-han-lab/llm-awq \
|
| 31 |
+
&& cd llm-awq \
|
| 32 |
+
&& git checkout 71d8e68df78de6c0c817b029a568c064bf22132d \
|
| 33 |
+
&& pip install -e . \
|
| 34 |
+
&& cd awq/kernels \
|
| 35 |
+
&& python setup.py install
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
import torch
|
| 40 |
+
from awq.quantize.quantizer import real_quantize_model_weight
|
| 41 |
+
from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer
|
| 42 |
+
from accelerate import init_empty_weights, load_checkpoint_and_dispatch
|
| 43 |
+
from huggingface_hub import hf_hub_download
|
| 44 |
+
|
| 45 |
+
model_name = "tiiuae/falcon-40b-instruct"
|
| 46 |
+
|
| 47 |
+
# Config
|
| 48 |
+
config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
|
| 49 |
+
|
| 50 |
+
# Tokenizer
|
| 51 |
+
tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name)
|
| 52 |
+
|
| 53 |
+
# Model
|
| 54 |
+
w_bit = 4
|
| 55 |
+
q_config = {
|
| 56 |
+
"zero_point": True,
|
| 57 |
+
"q_group_size": 64,
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
load_quant = hf_hub_download('abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq', 'pytorch_model.bin')
|
| 61 |
+
|
| 62 |
+
with init_empty_weights():
|
| 63 |
+
model = AutoModelForCausalLM.from_config(config=config,
|
| 64 |
+
torch_dtype=torch.float16, trust_remote_code=True)
|
| 65 |
+
|
| 66 |
+
real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
|
| 67 |
+
|
| 68 |
+
model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
|
| 69 |
+
|
| 70 |
+
# Inference
|
| 71 |
+
prompt = f'''What is the difference between nuclear fusion and fission?
|
| 72 |
+
###Response:'''
|
| 73 |
+
|
| 74 |
+
input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
|
| 75 |
+
output = model.generate(
|
| 76 |
+
inputs=input_ids,
|
| 77 |
+
temperature=0.7,
|
| 78 |
+
max_new_tokens=512,
|
| 79 |
+
top_p=0.15,
|
| 80 |
+
top_k=0,
|
| 81 |
+
repetition_penalty=1.1,
|
| 82 |
+
eos_token_id=tokenizer.eos_token_id
|
| 83 |
+
)
|
| 84 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## Evaluation
|
| 88 |
+
|
| 89 |
+
This evaluation was done using [LM-Eval](https://github.com/EleutherAI/lm-evaluation-harness).
|
| 90 |
+
|
| 91 |
+
[Falcon-40b-Instruct](https://huggingface.co/tiiuae/falcon-40b-instruct)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
[Falcon-40b-Instruct (4-bit 128-group AWQ)](https://huggingface.co/abhinavkulkarni/tiiuae-falcon-40b-instruct-w4-g128-awq)
|
| 95 |
+
|
| 96 |
+
| Task |Version| Metric |Value | |Stderr|
|
| 97 |
+
|--------|------:|---------------|-----:|---|------|
|
| 98 |
+
|wikitext| 1|word_perplexity|8.9237| | |
|
| 99 |
+
| | |byte_perplexity|1.5058| | |
|
| 100 |
+
| | |bits_per_byte |0.5905| | |
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
## Acknowledgements
|
| 104 |
+
|
| 105 |
+
*Paper coming soon* 😊. In the meanwhile, you can use the following information to cite:
|
| 106 |
+
```
|
| 107 |
+
@article{falcon40b,
|
| 108 |
+
title={{Falcon-40B}: an open large language model with state-of-the-art performance},
|
| 109 |
+
author={Almazrouei, Ebtesam and Alobeidli, Hamza and Alshamsi, Abdulaziz and Cappelli, Alessandro and Cojocaru, Ruxandra and Debbah, Merouane and Goffinet, Etienne and Heslow, Daniel and Launay, Julien and Malartic, Quentin and Noune, Badreddine and Pannier, Baptiste and Penedo, Guilherme},
|
| 110 |
+
year={2023}
|
| 111 |
+
}
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper:
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
@article{lin2023awq,
|
| 119 |
+
title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
|
| 120 |
+
author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
|
| 121 |
+
journal={arXiv},
|
| 122 |
+
year={2023}
|
| 123 |
+
}
|
| 124 |
+
```
|
| 125 |
+
|