Views
No views yet
1from intel_extension_for_transformers.transformers import AutoModelForCausalLM
2from transformers import AutoTokenizer
3quantized_model_dir = "Intel/falcon-7b-int4-inc"
4model = AutoModelForCausalLM.from_pretrained(quantized_model_dir,
5 device_map="auto",
6 trust_remote_code=False,
7 use_neural_speed=False,
8 )
9tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, use_fast=True)
10print(tokenizer.decode(model.generate(**tokenizer("There is a girl who likes adventure,", return_tensors="pt").to(model.device),max_new_tokens=50)[0]))
11"""
12There is a girl who likes adventure, and she is a girl who likes to be a hero. She is a girl who likes to be a hero. She is a girl who likes to be a hero. She is a girl who likes to be a hero. She is a girl who
13"""1##pip install auto-gptq
2from auto_gptq import AutoGPTQForCausalLM
3from transformers import AutoTokenizer
4quantized_model_dir = "Intel/falcon-7b-int4-inc"
5tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
6model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8text = "There is a girl who likes adventure,"
9inputs = tokenizer(text, return_tensors="pt").to(model.device)
10print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
11#There is a girl who likes adventure, and she is a girl who likes to travel. She is a girl who likes to go to the beach, and she is a girl who likes to go to the mountains. She is a girl who likes to go to the city, and she islm_eval --model hf --model_args pretrained="Intel/falcon-7b-int4-inc",autogptq=True,gptq_use_triton=True --device cuda:0 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu --batch_size 16| Metric | BF16 | int4 |
|---|---|---|
| Avg. | 0.5462 | 0.5454 |
| mmlu | 0.2546 | 0.2562 |
| lambada_openai | 0.7450 | 0.7485 |
| hellaswag | 0.5773 | 0.5719 |
| winogrande | 0.6740 | 0.6835 |
| piqa | 0.7943 | 0.7905 |
| truthfulqa_mc1 | 0.2228 | 0.2166 |
| openbookqa | 0.3080 | 0.3100 |
| boolq | 0.7361 | 0.7431 |
| arc_easy | 0.7475 | 0.7424 |
| arc_challenge | 0.4027 | 0.3908 |
1git clone https://github.com/intel/auto-round
2cd auto-round/examples/language-modeling
3pip install -r requirements.txt
4python3 main.py \
5--model_name tiiuae/falcon-7b \
6--device 0 \
7--group_size 64 \
8--bits 4 \
9--iters 1000 \
10--disable_quanted_input \
11--deployment_device 'gpu' \
12--output_dir "./tmp_autoround"