n1ck-guo commited on
Commit
f6bb1f7
·
verified ·
1 Parent(s): 11f717f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -41
README.md CHANGED
@@ -4,14 +4,9 @@ datasets:
4
  - NeelNanda/pile-10k
5
  ---
6
 
7
- ---
8
- license: apache-2.0
9
- datasets:
10
- - NeelNanda/pile-10k
11
-
12
  ## Model Details
13
 
14
- This model is an int4 model with group_size 128 with quantized lm-head of [Qwen/Qwen2-7B](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), auto-round is needed to run this model
15
 
16
  ## How To Use
17
 
@@ -22,21 +17,64 @@ This model is an int4 model with group_size 128 with quantized lm-head of [Qwen/
22
  ```python
23
  ##git clone https://github.com/intel/auto-round.git
24
  ##cd auto-round && pip install -vvv --no-build-isolation -e .
25
- from auto_round.auto_quantizer import AutoHfQuantizer
 
26
  from transformers import AutoModelForCausalLM,AutoTokenizer
27
  quantized_model_dir = "Intel/Qwen2.5-1.5B-Instruct-int4-inc"
28
  tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
29
- model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, device_map="auto")
30
- text = "下面我来介绍一下阿里巴巴公司,"
31
- text = "88+99等于多少?"
32
- text = "Once upon a time,"
33
- text = "There is a girl who likes adventure,"
34
- inputs = tokenizer(text, return_tensors="pt").to(model.device)
35
- print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
36
- ##下面我来介绍一下阿里巴巴公司,阿里巴巴集团是一家全球领先的电子商务和数字技术公司。它成立于1999年,总部位于中国杭州,并在全球拥有超过20个办公室和超过3万名员工。阿里巴巴集团的业务包括在线零售、云计算、金融服务、物流
37
- ##88+99等于多少?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
- ##Once upon a time, there was a young girl named Lily who loved to explore the world around her. She would often wander through fields and forests, looking for new places to visit and things to discover.One day, while she was wandering in a nearby forest, she stumbled
39
- ##There is a girl who likes adventure, and she has been exploring the world for many years. She has visited every country in Europe, climbed mountains all over the world, and even sailed across oceans on her own. However, she still feels that there are more places to explore.One day
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ```
41
 
42
  ### Evaluate the model
@@ -45,27 +83,26 @@ pip3 install lm-eval==0.4.2
45
 
46
  ```bash
47
  git clone https://github.com/intel/auto-round
48
- cd auto-round/examples/language-modeling
49
- python3 eval_042/evluation.py --model_name "Intel/Qwen2.5-1.5B-Instruct-int4-inc" --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,truthfulqa_mc2,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid
50
  ```
51
 
52
- | Metric | BF16 | INT4 |
53
- | -------------- | ------ | ------ |
54
- | Avg | 0.5575 | 0.5618 |
55
- | mmlu | 0.6010 | 0.5924 |
56
- | cmmlu | 0.6497 | 0.6259 |
57
- | ceval-valid | 0.6597 | 0.6404 |
58
- | lambada_openai | 0.6095 | 0.5924 |
59
- | hellaswag | 0.5082 | 0.5012 |
60
- | winogrande | 0.6298 | 0.6409 |
61
- | piqa | 0.7633 | 0.7650 |
62
- | truthfulqa_mc1 | 0.3109 | 0.3060 |
63
- | truthfulqa_mc2 | 0.4663 | 0.4563 |
64
- | openbookqa | 0.3160 | 0.3020 |
65
- | boolq | 0.7789 | 0.7709 |
66
- | arc_easy | 0.7677 | 0.7681 |
67
- | arc_challenge | 0.4343 | 0.4360 |
68
- | gsm8k 5 shots | 0.3101 | 0.4519 |
69
 
70
 
71
 
@@ -77,12 +114,11 @@ Here is the sample command to reproduce the model. We observed a larger accuracy
77
 
78
  ```bash
79
  git clone https://github.com/intel/auto-round
80
- cd auto-round/examples/language-modeling
81
- pip install -r requirements.txt
82
- python3 main.py \
83
  --model_name Qwen/Qwen2.5-1.5B-Instruct \
84
  --device 0 \
85
- --group_size 32 \
86
  --nsamples 512 \
87
  --bits 4 \
88
  --iter 1000 \
 
4
  - NeelNanda/pile-10k
5
  ---
6
 
 
 
 
 
 
7
  ## Model Details
8
 
9
+ This model is an int4 model with group_size 128 with quantized lm-head of [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), auto-round is needed to run this model
10
 
11
  ## How To Use
12
 
 
17
  ```python
18
  ##git clone https://github.com/intel/auto-round.git
19
  ##cd auto-round && pip install -vvv --no-build-isolation -e .
20
+ from auto_round import AutoHfQuantizer ##must import
21
+ import torch
22
  from transformers import AutoModelForCausalLM,AutoTokenizer
23
  quantized_model_dir = "Intel/Qwen2.5-1.5B-Instruct-int4-inc"
24
  tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
25
+
26
+ model = AutoModelForCausalLM.from_pretrained(
27
+ quantized_model_dir,
28
+ torch_dtype='auto',
29
+ device_map="auto",
30
+ )
31
+
32
+ ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
33
+ ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
34
+ ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
35
+
36
+ prompt = "There is a girl who likes adventure,"
37
+ messages = [
38
+ {"role": "system", "content": "You are a helpful assistant."},
39
+ {"role": "user", "content": prompt}
40
+ ]
41
+
42
+ text = tokenizer.apply_chat_template(
43
+ messages,
44
+ tokenize=False,
45
+ add_generation_prompt=True
46
+ )
47
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
48
+
49
+ generated_ids = model.generate(
50
+ model_inputs.input_ids,
51
+ max_new_tokens=50, ##change this to align with the official usage
52
+ do_sample=False ##change this to align with the official usage
53
+ )
54
+ generated_ids = [
55
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
56
+ ]
57
+
58
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
59
+ print(response)
60
+
61
+ ##prompt = "There is a girl who likes adventure,"
62
+ ##That's great! What kind of adventure does she like?
63
+
64
+ ##prompt = "Which one is bigger, 9.11 or 9.8"
65
+ ##To determine which number is larger between 9.11 and 9.8, you can compare them directly:
66
+ ##1. Start with the numbers: 9.11 and 9.8.
67
+ ##2. Compare their digits from left to
68
+
69
+
70
+ ##prompt = "Once upon a time,"
71
+ ##once upon a time, there was a young girl named Lily who lived in a small village nestled among the rolling hills of England. She had always been fascinated by nature and the beauty of the world around her.One day, while exploring the woods near\
72
+
73
+ ##prompt = "请介绍一下阿里巴巴公司"
74
+ ##阿里巴巴集团是一家全球领先的电子商务和科技企业,成立于1999年。阿里巴巴集团总部位于中国杭州,并在全球范围内拥有超过20个运营中心。
75
+ ##阿里巴巴集团的业务范围包括:
76
+ ##1. 电子商务:阿里巴巴集团是全球
77
+
78
  ```
79
 
80
  ### Evaluate the model
 
83
 
84
  ```bash
85
  git clone https://github.com/intel/auto-round
86
+ cd auto-round
87
+ python -m auto_round --model "Intel/Qwen2.5-1.5B-Instruct-int4-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid
88
  ```
89
 
90
+ | Metric | BF16 | INT4(group_size 128) | INT4(group_size 32) |
91
+ |:--------------:| :----: | :----: |:------:|
92
+ | Avg | 0.5646 | 0.5668 | 0.5699 |
93
+ | mmlu | 0.6010 | 0.5876 | 0.5924 |
94
+ | cmmlu | 0.6497 | 0.6146 | 0.6259 |
95
+ | ceval-valid | 0.6597 | 0.6382 | 0.6404 |
96
+ | lambada_openai | 0.6095 | 0.5886 | 0.6082 |
97
+ | hellaswag | 0.5082 | 0.4985 | 0.5012 |
98
+ | winogrande | 0.6298 | 0.6204 | 0.6409 |
99
+ | piqa | 0.7633 | 0.7519 | 0.7650 |
100
+ | truthfulqa_mc1 | 0.3109 | 0.3158 | 0.3060 |
101
+ | openbookqa | 0.3160 | 0.2940 | 0.3020 |
102
+ | boolq | 0.7789 | 0.7703 | 0.7681 |
103
+ | arc_easy | 0.7677 | 0.7660 | 0.7681 |
104
+ | arc_challenge | 0.4343 | 0.4454 | 0.4360 |
105
+ | gsm8k 5 shots | 0.3101 | 0.4776 | 0.4519 |
 
106
 
107
 
108
 
 
114
 
115
  ```bash
116
  git clone https://github.com/intel/auto-round
117
+ cd auto-round
118
+ python -m auto_round \
 
119
  --model_name Qwen/Qwen2.5-1.5B-Instruct \
120
  --device 0 \
121
+ --group_size 128 \
122
  --nsamples 512 \
123
  --bits 4 \
124
  --iter 1000 \