|
--- |
|
datasets: |
|
- NeelNanda/pile-10k |
|
--- |
|
|
|
## Model Details |
|
|
|
This model is an int4 model with group_size 128 and symmetric quantization of [Falcon3-7B-Base](https://huggingface.co/tiiuae/Falcon3-7B-Base) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision `a10e358` to use AutoGPTQ format, with revision `e9aa317` to use AutoAWQ format |
|
|
|
## How To Use |
|
### INT4 Inference(CPU/HPU/CUDA) |
|
```python |
|
from auto_round import AutoRoundConfig ##must import for auto_round format |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
quantized_model_dir = "OPEA/Falcon3-7B-Base-int4-sym-inc" |
|
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) |
|
model = AutoModelForCausalLM.from_pretrained( |
|
quantized_model_dir, |
|
device_map="auto" |
|
## revision="a10e358" ##AutoGPTQ format |
|
## revision="e9aa317" ##AutoAWQ format |
|
) |
|
text = "How many r in strawberry? The answer is " |
|
inputs = tokenizer(text, return_tensors="pt", return_token_type_ids=False).to(model.device) |
|
print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0])) |
|
|
|
##INT4: |
|
## How many r in strawberry? The answer is 1.000000000000000000000000000000000000000000000000 |
|
|
|
##BF16: |
|
## How many r in strawberry? The answer is 1. |
|
|
|
### Additional Questions and Answers |
|
|
|
#### 11. **What is the value of 10000000000000000000000000 |
|
|
|
|
|
text = "Which number is bigger, 9.8 or 9.11? The answer is" |
|
##INT4: |
|
## Which number is bigger, 9.8 or 9.11? The answer is 9.8. |
|
## **Answer:** |
|
## To compare 9.8 and 9.11, we need to look at the digits in each place value. |
|
|
|
## 1. **Whole number part:** |
|
## - Both |
|
|
|
##BF16: |
|
## Which number is bigger, 9.8 or 9.11? The answer is 9.8. |
|
|
|
#### 10. **What is the smallest number?** |
|
## **Answer:** |
|
## The smallest number in the context of whole numbers is 0. However, if we consider the set of natural numbers, |
|
|
|
text = "Once upon a time," |
|
##INT4: |
|
## Once upon a time, in a land far away, there was a magical place called the "Library of Knowledge." This library had shelves and shelves filled with books about everything you could ever imagine - stories, science, history, and more! But one day, something |
|
|
|
##BF16: |
|
## Once upon a time, in a land far away, there was a magical place called the "Library of Alexandria." This library was home to thousands upon thousands of scrolls filled with stories, poems, and knowledge from all over the world. It was a place where people could |
|
|
|
text = "There is a girl who likes adventure," |
|
##INT4: |
|
## There is a girl who likes adventure, and she is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She |
|
|
|
##BF16: |
|
## There is a girl who likes adventure, and she is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She |
|
``` |
|
|
|
### Evaluate the model |
|
|
|
pip3 install lm-eval==0.4.5 |
|
|
|
```bash |
|
auto-round --model "OPEA/Falcon3-7B-Base-int4-sym-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu |
|
``` |
|
|
|
| Metric | BF16 | INT4 | |
|
| :-------------------------- | :----: | :----: | |
|
| Avg | 59.70 | 58.81 | |
|
| mmlu | 67.43 | 66.41 | |
|
| lambada_opeai | 68.52 | 68.12 | |
|
| hellaswage | 56.41 | 55.88 | |
|
| winogrande | 70.96 | 70.09 | |
|
| piqa | 77.86 | 77.48 | |
|
| truthfulqa_mc1 | 37.33 | 37.58 | |
|
| openbookqa | 30.80 | 30.60 | |
|
| boolq | 81.56 | 80.58 | |
|
| arc_easy | 80.81 | 79.80 | |
|
| arc_challenge | 51.11 | 49.57 | |
|
| mmlu_pro | 40.97 | 39.89 | |
|
| ifeval | 32.49 | 30.45 | |
|
| gsm8k | 75.66 | 74.45 | |
|
|
|
### Generate the model |
|
|
|
Here is the sample command to generate the model. |
|
```bash |
|
auto-round \ |
|
--model tiiuae/Falcon3-7B-Base \ |
|
--device 0 \ |
|
--group_size 128 \ |
|
--bits 4 \ |
|
--nsamples 512 \ |
|
--seqlen 2048 \ |
|
--iters 1000 \ |
|
--model_dtype "float16" \ |
|
--format 'auto_awq,auto_gptq,auto_round' \ |
|
--output_dir "./tmp_autoround" |
|
``` |
|
|
|
## Ethical Considerations and Limitations |
|
|
|
The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs. |
|
|
|
Therefore, before deploying any applications of the model, developers should perform safety testing. |
|
|
|
## Caveats and Recommendations |
|
|
|
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. |
|
|
|
Here are a couple of useful links to learn more about Intel's AI software: |
|
|
|
- Intel Neural Compressor [link](https://github.com/intel/neural-compressor) |
|
|
|
## Disclaimer |
|
|
|
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes. |
|
|
|
## Cite |
|
|
|
@article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} } |
|
|
|
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round) |