change to bf16 and remove trust_remote_code
Browse files
README.md
CHANGED
@@ -18,35 +18,10 @@ Please follow the license of the original model.
|
|
18 |
|
19 |
**INT4 Inference on CUDA**(**at least 7*80G**)
|
20 |
|
21 |
-
On CUDA devices, the computation dtype is typically FP16 for int4 , which may lead to overflow for this model.
|
22 |
-
While we have added a workaround to address this issue, we cannot guarantee reliable performance for all prompts.
|
23 |
-
**For better stability, using CPU version is recommended. Please refer to the following section for details.**
|
24 |
-
|
25 |
~~~python
|
26 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
27 |
import transformers
|
28 |
|
29 |
-
# https://github.com/huggingface/transformers/pull/35493
|
30 |
-
def set_initialized_submodules(model, state_dict_keys):
|
31 |
-
"""
|
32 |
-
Sets the `_is_hf_initialized` flag in all submodules of a given model when all its weights are in the loaded state
|
33 |
-
dict.
|
34 |
-
"""
|
35 |
-
state_dict_keys = set(state_dict_keys)
|
36 |
-
not_initialized_submodules = {}
|
37 |
-
for module_name, module in model.named_modules():
|
38 |
-
if module_name == "":
|
39 |
-
# When checking if the root module is loaded there's no need to prepend module_name.
|
40 |
-
module_keys = set(module.state_dict())
|
41 |
-
else:
|
42 |
-
module_keys = {f"{module_name}.{k}" for k in module.state_dict()}
|
43 |
-
if module_keys.issubset(state_dict_keys):
|
44 |
-
module._is_hf_initialized = True
|
45 |
-
else:
|
46 |
-
not_initialized_submodules[module_name] = module
|
47 |
-
return not_initialized_submodules
|
48 |
-
|
49 |
-
transformers.modeling_utils.set_initialized_submodules = set_initialized_submodules
|
50 |
|
51 |
import torch
|
52 |
|
@@ -73,8 +48,7 @@ for i in range(61):
|
|
73 |
|
74 |
model = AutoModelForCausalLM.from_pretrained(
|
75 |
quantized_model_dir,
|
76 |
-
torch_dtype=torch.
|
77 |
-
trust_remote_code=True,
|
78 |
device_map=device_map,
|
79 |
)
|
80 |
|
@@ -121,69 +95,7 @@ for i, prompt in enumerate(prompts):
|
|
121 |
print(f"Generated: {decoded_outputs[i]}")
|
122 |
print("-" * 50)
|
123 |
|
124 |
-
"""
|
125 |
-
Prompt: 9.11和9.8哪个数字大
|
126 |
-
Generated: 要比较 **9.11** 和 **9.8** 的大小,可以按照以下步骤进行:
|
127 |
-
|
128 |
-
1. **比较整数部分**:
|
129 |
-
- 两个数的整数部分都是 **9**,因此整数部分相同。
|
130 |
-
|
131 |
-
2. **比较小数部分**:
|
132 |
-
- **9.11** 的小数部分是 **0.11**
|
133 |
-
- **9.8** 的小数部分是 **0.8**
|
134 |
-
|
135 |
-
3. **统一小数位数**:
|
136 |
-
- 将 **0.8** 转换为 **0.80**,以便于比较。
|
137 |
-
|
138 |
-
4. **进行大小比较**:
|
139 |
-
- **0.80** > **0.11**
|
140 |
-
|
141 |
-
因此,**9.8** 大于 **9.11**。
|
142 |
-
|
143 |
-
最终答案:\boxed{9.8}
|
144 |
-
--------------------------------------------------
|
145 |
-
|
146 |
-
--------------------------------------------------
|
147 |
-
Prompt: strawberry中有几个r?
|
148 |
-
Generated: ### 第一步:理解问题
|
149 |
-
|
150 |
-
首先,我需要明确问题的含义。问题是:“strawberry中有几个r?”。这里的“strawberry”是一个英文单词,意思是“草莓”。问题问的是这个单词中有多少个字母“r”。
|
151 |
-
|
152 |
-
### 第二步:分解单词
|
153 |
|
154 |
-
为了找出“strawberry”中有多少个“r”,我需要将这个单词分解成单个字母。让我们逐个字母来看:
|
155 |
-
|
156 |
-
- s
|
157 |
-
# 2023年10月浙江宁波市鄞州区第二医院医共体首南分院编外人员招考聘用笔试历年高频考点(难、易错点荟萃)附带答案详解.docx
|
158 |
-
|
159 |
-
## 2023年10月浙江宁波市鄞州区第二医院医共体首南分院编外人员招考聘用笔试历年高频考点(难、易错点荟萃)附带答案详解.docx
|
160 |
-
|
161 |
-
- 4、
|
162 |
-
--------------------------------------------------
|
163 |
-
Prompt: How many r in strawberry.
|
164 |
-
Generated: The word "strawberry" contains **3 "r"s.
|
165 |
-
--------------------------------------------------
|
166 |
-
Prompt: There is a girl who likes adventure,
|
167 |
-
Generated: That's wonderful! A girl who loves adventure is likely curious, brave, and eager to explore new experiences. Here are some ideas to fuel her adventurous spirit:
|
168 |
-
|
169 |
-
### Outdoor Adventures:
|
170 |
-
1. **Hiking**: Explore local trails, national parks, or even plan a multi-day trek.
|
171 |
-
2. **Camping**: Spend a night under the stars, roast marshmallows, and tell stories around a campfire.
|
172 |
-
3. **Rock Climbing**: Challenge herself with indoor or outdoor climbing.
|
173 |
-
4. **Kayaking or Canoeing**: Paddle through rivers, lakes, or even the ocean.
|
174 |
-
5. **Zip-lining**: Soar through the treetops for an adrenaline rush.
|
175 |
-
|
176 |
-
### Travel Adventures:
|
177 |
-
1. **Road Trips**: Plan a trip to a new city or state, stopping at interesting landmarks along the way.
|
178 |
-
2. **Backpacking**: Travel light and explore
|
179 |
-
--------------------------------------------------
|
180 |
-
Prompt: Please give a brief introduction of DeepSeek company.
|
181 |
-
Generated: DeepSeek Artificial Intelligence Co., Ltd. (referred to as "DeepSeek" or "深度求索") , founded in 2023, is a Chinese company dedicated to making AGI a reality.
|
182 |
-
--------------------------------------------------
|
183 |
-
Prompt: hello
|
184 |
-
Generated: Hello! How can I assist you today? 😊
|
185 |
-
|
186 |
-
"""
|
187 |
~~~
|
188 |
|
189 |
### INT4 Inference on CPU with ITREX(Recommended)
|
|
|
18 |
|
19 |
**INT4 Inference on CUDA**(**at least 7*80G**)
|
20 |
|
|
|
|
|
|
|
|
|
21 |
~~~python
|
22 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
23 |
import transformers
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
import torch
|
27 |
|
|
|
48 |
|
49 |
model = AutoModelForCausalLM.from_pretrained(
|
50 |
quantized_model_dir,
|
51 |
+
torch_dtype=torch.bfloat16,
|
|
|
52 |
device_map=device_map,
|
53 |
)
|
54 |
|
|
|
95 |
print(f"Generated: {decoded_outputs[i]}")
|
96 |
print("-" * 50)
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
~~~
|
100 |
|
101 |
### INT4 Inference on CPU with ITREX(Recommended)
|