Views
No views yet
1from intel_extension_for_transformers.transformers import AutoModelForCausalLM
2from transformers import AutoTokenizer
3quantized_model_dir = "Intel/gemma-2b-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"""
12<bos>There is a girl who likes adventure, and she is a girl who likes to travel. She is a girl who likes to explore the world and see new things. She is a girl who likes to meet new people and learn about their cultures. She is a girl who likes to take risks
13"""1##pip install auto-gptq
2from transformers import AutoModelForCausalLM, AutoTokenizer
3quantized_model_dir = "Intel/gemma-2b-int4-inc"
4tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
5model = AutoModelForCausalLM.from_pretrained(quantized_model_dir,
6 device_map="auto",
7 trust_remote_code=False,
8 )
9tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, use_fast=True)
10text = "There is a girl who likes adventure,"
11inputs = tokenizer(text, return_tensors="pt").to(model.device)
12print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))
13##<bos>There is a girl who likes adventure, and she is a girl who likes to travel. She is a girl who likes to explore the world and see new things. She is a girl who likes to meet new people and learn about their cultures. She is a girl who likes to take riskslm_eval --model hf --model_args pretrained="Intel/gemma-2b-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 | FP16 | AutoRound v0.1 | AutoRound v0.2 |
|---|---|---|---|---|
| Avg. | 0.5263 | 0.5277 | 0.5235 | 0.5248 |
| mmlu | 0.3287 | 0.3287 | 0.3297 | 0.3309 |
| lambada_openai | 0.6344 | 0.6375 | 0.6307 | 0.6379 |
| hellaswag | 0.5273 | 0.5281 | 0.5159 | 0.5184 |
| winogrande | 0.6504 | 0.6488 | 0.6543 | 0.6575 |
| piqa | 0.7671 | 0.7720 | 0.7612 | 0.7606 |
| truthfulqa_mc1 | 0.2203 | 0.2203 | 0.2203 | 0.2191 |
| openbookqa | 0.2980 | 0.3020 | 0.3000 | 0.3060 |
| boolq | 0.6927 | 0.6936 | 0.6939 | 0.6966 |
| arc_easy | 0.7420 | 0.7403 | 0.7353 | 0.7357 |
| arc_challenge | 0.4019 | 0.4061 | 0.3933 | 0.3857 |
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 google/gemma-2b \
6--device 0 \
7--group_size 128 \
8--bits 4 \
9--iters 400 \
10--model_dtype "float16" \
11--deployment_device 'gpu' \
12--output_dir "./tmp_autoround"
13